godbaba
Members-
Posts
69 -
Joined
-
Last visited
Everything posted by godbaba
-
Easier way setItemDamage(0) in onArmorUpdate(){} event
-
Ohhh Thanks for the explanation
-
It is quite interesting I solved problem but it is weird... if(data.readInt() == 2002) is not working... int id = data.readInt(); if(id ==2002) is working... Weird but it is working
-
And I just realised that I am getting this exception when I try to data.readInt() java.io.EOFException 2013-08-04 00:15:05 [iNFO] [sTDERR] at java.io.DataInputStream.readInt(Unknown Source) 2013-08-04 00:15:05 [iNFO] [sTDERR] at netherfors.misc.PacketReadStream.readInt(PacketReadStream.java:53) 2013-08-04 00:15:05 [iNFO] [sTDERR] at netherfors.ServerModPacketHandler.onPacketData(ServerModPacketHandler.java:28) 2013-08-04 00:15:05 [iNFO] [sTDERR] at cpw.mods.fml.common.network.NetworkRegistry.handlePacket(NetworkRegistry.java:255) 2013-08-04 00:15:05 [iNFO] [sTDERR] at cpw.mods.fml.common.network.NetworkRegistry.handleCustomPacket(NetworkRegistry.java:245) 2013-08-04 00:15:05 [iNFO] [sTDERR] at cpw.mods.fml.common.network.FMLNetworkHandler.handlePacket250Packet(FMLNetworkHandler.java:83) 2013-08-04 00:15:05 [iNFO] [sTDERR] at net.minecraft.network.NetServerHandler.handleCustomPayload(NetServerHandler.java:1098) 2013-08-04 00:15:05 [iNFO] [sTDERR] at net.minecraft.network.packet.Packet250CustomPayload.processPacket(Packet250CustomPayload.java:70) 2013-08-04 00:15:05 [iNFO] [sTDERR] at net.minecraft.network.MemoryConnection.processReadPackets(MemoryConnection.java:89) 2013-08-04 00:15:05 [iNFO] [sTDERR] at net.minecraft.network.NetServerHandler.networkTick(NetServerHandler.java:134) 2013-08-04 00:15:05 [iNFO] [sTDERR] at net.minecraft.network.NetworkListenThread.networkTick(NetworkListenThread.java:53) 2013-08-04 00:15:05 [iNFO] [sTDERR] at net.minecraft.server.integrated.IntegratedServerListenThread.networkTick(IntegratedServerListenThread.java:109) 2013-08-04 00:15:05 [iNFO] [sTDERR] at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:675) 2013-08-04 00:15:05 [iNFO] [sTDERR] at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:571) 2013-08-04 00:15:05 [iNFO] [sTDERR] at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:127) 2013-08-04 00:15:05 [iNFO] [sTDERR] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:469) 2013-08-04 00:15:05 [iNFO] [sTDERR] at net.minecraft.server.ThreadMinecraftServer.run(ThreadMinecraftServer.java:16) And this is how I handle my packets http://www.minecraftforge.net/wiki/Organising_packet_handlers
-
I added this code to the handler : System.out.println("PACKET ARRIVED!"); System.out.println(packet.channel); System.out.println(data.readInt()); And channel is ok , packet is arriving , integer is running but the if statement its not working it looks like ... :?
-
I am still in 1.5.2 and thats in the : @Init public void init(FMLInitializationEvent event){}
-
I can get the packet in single player so yes! IPacketHandler packetServer = new ServerModPacketHandler(); IPacketHandler packetClient = new ClientModPacketHandler(); NetworkRegistry.instance().registerChannel(packetServer, "netherfors", Side.SERVER); NetworkRegistry.instance().registerChannel(packetClient, "netherfors", Side.CLIENT);
-
When I send a packet to the server If I am in the client it does work but in the multiplayer it doesnt work... I send my packet : EntityClientPlayerMP pl = (EntityClientPlayerMP) player; pl.sendQueue.addToSendQueue(stream.makePacket("netherfors")); And my server packet handler : package netherfors; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.network.INetworkManager; import net.minecraft.network.packet.Packet250CustomPayload; import netherfors.misc.PacketReadStream; import cpw.mods.fml.common.network.IPacketHandler; import cpw.mods.fml.common.network.Player; public class ServerModPacketHandler implements IPacketHandler { @Override public void onPacketData(INetworkManager manager, Packet250CustomPayload packet, Player player) { EntityPlayer p = (EntityPlayer) player; if(packet.channel.equals("netherfors")){ PacketReadStream data = new PacketReadStream(packet); if(data.readInt() == 1001){ p.addChatMessage("Done!"); } if(data.readInt() == 2002){ System.out.println("2002"); destroyPhoxNote(p); } } } public void destroyPhoxNote(EntityPlayer player){ player.closeScreen(); player.inventory.decrStackSize(player.inventory.currentItem, 1); player.addChatMessage("You have successfully learned what this Phox Note teaches!"); } } Can anyone help with this ?
-
Hey dude! Thank you for your help I successfully defined the server and the client proxy but here is the deal : With an item I am sending a packet to server with int(1001) When packet handler gets the int(1001) prints a "Done!" It works on singleplayer still but doesnt work on the multiplayer And I am okey with you saying me I am newbie! Because I am a newbie
-
Actually I am using 1 packet handler I dont know how to create sided handlers
-
All nice in the single player No fake items or nothing like that But in multiplayer it acts like it doesnt get the packet...
-
With your classes it looks easy...Can I use these classes in my mod ?
-
You know about packets it looks like Can you give me an example about how to send integers and execute them a fast one Because the packet tutorial on wiki is very complicated
-
Okey thanks for help I will have a look in packets and implement that into my mod! Thanks one more!
-
You cant depent on packets because players easily can exploit them And they are actually complicated
-
God! This topic is going crazy Guys all I am trying to do is giving player items when you click a button but guis are clientsided so i cant do it This is my problem can anyone help ?
-
Dude just check out my mod I detect the items in the players inventory and give the player an item if the player has the needed items But when you add @SideOnly(Side.CLIENT) or IGuiHandler the Gui only gets opened in the client and it prevents you from spawing items etc
-
Dude it spawns one item and it is fake
-
I converted all of my code into IGuiHandler but now world.spawnEntityInWorld() spawns fake items as well Still have the problem...
-
Ohh god ! This was easier...I was using IGuiHandler for only containers but now I should use it for GuiScreens too Thanks for help dude I will try it and tell the result here
-
For example BlockCode: package netherfors.block; import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.src.ModLoader; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Icon; import net.minecraft.world.World; import netherfors.main; import netherfors.gui.GuiLavaCollector; import netherfors.tile.TileLavaCollector; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; public class LavaCollector extends BlockContainer{ private Icon top,bottom; public LavaCollector(int id) { super(id, Material.rock); this.setStepSound(Block.soundStoneFootstep); this.setCreativeTab(main.nettab); this.setHardness(5f); } @SideOnly(Side.CLIENT) public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9) { TileLavaCollector tile = (TileLavaCollector) world.getBlockTileEntity(x, y, z); if(tile!=null){ Minecraft mc = ModLoader.getMinecraftInstance(); mc.displayGuiScreen(new GuiLavaCollector(player,world,tile)); } return true; } public void onBlockClicked(World world, int x, int y, int z, EntityPlayer player) { TileLavaCollector tile = (TileLavaCollector) world.getBlockTileEntity(x, y, z); if(tile!=null){ if(tile.itemamount>0){ EntityItem it = new EntityItem(world, x, y, z, new ItemStack(main.craftingitems,tile.itemamount,0)); if(!world.isRemote){ world.spawnEntityInWorld(it); } tile.itemamount = 0; } } } public void onBlockAdded(World world, int x, int y, int z) { TileLavaCollector t = (TileLavaCollector) world.getBlockTileEntity(x, y, z); if(t!=null){ t.itemamount = 0; t.amount = 0; t.interval = 0; t.time = 0; } } public void registerIcons(IconRegister r){ this.blockIcon = r.registerIcon("netherfors:lavaside"); this.top = r.registerIcon("netherfors:lavatop"); this.bottom = r.registerIcon("netherfors:lavabottom"); } public Icon getIcon(int par1, int par2) { return par1 == 1 ? this.top : (par1 == 0 ? this.bottom : (par1 != par2 ? this.blockIcon : this.blockIcon)); } @Override public TileEntity createNewTileEntity(World world) { return new TileLavaCollector(); } } GuiCode : package netherfors.gui; import net.minecraft.client.gui.GuiScreen; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.world.World; import netherfors.tile.TileLavaCollector; import org.lwjgl.opengl.GL11; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; public class GuiLavaCollector extends GuiScreen{ private int wi,he; private EntityPlayer player; private World world; private TileLavaCollector tile; // 88 // 65 public GuiLavaCollector(EntityPlayer pla,World wor,TileLavaCollector ti){ this.wi = 88; this.he = 90; this.world = wor; this.player = pla; this.tile = ti; } public boolean doesGuiPauseGame() { return false; } public void drawProgressBar(int i){ if(i>65){ i = 65; } GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); this.mc.renderEngine.bindTexture("/mods/netherfors/textures/gui/lavacollector.png");; this.drawTexturedModalRect(width/2-35, (height/2-37)+(65-i), 88, 0, 20, i); } public void progressOverHundred(int o){ if(o>100){ o = 100; } int percent = (65*o)/100; drawProgressBar(percent); } public void initGui(){ } @SideOnly(Side.CLIENT) public void drawScreen(int par1, int par2, float par3) { this.drawGuiContainerBackgroundLayer(par3, par2, par1); int t = tile.amount; progressOverHundred(t); this.fontRenderer.drawSplitString("Progress\n"+Integer.toString(tile.amount)+"%\n\nAmount\n"+Integer.toString(tile.itemamount), width/2-20, height/2-34, 54, 0); super.drawScreen(par1, par2, par3); } @SideOnly(Side.CLIENT) protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); this.mc.renderEngine.bindTexture("/mods/netherfors/textures/gui/lavacollector.png"); int k = (this.width - this.wi) / 2; int l = (this.height - this.he) / 2; this.drawTexturedModalRect(k, l, 0, 0, this.wi, this.he); } } If I dont put sideonly to the onBlockActivated it crashes the server
-
If i dont use it it crashes the server because it attemps to render on server too
-
Hi I have a mod full of Guis and I had a problem with the guis crashing the server as soon as I added @SideOnly(Side.CLIENT) to the onItemRightClick command it fixed the problem but the new problem is that I used to have guibuttons that when you click drops item @SideOnly(Side.CLIENT) annotation brokes them!! What can I do about this ?
-
These are all while player is online... I want to be able to save into player nbt while player is offline...(NOT LOGGED into the server)