Jump to content

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


Recommended Posts

Posted

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!

Posted

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.

Posted

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?

Posted

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"?

Posted

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.

Posted

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.

Posted

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.

Posted

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.

Posted

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.

Posted

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.

Posted

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?

Posted

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.

Posted

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

Posted

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)

Posted

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

Posted

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;
}
}

Posted

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.

Posted

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'

Posted

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.

Posted

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

Posted

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.

Posted

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?

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

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.