Jump to content

[1.5.2]A mod tried to open a gui on the server without being a network mod


lorizz

Recommended Posts

Hi guys, I'm TheLorizz and today I'm here with a new problem!:

A mod tried to open a gui on the server without being a network mod

Why? I tried changing instances, redoing every main class (I got a mod for the client and and another for the server for a better security, 'cause I've got a custom launcher).

 

ExoWorld_Client (Client Mod Mainclass):

 

package it.exoworld_client;

import it.exoworld_client.handler.ExoGuiHandler;
import it.exoworld_client.proxy.ServerProxy;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.Init;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.Mod.PostInit;
import cpw.mods.fml.common.Mod.PreInit;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.network.NetworkRegistry;

@Mod(modid = ExoWorld_Client.modid, name = "Exotium World Mod (CLIENT SIDE)", version = "Beta 1.0")
@NetworkMod(clientSideRequired = true, serverSideRequired = false)
public class ExoWorld_Client {

@Instance(ExoWorld_Client.modid)
public static ExoWorld_Client instance = new ExoWorld_Client();

public static final String modid = "exoworld_client";

@SidedProxy(clientSide = "it.exoworld_client.proxy.ClientProxy", serverSide = "it.exoworld_client.proxy.ServerProxy")
public static ServerProxy proxy;

@PreInit
public void preInit(FMLPreInitializationEvent evt) {
	proxy.preInit();
}

@Init
public void init(FMLInitializationEvent evt) {
	proxy.init();
	System.out.println("============== LOADING GUI HANDLER =============");
	NetworkRegistry.instance().registerGuiHandler(ExoWorld_Client.instance, new ExoGuiHandler());
	System.out.println("============== Exotium World's Gui Handler Ver. Alpha 1.4_3b =============");
	System.out.println("============== DONE! =============");
}

@PostInit
public void postInit(FMLPostInitializationEvent evt) {
	proxy.postInit();
}
}

 

 

ExoWorld_Server (Server Mod Mainclass):

 

package it.exoworld_server;

import it.exoworld_client.handler.ExoGuiHandler;
import it.exoworld_server.proxy.ServerProxy;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.Init;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.Mod.PostInit;
import cpw.mods.fml.common.Mod.PreInit;
import cpw.mods.fml.common.Mod.ServerStarting;
import cpw.mods.fml.common.Mod.ServerStopping;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.event.FMLServerStartingEvent;
import cpw.mods.fml.common.event.FMLServerStoppingEvent;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.network.NetworkRegistry;

@Mod(modid = ExoWorld_Server.modid, name = "Exotium World Mod (SERVER SIDE)", version = "Beta 1.0")
@NetworkMod(clientSideRequired = false, serverSideRequired = true)
public class ExoWorld_Server {

@Instance(ExoWorld_Server.modid)
public static ExoWorld_Server instance = new ExoWorld_Server();

public static final String modid = "exoworld_server";

@SidedProxy(clientSide = "it.exoworld_server.proxy.ClientProxy", serverSide = "it.exoworld_server.proxy.ServerProxy")
public static ServerProxy proxy;

@PreInit
public void preInit(FMLPreInitializationEvent evt) {
	proxy.preInit();
}

@Init
public void init(FMLInitializationEvent evt) {
	proxy.init();
}

@PostInit
public void postInit(FMLPostInitializationEvent evt) {
	proxy.postInit();
}

@ServerStarting
public void serverStarting(FMLServerStartingEvent evt) {
	proxy.serverStarting(evt);
}

@ServerStopping
public void serverStopping(FMLServerStoppingEvent evt) {
	proxy.serverStopping();
}
}

 

 

ClientProxy (Called on server mod):

 

package it.exoworld_server.proxy;

import it.exoworld_client.ExoWorld_Client;
import it.exoworld_client.event.ExoEntityPlayerEvent;
import it.exoworld_client.event.ExoSoundEvent;
import it.exoworld_client.gui.ExoGuiStats;
import it.exoworld_client.handler.ExoGuiHandler;
import it.exoworld_client.handler.ExoKeyHandler;
import it.exoworld_client.recipe.RecipeHandler;
import it.exoworld_client.registry.BlockRegistry;
import it.exoworld_client.registry.ClassRegistry;
import it.exoworld_client.registry.ItemRegistry;
import it.exoworld_client.registry.TabRegistry;
import it.exoworld_client.renderer.ItemDaggerRenderer;
import it.exoworld_client.tileentity.TileEntityCharacter;
import it.exoworld_client.world.ExoWorldGenerator;
import net.minecraft.client.Minecraft;
import net.minecraftforge.client.IItemRenderer;
import net.minecraftforge.client.MinecraftForgeClient;
import net.minecraftforge.common.MinecraftForge;
import cpw.mods.fml.client.registry.KeyBindingRegistry;
import cpw.mods.fml.common.event.FMLServerStartingEvent;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.GameRegistry;

public class ClientProxy extends ServerProxy {

public void registerRenderers(IItemRenderer renderer) {
	MinecraftForgeClient.registerItemRenderer(
			ItemRegistry.daggerWooden.itemID, renderer);
}

public void registerTileEntities() {
	GameRegistry.registerTileEntity(TileEntityCharacter.class,
			"TileEntityCharacter");
}

@Override
public void preInit() {
	MinecraftForge.EVENT_BUS.register(new ExoSoundEvent());
	System.out.println("EVENT_BUS preinizializzati (CLIENT SIDE)!");
	GameRegistry.registerWorldGenerator(new ExoWorldGenerator());
	System.out.println("EXOWORLD: WorldGenerator caricato (CLIENT SIDE)!");
}

@Override
public void init() {
	RecipeHandler.removeRecipes();
	System.out.println("EXOWORLD: Ricette rimosse!");
	BlockRegistry.loadClass();
	ItemRegistry.loadClass();
	TabRegistry.loadClass();
	ClassRegistry.loadClass();
	System.out.println("EXOWORLD: Registry caricati!");
	this.registerRenderers(new ItemDaggerRenderer());
	System.out.println("EXOWORLD: Oggetti renderizzati!");
	this.registerTileEntities();
	System.out.println("EXOWORLD: Tile Entities registrati!");
	KeyBindingRegistry.registerKeyBinding(new ExoKeyHandler());
	System.out.println("EXOWORLD: Handler registrati (CLIENT SIDE)!");
}

@Override
public void postInit() {
	MinecraftForge.EVENT_BUS.register(new ExoGuiStats(Minecraft
			.getMinecraft()));
	MinecraftForge.EVENT_BUS.register(new ExoEntityPlayerEvent());
	System.out.println("EVENT_BUS registrati (CLIENT SIDE)!");
}

@Override
public void serverStarting(FMLServerStartingEvent evt) {

}

@Override
public void serverStopping() {

}
}

 

 

ServerProxy (Called on server mod too):

 

package it.exoworld_server.proxy;

import it.exoworld_client.event.ExoEntityEvent;
import it.exoworld_client.event.ExoEntityPlayerEvent;
import it.exoworld_client.recipe.RecipeHandler;
import it.exoworld_client.registry.BlockRegistry;
import it.exoworld_client.registry.ClassRegistry;
import it.exoworld_client.registry.ItemRegistry;
import it.exoworld_client.registry.TabRegistry;
import it.exoworld_client.world.ExoWorldGenerator;
import it.exoworld_server.handler.PlayerTracker;
import it.exoworld_server.network.SQL;
import net.minecraftforge.common.MinecraftForge;
import cpw.mods.fml.common.event.FMLServerStartingEvent;
import cpw.mods.fml.common.registry.GameRegistry;

public class ServerProxy {

public void preInit() {
	GameRegistry.registerPlayerTracker(new PlayerTracker());
	System.out.println("EXOWORLD: PlayerTracker registrato!");
	GameRegistry.registerWorldGenerator(new ExoWorldGenerator());
	System.out.println("EXOWORLD: WorldGenerator caricato (SERVER SIDE)!");
}

public void init() {
	RecipeHandler.removeRecipes();
	System.out.println("EXOWORLD: Ricette rimosse!");
	BlockRegistry.loadClass();
	ItemRegistry.loadClass();
	TabRegistry.loadClass();
	ClassRegistry.loadClass();
	System.out.println("EXOWORLD: Registry caricati!");
	System.out.println("EXOWORLD: Handler registrati (SERVER SIDE)!");
}

public void postInit() {
	MinecraftForge.EVENT_BUS.register(new ExoEntityEvent());
	MinecraftForge.EVENT_BUS.register(new ExoEntityPlayerEvent());
	System.out.println("EXOWORLD: EVENT_BUS registrati (SERVER SIDE)!");
}

public void serverStarting(FMLServerStartingEvent evt) {
	SQL.connect();
}

public void serverStopping() {
	SQL.disconnect();
}
}

 

 

GuiHandler:

 

package it.exoworld_client.handler;

import it.exoworld_client.container.ContainerCharacter;
import it.exoworld_client.gui.GuiCharacter;
import it.exoworld_client.tileentity.TileEntityCharacter;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import cpw.mods.fml.common.network.IGuiHandler;

public class ExoGuiHandler implements IGuiHandler {

@Override
public Object getServerGuiElement(int id, EntityPlayer player, World world,
		int x, int y, int z) {
	// This gets the TileEntity the player is currently activating
	TileEntity tile_entity = world.getBlockTileEntity(x, y, z);
	// This checks if the TileEntity is the TileTutorial
	if (tile_entity instanceof TileEntityCharacter) {
		// If it is it returns a new ContainerTutorial instance
		return new ContainerCharacter(player.inventory,
				(TileEntityCharacter) tile_entity);
	}

	// Returns null if not
	return null;
}

// This is another required method to open the Gui and has 6 params
// @param int id, this is the Gui Id
// @param EntityPlayer, this is the player declaration
// @param World, this is the world declaration,
// @param int x, y, z this is the players current x, y, z coords
@Override
public Object getClientGuiElement(int id, EntityPlayer player, World world,
		int x, int y, int z) {
	// This gets the TIleEntity the player is currently activating
	TileEntity tile_entity = world.getBlockTileEntity(x, y, z);

	// This checks if the TileEntity is the TileTutorial
	if (tile_entity instanceof TileEntityCharacter) {
		// If it is it returns a new GuiTutorial instance
		return new GuiCharacter(player.inventory, (TileEntityCharacter) tile_entity);
	}

	// Returns null if not
	return null;
}
}

 

 

KeyHandler (The class where the method "player.openGui()" has been called):

 

package it.exoworld_client.handler;

import it.exoworld_client.ExoWorld_Client;
import it.exoworld_client.registry.GuiRegistry;

import java.util.EnumSet;

import net.minecraft.client.Minecraft;
import net.minecraft.client.settings.KeyBinding;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;

import org.lwjgl.input.Keyboard;

import cpw.mods.fml.client.registry.KeyBindingRegistry.KeyHandler;
import cpw.mods.fml.common.TickType;

public class ExoKeyHandler extends KeyHandler {

public static Minecraft mc;

public static KeyBinding openCharacter = new KeyBinding(
		"Apri Equipaggiamento Personaggio", Keyboard.KEY_C);

public static KeyBinding[] arrayOfKeys = new KeyBinding[] { openCharacter };
public static boolean[] areRepeating = new boolean[] { false };

public static boolean isKeyDown = false;

public ExoKeyHandler() {
	super(arrayOfKeys, areRepeating);
	this.mc = Minecraft.getMinecraft();
}

@Override
public String getLabel() {
	return "Exotium World's Key Handler";
}

@Override
public void keyDown(EnumSet<TickType> types, KeyBinding kb,
		boolean tickEnd, boolean isRepeat) {
	this.isKeyDown = true;
	EntityPlayer player = (EntityPlayer) this.mc.thePlayer;
	World world = (World) this.mc.theWorld;
	int x = (int) player.posX;
	int y = (int) player.posY;
	int z = (int) player.posZ;
	if (kb.keyCode == this.openCharacter.keyCode) {
		player.openGui(ExoWorld_Client.modid, GuiRegistry.gui_Character, world, x, y, z);
	}
}

@Override
public void keyUp(EnumSet<TickType> types, KeyBinding kb, boolean tickEnd) {
	this.isKeyDown = false;
}

@Override
public EnumSet<TickType> ticks() {
	return EnumSet.of(TickType.CLIENT);
}
}[/spoiler]

 

Any help? Thanks!

Link to comment
Share on other sites

That...is not how you do client/server mods.

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

I know I know I know.... Just tell me how can I fix this problem and stop.

Make one mod. Not two.

 

I NEED two mods! This is the reason:

 

On Server Starting -> Server Mod Only -> Connect to MySQL database -> load everything -> put on client mod;

On Client Starting -> Server Mod Only -> Load everything from Client Mod Only;

Client Mod Only Contains: resources, textures;

Server Mod Only Contains: SQL table;

 

Now please can someone help me?

Link to comment
Share on other sites

Again: Make ONE mod. You can dynamically detect on which side you are (FMLCommonHandler.instance().getSide()) and act depending on that.

There is @SidedProxy invented exactly for this purpose. Read the tutorial on the wiki.

 

What word didn't you understand of "Connect to MySQL database" and "Anti-Steal Mod"?

Link to comment
Share on other sites

What word didn't you understand of "Connect to MySQL database" and "Anti-Steal Mod"?

 

Dude.

 

If you're distributing your server-side mod, it's stealable.

 

You also never mentioned "anti-steal" at any point prior to this.

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

ClientProxy (Called on server mod)

You didn't realize this is wrong ?

If you make a server only mod, it isn't supposed to have a client part at all.

 

On Server Starting -> Server Mod Only -> Connect to MySQL database -> load everything -> put on client mod;

On Client Starting -> Server Mod Only -> Load everything from Client Mod Only;

Doesn't make sense to me. Your "Server Mod Only" actually works like a Universal mod, and thus you don't need a "Client Mod Only", since you can merge it in the first one.

If "put on client mod" means installing it, you can't do that. It isn't possible to download and install a mod without restarting the game.

Link to comment
Share on other sites

And I am unable to understand what your problem with something like this is:

 

if (FMLCommonHandler.instance().getSide().isServer()) {
    connectToMySQL();
} else {
    // damn, we are on the Client, what now? Hm. Just do nothing
}

 

I know this....Let's see if it works then I need to work with this settings, otherwise there's a problem.

Link to comment
Share on other sites

ClientProxy (Called on server mod)

You didn't realize this is wrong ?

If you make a server only mod, it isn't supposed to have a client part at all.

 

On Server Starting -> Server Mod Only -> Connect to MySQL database -> load everything -> put on client mod;

On Client Starting -> Server Mod Only -> Load everything from Client Mod Only;

Doesn't make sense to me. Your "Server Mod Only" actually works like a Universal mod, and thus you don't need a "Client Mod Only", since you can merge it in the first one.

If "put on client mod" means installing it, you can't do that. It isn't possible to download and install a mod without restarting the game.

and

And I am unable to understand what your problem with something like this is:

 

if (FMLCommonHandler.instance().getSide().isServer()) {
    connectToMySQL();
} else {
    // damn, we are on the Client, what now? Hm. Just do nothing
}

 

I know this....Let's see if it works then I need to work with this settings, otherwise there's a problem.

 

I realized now that you guys didn't understand something: THEY CAN STEAL MY DATABASE INFORMATION!(host, username, password, database name), do you understand now??

 

If "put on client mod" means installing it, you can't do that. It isn't possible to download and install a mod without restarting the game

What the hell are you talking about? And now I write the last things.

If I have got a XMPP Chat connection and a MySQL Connection, do I need to load it on the client so EVERY PLAYER can get it from my Roaming folder (".exoworld"), put it in a minecraft.jar of a MCP folder and click the goddamn "DECOMPILE.BAT" for decompiling and deobfuscating my mod then open the SQLConnection and read every information?

Think guys before posting, I thought you were good guys and answering without complaining about Server and Client Side Mod Only, now I ask the last question.

 

 

 

Can I fix this problem WITHOUT deleting the server mod? How?

 

 

 

Simply just write "Yes, you can. You need to do...." or "No, you can't sorry!"

I'm not so stupid to load a mod in the client, it's SERVER SIDE ONLY it loads only on the server, NOBODY CAN ACCESS TO IT.

Link to comment
Share on other sites

This is where the magic of config files comes in.

 

DON'T PUT YOUR SQL INFO IN THE CODE.  Reference an external file.

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

This is where the magic of config files comes in.

 

DON'T PUT YOUR SQL INFO IN THE CODE.  Reference an external file.

 

It's in the goddamn server! Nobody can access to the server machine and get the EXOWORLD_SERVER.zip file! It's a launcher with multiple hosted server, join in a server and it downloads ONLY the files that are in the client folder of the server.

Link to comment
Share on other sites

It's in the goddamn server! Nobody can access to the server machine and get the EXOWORLD_SERVER.zip file! It's a launcher with multiple hosted server, join in a server and it downloads ONLY the files that are in the client folder of the server.

 

See, your problem is that you're never intending to distribute the server-side mod.

 

Stop thinking about it like that.

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

Can you just release the client side without the SQL code? As in put server side and client side to needed in both versions, and keep the mod Id the same, but remove any server side only code that you don't want stolen?

 

I need to save the player data, I also use datawatcher but if the launcher everytime find new files for the server or find modified files or missing files it redownload everything, I use SQL system.

 

Thanks guys I think I figured out the configuration file, I'm so blockhead!

Anyway I transfered every class of the server mod to the client mod, loading the connection on the server connection, but I still have the problem "A mod tried to open a gui in a server without being a network mod", I also changed the "serverSideRequired" to true, but no fix.

 

 

Oh god I think it's the customnpcs mod....

Link to comment
Share on other sites

If your KeyHandler really is the the only place where you call openGui that message is impossible to get. But you will not be able to use Guis that have a Container with that method. You have to call openGui on the server for that, KeyHandlers only exist on the client though. You will need to send packets.

 

Still doesn't work, why?

 

GuiHandler:

@Override
public void keyDown(EnumSet<TickType> types, KeyBinding kb,
boolean tickEnd, boolean isRepeat) {
this.isKeyDown = true;
EntityPlayer player = (EntityPlayer) this.mc.thePlayer;
World world = (World) this.mc.theWorld;
int x = (int) player.posX;
int y = (int) player.posY;
int z = (int) player.posZ;
if (kb.keyCode == this.openCharacter.keyCode) {
	this.phMethods.openGui(player);
}
}

 

PacketHandler:

public class ExoPacketHandler implements IPacketHandler {

public static final String OPENGUI = "OPENGUI";

@Override
public void onPacketData(INetworkManager manager,
		Packet250CustomPayload packet, Player player) {

	if (packet.channel.equals(ExoPacketHandler.OPENGUI)) {
		this.openCharacterGui(packet, (EntityPlayer) player);
	}
}

private void openCharacterGui(Packet250CustomPayload packet, EntityPlayer player) {
	DataInputStream inputStream = new DataInputStream(
			new ByteArrayInputStream(packet.data));

	player.openGui(ExoWorld_Client.modid, GuiRegistry.guiCharacter,
			player.worldObj, (int) player.posX, (int) player.posY,
			(int) player.posZ);
}
}

 

The method that sends the packet:

public void openGui(EntityPlayer entityPlayer) {
Random random = new Random();
        int randomInt1 = random.nextInt();
        int randomInt2 = random.nextInt();
        
        ByteArrayOutputStream bos = new ByteArrayOutputStream(;
        DataOutputStream outputStream = new DataOutputStream(bos);
        try {
                outputStream.writeInt(randomInt1);
                outputStream.writeInt(randomInt2);
        } catch (Exception ex) {
                ex.printStackTrace();
        }
        
        Packet250CustomPayload packet = new Packet250CustomPayload();
        packet.channel = ExoPacketHandler.OPENGUI;
        packet.data = bos.toByteArray();
        packet.length = bos.size();
        
        Side side = FMLCommonHandler.instance().getEffectiveSide();
        if (side == Side.SERVER) {
                // We are on the server side.
                EntityPlayerMP entityPlayerMP = (EntityPlayerMP) entityPlayer;
        } else if (side == Side.CLIENT) {
                // We are on the client side.
                EntityClientPlayerMP entityClientPlayerMP = (EntityClientPlayerMP) entityPlayer;
                entityClientPlayerMP.sendQueue.addToSendQueue(packet);
        } else {
                // We are on the Bukkit server.
        }
}

 

@NetworkMod():

@NetworkMod(clientSideRequired = true, serverSideRequired = true, channels = { ExoPacketHandler.OPENGUI }, packetHandler = ExoPacketHandler.class)

Link to comment
Share on other sites

You pass in your ModId as the instance to openGui. You need to pass the actual instance though.

And why on earth are you sending random ints and then never use them? And your channel name is not very unique. Remember it has to be unique over all mods.

Ah yeah sorry, I didn't notice "modid", and for the randomInt I didn't remove them because I get the packet handler from the tutorial on the wiki and didn't notice them, for the channel name ok, I'll try with OPENGUICHARACTER

Link to comment
Share on other sites

UPDATE:

Now it doesn't open...no crash, no errors, the packet is called (I put a "print" method to check if the method is called and it works) but now it doesn't open...I also modified a bit the gui handler:

 

PacketHandler Method:

private void openCharacterGui(Packet250CustomPayload packet,
		EntityPlayer player) {
	DataInputStream inputStream = new DataInputStream(
			new ByteArrayInputStream(packet.data));
	player.openGui(ExoWorld_Client.instance, GuiRegistry.guiCharacter,
			Minecraft.getMinecraft().theWorld, (int) player.posX, (int) player.posY,
			(int) player.posZ);
	Log.log("Gui Aperto");
}

 

New GuiHandler:

public class ExoGuiHandler implements IGuiHandler {

public Object getServerGuiElement(int ID, EntityPlayer player, World world,
		int x, int y, int z) {
	TileEntity entity = world.getBlockTileEntity(x, y, z);
	if (entity != null) { // detecta si hay una entidad
		switch (ID) {
		case GuiRegistry.guiCharacter:
			if (entity instanceof TileEntityCharacter) {
				return new ContainerCharacter(player.inventory,
						(TileEntityCharacter) entity);
			}
		}
	}
	return null;
}

public Object getClientGuiElement(int ID, EntityPlayer player, World world,
		int x, int y, int z) {
	TileEntity entity = world.getBlockTileEntity(x, y, z);
	if (entity != null) {
		switch (ID) {
		case GuiRegistry.guiCharacter:
			if (entity instanceof TileEntityCharacter) {
				return new GuiCharacter(player.inventory,
						(TileEntityCharacter) entity);
			}
		}
	}
	return null;
}
}

Link to comment
Share on other sites

player.openGui(ExoWorld_Client.instance, GuiRegistry.guiCharacter,
			Minecraft.getMinecraft().theWorld, (int) player.posX, (int) player.posY,
			(int) player.posZ);

 

...You know the player has a worldObj right?

 

Not to mention that that function makes no frakking sense.  It takes in a packet, then it turns the packet into an input stream, and then does nothing with it.

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

player.openGui(ExoWorld_Client.instance, GuiRegistry.guiCharacter,
			Minecraft.getMinecraft().theWorld, (int) player.posX, (int) player.posY,
			(int) player.posZ);

 

...You know the player has a worldObj right?

 

Not to mention that that function makes no frakking sense.  It takes in a packet, then it turns the packet into an input stream, and then does nothing with it.

 

I already done with player.worldObj but still not opening the gui, I tried with this method that I hate so much, still nothin'

Link to comment
Share on other sites

player.openGui(ExoWorld_Client.instance, GuiRegistry.guiCharacter,
			Minecraft.getMinecraft().theWorld, (int) player.posX, (int) player.posY,
			(int) player.posZ);

public Object getServerGuiElement(int ID, EntityPlayer player, World world,
		int x, int y, int z) {
	TileEntity entity = world.getBlockTileEntity(x, y, z);
	if (entity != null) {

You are trying to find a TileEntity where the player is located. That is rather unlikely.

You need to give the correct TileEntity coordinates to the "openGui" method.

Link to comment
Share on other sites

player.openGui(ExoWorld_Client.instance, GuiRegistry.guiCharacter,
			Minecraft.getMinecraft().theWorld, (int) player.posX, (int) player.posY,
			(int) player.posZ);

public Object getServerGuiElement(int ID, EntityPlayer player, World world,
		int x, int y, int z) {
	TileEntity entity = world.getBlockTileEntity(x, y, z);
	if (entity != null) {

You are trying to find a TileEntity where the player is located. That is rather unlikely.

You need to give the correct TileEntity coordinates to the "openGui" method.

 

I can't figure out how to do that, I tried MatHelper.floor_double(); but doesn't work....

Link to comment
Share on other sites

floor, ceiling, round...none of those are going to locate a tile entity that encases the player's feet.

You should get the location of the tile entity from itself and pass the xyz in the packet.

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

Sorry but I cannot figure out, canyou write me the code? I tried with "TileEntity tileEntity = new TileEntityCharacter()"'s xCoord, yCoord and zCoord or creating the tileentity in the packet handler then calling the coordinates.

Can you write me the code?

Link to comment
Share on other sites

new TileEntityCharacter()

 

...Really.  A new tile entity.  No no no no.

 

You have a tile entity somewhere that is involved.  Generally when the player right clicks it is when you open a gui for it.  That method is inside a tile entity and has reference to itself.

 

Unfortunately with the code you have supplied I'm not sure you even HAVE a tile entity anywhere.  So I don't know why you're trying to reference it at all.

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

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.



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • https://mclo.gs/4UC49Ao
    • Way back in the Forge 1.17 days, work started for adding JPMS (Java Platform Module Support) to ModLauncher and ForgeModLoader. This has been used internally by Forge and some libraries for a while now, but mods (those with mods.toml specifically) have not been able to take advantage of it. As of Forge 1.21.1 and 1.21.3, this is now possible!   What is JPMS and what does it mean for modders? JPMS is the Java Platform Module System, introduced in Java 9. It allows you to define modules, which are collections of packages and resources that can be exported or hidden from other modules. This allows for much more fine-tuned control over visibility, cleaner syntax for service declarations and support for sealed types across packages. For example, you might have a mod with a module called `com.example.mod` that exports `com.example.mod.api` and `com.example.mod.impl` to other mods, but hides `com.example.mod.internal` from them. This would allow you to have a clean API for other mods to use, while keeping your internal implementation details hidden from IDE hints, helping prevent accidental usage of internals that might break without prior notice. This is particularly useful if you'd like to use public records with module-private constructors or partially module-private record components, as you can create a sealed interface that only your record implements, having the interface be exported and the record hidden. It's also nice for declaring and using services, as you'll get compile-time errors from the Java compiler for typos and the like, rather than deferring to runtime errors. In more advanced cases, you can also have public methods that are only accessible to specific other modules -- handy if you want internal interactions between multiple of your own mods.   How do I bypass it? We understand there may be drama in implementing a system that prevents mods from accessing each other's internals when necessary (like when a mod is abandoned or you need to fix a compat issue) -- after all, we are already modding a game that doesn't have explicit support for Java mods yet. We have already thought of this and are offering APIs from day one to selectively bypass module restrictions. Let me be clear: Forge mods are not required to use JPMS. If you don't want to use it, you don't have to. The default behaviour is to have fully open, fully exported automatic modules. In Java, you can use the `Add-Opens` and `Add-Exports` manifest attributes to selectively bypass module restrictions of other mods at launch time, and we've added explicit support for these when loading your Forge mods. At compile-time, you can use existing solutions such as the extra-java-module-info Gradle plugin to deal with non-modular dependencies and add extra opens and exports to other modules. Here's an example on how to make the internal package `com.example.examplemod.internal` open to your mod in your build.gradle: tasks.named('jar', Jar) { manifest { attributes([ 'Add-Opens' : 'com.example.examplemod/com.example.examplemod.internal' 'Specification-Title' : mod_id, 'Specification-Vendor' : mod_authors // (...) ]) } } With the above in your mod's jar manifest, you can now reflectively access the classes inside that internal package. Multiple entries are separated with a space, as per Java's official spec. You can also use Add-Exports to directly call without reflection, however you'd need to use the Gradle plugin mentioned earlier to be able to compile. The syntax for Add-Exports is the same as Add-Opens, and instructions for the compile-time step with the Gradle plugin are detailed later in this post. Remember to prefer the opens and exports keywords inside module-info.java for sources you control. The Add-Opens/Add-Exports attributes are only intended for forcing open other mods.   What else is new with module support? Previously, the runtime module name was always forced to the first mod ID in your `mods.toml` file and all packages were forced fully open and exported. Module names are now distinguished from mod IDs, meaning the module name in your module-info.java can be different from the mod ID in your `mods.toml`. This allows you to have a more descriptive module name that doesn't have to be the same as your mod ID, however we strongly recommend including your mod ID as part of your module name to aid troubleshooting. The `Automatic-Module-Name` manifest attribute is now also honoured, allowing you to specify a module name for your mod without needing to create a `module-info.java` file. This is particularly useful for mods that don't care about JPMS features but want to have a more descriptive module name and easier integration with other mods that do use JPMS.   How do I use it? The first step is to create a `module-info.java` file in your mod's source directory. This file should be in the same package as your main mod class, and should look something like this: open module com.example.examplemod { requires net.minecraftforge.eventbus; requires net.minecraftforge.fmlcore; requires net.minecraftforge.forge; requires net.minecraftforge.javafmlmod; requires net.minecraftforge.mergetool.api; requires org.slf4j; requires logging; } For now, we're leaving the whole module open to reflection, which is a good starting point. When we know we want to close something off, we can remove the open modifier from the module and open or export individual packages instead. Remember that you need to be open to Forge (module name net.minecraftforge.forge), otherwise it can't call your mod's constructor. Next is fixing modules in Gradle. While Forge and Java support modules properly, Gradle does not put automatic modules on the module path by default, meaning that the logging module (from com.mojang:logging) is not found. To fix this, add the Gradle plugin and add a compile-time module definition for that Mojang library: plugins { // (...) id 'org.gradlex.extra-java-module-info' version "1.9" } // (...) extraJavaModuleInfo { failOnMissingModuleInfo = false automaticModule("com.mojang:logging", "logging") } The automatic module override specified in your build.gradle should match the runtime one to avoid errors. You can do the same for any library or mod dependency that is missing either a module-info or explicit Automatic-Module-Name, however be aware that you may need to update your mod once said library adds one. That's all you need to get started with module support in your mods. You can learn more about modules and how to use them at dev.java.
    • Faire la mise à jour grâce à ce lien m'a aider personnellement, merci à @Paint_Ninja. https://www.amd.com/en/support 
    • When I came across the 'Exit Code: I got a 1 error in my Minecraft mods, so I decided to figure out what was wrong. First, I took a look at the logs. In the mods folder (usually where you'd find logs or crash reports), I found the latest.log file or the corresponding crash report. I read it through carefully, looking for any lines with errors or warnings. Then I checked the Minecraft Forge support site, where you can often find info on what causes errors and how to fix them. I then disabled half of my mods and tried running the game. If the error disappeared, it meant that the problem was with the disabled mod. I repeated this several times to find the problem mod.
    • I have no idea - switch to a pre-configured modpack and use it as working base    
  • Topics

×
×
  • Create New...

Important Information

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