Jump to content

[1.12.2] Problem with my proxies [Totally solved]


Legenes

Recommended Posts

I tried to make another mod, following the same steps that I done, but when I came to the point, where I need to make the proxies... it just isn't working.

My main class:
 

package com.betternether.mod;


import com.betternether.mod.proxy.CommonProxy;
import net.minecraft.item.Item;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

@Mod(modid = BetterNether.modId, name = BetterNether.name, version = BetterNether.version, acceptedMinecraftVersions = "[1.12.2]")
public class BetterNether {

    public static final String modId = "bn";
    public static final String name = "Better Nether Mod";
    public static final String version = "1.0.0";

    @SidedProxy(serverSide = "com.betternether.mod.proxy.CommonProxy", clientSide = "com.betternether.mod.proxy.ClientProxy")
    public static CommonProxy proxy;

    @Mod.EventBusSubscriber
    public static class RegistrationHandler {

        @SubscribeEvent
        public static void registerItems(RegistryEvent.Register<Item> event) {
            ModItems.register(event.getRegistry());
        }

        @SubscribeEvent
        public static void registerItems(ModelRegistryEvent event) {
            ModItems.registerModels();
        }

    }

    @Mod.Instance(modId)
    public static BetterNether instance;

    @Mod.EventHandler
    public void preInit(FMLPreInitializationEvent event) {
        System.out.println(name + " is loading!");
    }

    @Mod.EventHandler
    public void init(FMLInitializationEvent event) {

    }

    @Mod.EventHandler
    public void postInit(FMLPostInitializationEvent event) {

    }

}

 

My ClientProxy:
 

package com.betternether.mod.proxy;

public class ClientProxy {
}

 

My CommonProxy:
 

package com.betternether.mod.proxy;

import com.betternether.mod.BetterNether;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraftforge.client.model.ModelLoader;

public class CommonProxy {

    public void registerItemRenderer(Item item, int meta, String id) {
        ModelLoader.setCustomModelResourceLocation(item, meta, new ModelResourceLocation(BetterNether.modId + ":" + id, "inventory"));
    }

}

 

The error:

[16:36:01] [main/FATAL] [FML]: Attempted to load a proxy type com.betternether.mod.proxy.ClientProxy into com.betternether.mod.BetterNether.proxy, but the types don't match
[16:36:01] [main/ERROR] [FML]: An error occurred trying to load a proxy into proxy.net.minecraftforge.fml.common.LoaderException: Attempted to load a proxy type com.betternether.mod.proxy.ClientProxy into com.betternether.mod.BetterNether.proxy, but the types don't match
[16:36:01] [main/INFO] [STDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:629]: ---- Minecraft Crash Report ----
// I let you down. Sorry :(

Time: 7/15/18 4:36 PM
Description: There was a severe problem during mod loading that has caused the game to fail

net.minecraftforge.fml.common.LoaderException: net.minecraftforge.fml.common.LoaderException: Attempted to load a proxy type com.betternether.mod.proxy.ClientProxy into com.betternether.mod.BetterNether.proxy, but the types don't match
	at net.minecraftforge.fml.common.ProxyInjector.inject(ProxyInjector.java:102)
	at net.minecraftforge.fml.common.FMLModContainer.constructMod(FMLModContainer.java:603)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:497)
	at com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:91)
	at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:150)
	at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:76)
	at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399)
	at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:71)
	at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:116)
	at com.google.common.eventbus.EventBus.post(EventBus.java:217)
	at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:218)
	at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:196)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:497)
	at com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:91)
	at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:150)
	at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:76)
	at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399)
	at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:71)
	at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:116)
	at com.google.common.eventbus.EventBus.post(EventBus.java:217)
	at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:135)
	at net.minecraftforge.fml.common.Loader.loadMods(Loader.java:593)
	at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:226)
	at net.minecraft.client.Minecraft.init(Minecraft.java:513)
	at net.minecraft.client.Minecraft.run(Minecraft.java:421)
	at net.minecraft.client.main.Main.main(Main.java:118)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:497)
	at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
	at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:497)
	at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97)
	at GradleStart.main(GradleStart.java:25)
Caused by: net.minecraftforge.fml.common.LoaderException: Attempted to load a proxy type com.betternether.mod.proxy.ClientProxy into com.betternether.mod.BetterNether.proxy, but the types don't match
	at net.minecraftforge.fml.common.ProxyInjector.inject(ProxyInjector.java:95)
	... 43 more

 

And I was thinking... where did "com.betternether.mod.BetterNether.proxy" came from, if I used "com.betternether.mod.proxy.ClientProxy" and "com.betternether.mod.proxy.CommonProxy"?

Thanks for helping!

Edited by Legenes
procedure WakeMeUp(Integer plusTime);
var
  I: Integer;
begin
  for I := 0 to plusTime do begin
    println('One more minute!');
    Sleep(1000);
  end;
  println('Okay, nothing to worry, I''m alive!');
  println('So... somebody can give me a coffee?');
  println('I know it''s Pascal, and not Java, but I love it :D.');
end;
Link to comment
Share on other sites

3 minutes ago, Legenes said:

com.betternether.mod.BetterNether.proxy

This is the name of your field in your main mod class.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

So I need to extend my ClientProxy from CommonProxy?

 

procedure WakeMeUp(Integer plusTime);
var
  I: Integer;
begin
  for I := 0 to plusTime do begin
    println('One more minute!');
    Sleep(1000);
  end;
  println('Okay, nothing to worry, I''m alive!');
  println('So... somebody can give me a coffee?');
  println('I know it''s Pascal, and not Java, but I love it :D.');
end;
Link to comment
Share on other sites

Thanks, I got it worked!


My common proxy:
 

package com.betternether.mod.proxy;

import net.minecraft.item.Item;

public class CommonProxy {

    public void registerItemRenderer(Item item, int meta, String id) {

    }

}

 

My client proxy:

package com.betternether.mod.proxy;

import com.betternether.mod.BetterNether;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraftforge.client.model.ModelLoader;

public class ClientProxy extends CommonProxy {

    @Override
    public void registerItemRenderer(Item item, int meta, String id) {
        ModelLoader.setCustomModelResourceLocation(item, meta, new ModelResourceLocation(BetterNether.modId + ":" + id, "inventory"));
    }

}

 

I know that diesieben07 said something else with the Code Style Issue 1, but it works great, even on servers, so I use it.

Thanks for all, again! :D

Edited by Legenes
Little change on code
procedure WakeMeUp(Integer plusTime);
var
  I: Integer;
begin
  for I := 0 to plusTime do begin
    println('One more minute!');
    Sleep(1000);
  end;
  println('Okay, nothing to worry, I''m alive!');
  println('So... somebody can give me a coffee?');
  println('I know it''s Pascal, and not Java, but I love it :D.');
end;
Link to comment
Share on other sites

7 minutes ago, _Cruelar_ said:

What's exactly the Problem with having a CommonProxy, I've found nothing so far

It makes no sense. Proxies are objects which are injected into the field based on the physical side the game is on. The entire point of a proxy is to separate sided-only code. Your "common" code can go anywhere else. A common proxy is using proxies in the only way they are not supposed to be used.

Link to comment
Share on other sites

So... what can I do to get rid of the common proxy, I write everything that's in the common proxy at the place where it's used, so I can use only the Client Proxy, and I make a separate Server Proxy? (Sorry for this crappy sentence, but I'm Hungarian)

 

If yes, what should I write into the server one?

procedure WakeMeUp(Integer plusTime);
var
  I: Integer;
begin
  for I := 0 to plusTime do begin
    println('One more minute!');
    Sleep(1000);
  end;
  println('Okay, nothing to worry, I''m alive!');
  println('So... somebody can give me a coffee?');
  println('I know it''s Pascal, and not Java, but I love it :D.');
end;
Link to comment
Share on other sites

So... I made a Server Proxy, that has only the (idk what to call them) "functions", that are needed for the server, and a Client Proxy which has the "functions" needed for the client, and I have a proxy in the main class, that allows me to access both of them. Is this correct, because it runs :D ?

Edited by Legenes
procedure WakeMeUp(Integer plusTime);
var
  I: Integer;
begin
  for I := 0 to plusTime do begin
    println('One more minute!');
    Sleep(1000);
  end;
  println('Okay, nothing to worry, I''m alive!');
  println('So... somebody can give me a coffee?');
  println('I know it''s Pascal, and not Java, but I love it :D.');
end;
Link to comment
Share on other sites

Huh... this is a good question, because, the only things I know that it's object oriented and the syntax of it. I was using Pascal, Delphi, Php, Html, and C++, (The 2 last not for long), and I think I know enough to make a crappy, starting mod. :D

(I know that functions and methods are similar, and I know that how the extending works)

Edited by Legenes
procedure WakeMeUp(Integer plusTime);
var
  I: Integer;
begin
  for I := 0 to plusTime do begin
    println('One more minute!');
    Sleep(1000);
  end;
  println('Okay, nothing to worry, I''m alive!');
  println('So... somebody can give me a coffee?');
  println('I know it''s Pascal, and not Java, but I love it :D.');
end;
Link to comment
Share on other sites

While I respect diesieben07's objection to the common proxy approach, even the actual javadocs written by cpw for the proxy system suggest using a common proxy. So it is understandable that a lot of people have used it that way, and mostly It does works except logically you don't need code that runs on both sides to be in a proxy at all. So the term "common proxy" hurts our brains and I agree it probably further causes unnecessary confusion about the whole concept.

 

So the more modern recommendation is to have all the common stuff just run directly in your main mod class (or wherever you handle the FML loading events like pre-init and such) and then only call the proxy methods for things that actually differ between client and server. For those, you create an interface (e.g. IProxy) and a client and server class that implement that interface each with their own version of the method.

  • Thanks 2

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Link to comment
Share on other sites

I created the interface with both proxies implementing it, but can I make a method to be only implemented in one of them? Maybe making an abstract method somehow?

 

Edit: It's wrong if my proxies are abstract? Because it works great that way :D

 

Edited by Legenes
procedure WakeMeUp(Integer plusTime);
var
  I: Integer;
begin
  for I := 0 to plusTime do begin
    println('One more minute!');
    Sleep(1000);
  end;
  println('Okay, nothing to worry, I''m alive!');
  println('So... somebody can give me a coffee?');
  println('I know it''s Pascal, and not Java, but I love it :D.');
end;
Link to comment
Share on other sites

8 minutes ago, Legenes said:

It's wrong if my proxies are abstract?

They should not be abstract.

9 minutes ago, Legenes said:

I created the interface with both proxies implementing it, but can I make a method to be only implemented in one of them?

No

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

So then how my IProxy will know when it needs to use the Server's, or when it needs to use the Client's method, if they both have it?

procedure WakeMeUp(Integer plusTime);
var
  I: Integer;
begin
  for I := 0 to plusTime do begin
    println('One more minute!');
    Sleep(1000);
  end;
  println('Okay, nothing to worry, I''m alive!');
  println('So... somebody can give me a coffee?');
  println('I know it''s Pascal, and not Java, but I love it :D.');
end;
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
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.