Jump to content

GotoLink

Members
  • Posts

    2012
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by GotoLink

  1. Feeling really stupid right now. Channels strings have to be compared with String.equals(Object) since they can't be the same object. *solved*
  2. Single player: [sTDOUT] yes i have send the packet [iNFO] [ForgeModLoader] SERVER recieved a Gui packet [iNFO] [ForgeModLoader] CLIENT recieved a Animator packet Multi: [iNFO] [ForgeModLoader] SERVER recieved a Gui packet Server not sending packet, as I said. Oh, and there isn't any exception thrown due to bad data.
  3. You are cancelling the event, no wonder nothing happens. if (event.isCancelable()) { event.setCanceled(true); }
  4. Debug says "SERVER received gui packet", even on multiplayer. But I only have "CLIENT received animator packet" on single player. That is the whole issue, as my title says, server don't send the packet to the player on multiplayer.
  5. Well same results for all PacketDispatcher methods... Ok some news: one packet is sent on player login and one when the block is placed. It isn't sent after gui change.
  6. @NetworkMod(clientSideRequired = true, serverSideRequired = false , channels={"Gui","Animator"}, packetHandler = PacketHandler.class) public static final String[] PACKET_CHANNELS = {"Gui","Animator"}; While reading your tutorial, I came across PacketDispatcher class. Trying the methods in it right now.
  7. Nope, the description packet given by getPacket(TileEntityAnimator) has channel 1 and the receiving part handleDescriptionPacket is also waiting for channel 1. It wouldn't work on single player if I made that mistake.
  8. I tried to fix with the commented part, but result is the same. In my tile entity, i have @Override public Packet getDescriptionPacket() { return PacketHandler.getPacket(this); } So with player.worldObj.markBlockForUpdate(data[1], data[2], data[3]); the description packet is sent. But only on single player...
  9. With your new example: event.manager.soundPoolStreaming.addSound("customsound:Ao1.ogg");
  10. I have been struggling with this issue for the past few days. I made an universal packet handler on my network mod, which handles changes to a tileentity induced by a player from a gui. public class PacketHandler implements IPacketHandler{ @Override public void onPacketData(INetworkManager manager, Packet250CustomPayload packet, Player player) { if(packet.channel == GeneralRef.PACKET_CHANNELS[0]) {//Sent by AnimatorGUI to server when a button has been activated handleGuiChange(manager, packet,(EntityPlayer) player); } else if(packet.channel == GeneralRef.PACKET_CHANNELS[1]) {//Sent by server to client FIXME: packet isn't received on multiplayer ?? handleDescriptionPacket(packet,(EntityPlayer) player); } //DEBUG: Side side = ((EntityPlayer)player).worldObj.isRemote?Side.CLIENT:Side.SERVER; FMLLog.getLogger().info(side.toString()+" recieved a "+packet.channel +" packet"); } /** * Client method to handle a packet describing the TileEntityAnimator from server * @param packet * @param player */ private static void handleDescriptionPacket(Packet250CustomPayload packet, EntityPlayer player) { DataInputStream dat = new DataInputStream(new ByteArrayInputStream(packet.data)); try{ int x = dat.readInt(); int y = dat.readInt(); int z = dat.readInt(); TileEntity te = player.worldObj.getBlockTileEntity(x, y, z); if (te instanceof TileEntityAnimator) { TileEntityAnimator animator = (TileEntityAnimator) te; animator.setEditing(dat.readBoolean()); if(!animator.isEditing() && animator.getStackInSlot(0)!=null) resetRemote(animator.getStackInSlot(0)); animator.setFrame(dat.readInt()); animator.setMaxFrame(dat.readInt()); animator.setCount(dat.readInt()); animator.resetDelay(); animator.setDelay(dat.readInt()); animator.setMode(Mode.values()[dat.readShort()]); } }catch(IOException i) { i.printStackTrace(); } } /** * Server method to handle a client action in AnimatorGUI * @param manager * @param packet * @param player */ private static void handleGuiChange(INetworkManager manager, Packet250CustomPayload packet, EntityPlayer player) { DataInputStream inStream = new DataInputStream(new ByteArrayInputStream(packet.data)); int[] data = new int[packet.data.length/4]; try { for(int id = 0; id < data.length; id++) data[id] = inStream.readInt(); } catch (IOException e) { e.printStackTrace(); return; } TileEntity tile = player.worldObj.getBlockTileEntity(data[1], data[2], data[3]); if(tile instanceof TileEntityAnimator) { handleData((TileEntityAnimator) tile, data); if(player.openContainer instanceof ContainerAnimator && ((ContainerAnimator)player.openContainer).getControl() == tile) player.openContainer.detectAndSendChanges(); //manager.addToSendQueue(getPacket((TileEntityAnimator) tile)); player.worldObj.markBlockForUpdate(data[1], data[2], data[3]); } } public static void handleData(TileEntityAnimator animator, int... data) { switch(data[0]) { case 0://"+" button has been pressed animator.setDelay(1); break; case 1://"-" button has been pressed if(animator.getDelay()>-1) {//Lower delay won't work and might crash animator.setDelay(-1); } break; case 2://"Switch button has been pressed, going LOOP->ORDER->REVERSE->RANDOM->LOOP int mod = animator.getMode().ordinal(); if(mod + 1 < Mode.values().length) animator.setMode(Mode.values()[mod + 1]); else animator.setMode(Mode.LOOP); break; case 3: case 4://One of the "Reset" button has been pressed animator.setEditing(false); animator.setLinker(null); if(data[0]==4)//This is a full reset { resetAnimator(animator); } if(data.length > 4)//Get the item and reset it resetRemote(animator.getStackInSlot(0)); break; case 5://Increment Max number of frames that will run animator.setMaxFrame(animator.getMaxFrame() + 1); break; case 6://Increment first frame to display animator.setFrame(animator.getFrame() + 1); break; } } public static void resetAnimator(TileEntityAnimator animator) { animator.setFrame(0); animator.setMode(Mode.ORDER); animator.resetDelay(); animator.setMaxFrame(-1); animator.setCount(0); } public static void resetRemote(ItemStack stack) { ItemBase remote = (ItemBase)stack.getItem(); remote.resetLinker(); stack.getTagCompound().removeTag(ItemBase.KEYTAG); } public static Packet getPacket(TileEntityAnimator animator) { ByteArrayOutputStream bos = new ByteArrayOutputStream(31); DataOutputStream dos = new DataOutputStream(bos); try { dos.writeInt(animator.xCoord); dos.writeInt(animator.yCoord); dos.writeInt(animator.zCoord); dos.writeBoolean(animator.isEditing()); dos.writeInt(animator.getFrame()); dos.writeInt(animator.getMaxFrame()); dos.writeInt(animator.getCount()); dos.writeInt(animator.getDelay()); dos.writeShort(animator.getMode().ordinal()); } catch (IOException e) { e.printStackTrace(); } Packet250CustomPayload pkt = new Packet250CustomPayload(); pkt.channel = GeneralRef.PACKET_CHANNELS[1]; pkt.data = bos.toByteArray(); pkt.length = bos.size(); pkt.isChunkDataPacket = true; return pkt; } } While it works on single player, with values being changed and gui following it ("SERVER received a Gui packet","CLIENT received description packet") it doesn't on multiplayer with mcp test server ("SERVER received a Gui packet",*nothing follows*) Hopefully someone will found where I derped Edit: This is on 1.5.2 and Forge 7.8.1.737 by the way.
  11. Light value code seems right. Block with meta=0 should give light like torch, while others don't. Note that this parameter doesn't have anything to do with how your texture look. (except that without any light, anything looks dark obviously) Can you show us how you set your textures ?
  12. Well it is not hard to look at ItemSword, is it ?
  13. Well you can make new ItemArmor and new ItemTool, or new ItemPickaxe, ItemAxe... register them with GameRegistry.registerItem(instance, name) If you want to add a new tool material, you can use EnumHelper.addToolMaterial(args) you can also use EnumHelper.addArmorMaterial(args)...
  14. That is because the string is truncated before the ".". It is reserved for removing the file extension, don't use it.
  15. No, my code sets .minecraft/mods/(assets/modid/records/myfile.ogg)jarred/or zipped. Did you even try it ?
  16. Well look at BlockFurnace. Mojang use two block ids. You could use ISimpleBlockRenderingHandler to do render passes accordingly to a tile entity.
  17. Put in assets/modid/(path of choice here, records/myfile.ogg for your example) then use addSound("modid:/records/myfile.ogg")
  18. Use \u00a7 if you want to use it as a string.
  19. Probably the poles are providing power to each other in an infinite loop... I think you should "notifyBlockOfNeighbourChange(args)" in your onBlockAdded and onNeighborBlockChange, that should eventually get rid of the issue.
  20. There are lots of threads with "textures" on the title...maybe they are related ? Anyway, you didn't give your code nor textures path, so by pure guess: try with lower case ?
  21. On 1.6.2, getDamageVsEntity(entity) do not exist anymore. This is replaced with Attribute, modifiers and such.
  22. It could be that the item #thingy is wrong and the id is the one you set. Or you were using another id previously, and it didn't make the change. You are only giving us the most uninteresting part of your code anyway.
  23. Well this: Minecraft.getMinecraft(); Means your on the client side. Always. It is a field in your object or called in its constructor ? Your object is client side. Thus do not build your object nor call one of its methods on server side. How to check which side you are on is left as an exercise.
  24. That is the point, you shouldn't copy or use MC way of handling 2inputs, since they don't support. You have to handle it yourself. As hydroflame suggested, you may want to make a unique map for both inputs, with the keys being an array, or list, of ItemStacks (or another custom Object containing them). Hope that helped
×
×
  • Create New...

Important Information

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