Jump to content

imadnsn

Members
  • Posts

    186
  • Joined

  • Last visited

Posts posted by imadnsn

  1. Can't you just play sound from file rather than copying it, you might if you did what diesieben07.

    Also you can let the player register the records using configs, and make changes inside the game only take effect after restart. Although this might not be necessary and a workaround might be there.

  2. And also, I have an IExtendedEntityProperties with both save and load nbtdata. But these fonctions are never called. THe class itself is registered and works perfectly. But at no point the save and load functions are called. (PS: I followed step by step this (http://www.minecraftforum.net/forums/mapping-and-modding/mapping-and-modding-tutorials/1571567-1-7-2-1-6-4-eventhandler-and)

     

    Did you make the EntityConstructing event handler and register it correctly? Save and load nbt are automatically called when saving and loading world (are you sure those methods are overrides?)

     

    Also, for the network stuff I recommend using SimpleNetworkWrapper and IMessage, its tutorial is in those forums

    http://www.minecraftforge.net/forum/index.php/topic,20138.0.html

    http://www.minecraftforge.net/forum/index.php/topic,20135.0.html

  3. Thanks for your post, well you've got what I was thinking.

    I actually deliberately didn't send all the info I will need on the same packet, only the ones that change regularly, I'm planning to make different packets that send whenever values change.

     

    A player level won't change every 10 ticks, and it wouldn't make sense to send them with the health or hunger, for instance.

  4. That would be worse, because then I'd send two packets every few ticks when rendering Gui.

    Also keeping it server-sided is better because I can use the data on different things update the data regularly instead of every time something needs it.

     

    But that's not my problem anyway, all I want to know is how and when packet sending might make the game a bit laggy especially on multiplayer, so I can avoid overusing it whenever I can.

  5. There are a few properties I wanted to synchronize between my server and client by sending packets from server whenever the properties change. The issue was that those properties changed every tick, so I made them change only twice a second which is the best pace I found for what I'm doing.

     

    My question is, what is the rate of sending packets per seconds generally that should worry me when implemented? Taking in account for other packets being sent by the mod or other mods regularly.

  6. You can do this in eclipse by going to:

    Run > Run Configurations/Debug Configurations > Select client > Arguments

    add this line in the program arguments:

    --username (username) -password (password)

     

    Do this to both clients or whatever you want (one is for normal run, the other is for debug run)

     

     

  7. damage is a positive number that increases with each use until maxDamage is reached.

     

    P.S.: you should really start renaming your variables to make them more readable for other people and for you in the future, you'll appreciate that later on, An easy way in eclipse is pointing on variable the pressing CTRL + 2 then R then rename to whatever

  8. import mod file to referenced libraries.

    Right click project folder in eclipse's Project Explorer (usually called "Minecraft") then select Properties > Java Build Path > Libraries > Add External JARs then select the .jar or .zip file of the mod.

    You can remove them later in the same place by selecting libraries and clicking remove.

  9. I'm guessing this is a bug, because whenever I send an empty message (with no value in them) then reply an exception is thrown at the reply message.

    The exception, which is IndexOutOfRangeException, is thrown when it wants to read the reply message, so I'm guessing it is not resetting the reading index at the reply and it goes out of range when trying to read the data.

  10. Ok, I first should note that the message itself is supposed to do nothing but reply another message from client containing requested data, thus why it is called EmptyMessage, but I wrote an integer to the buffer to prevent IndexOutOfRangeException.

     

    The class:

    public class EmptyMessage implements IMessage {
    
    public EmptyMessage() {	}
    
    @Override
    public void fromBytes(ByteBuf buf) {
    	buf.readInt();
    }
    
    @Override
    public void toBytes(ByteBuf buf) {
    	buf.writeInt(1);		
    }
    }

     

    It is handled by this handler but I know it doesn't reach this code since I tried writing to output to no avail.

     

    The handler:

    public class EmptyMessagePlayerDataHandler implements IMessageHandler<EmptyMessage, PlayerDataMessage> {
    
    @Override
    public PlayerDataMessage onMessage(EmptyMessage message,
    		MessageContext ctx) {
    	return PlayerDataMessage.fromMinecraft(Minecraft.getMinecraft()); // This is in client
    }
    }

     

    This is the way it is sent:

    EmptyMessage message = new EmptyMessage();
    Magematica.network.sendTo(message, (EntityPlayerMP) player); // On server side

     

    This is the line in preInit:

    network.registerMessage(EmptyMessagePlayerDataHandler .class, EmptyMessage.class, 2, Side.CLIENT);

  11. I am trying to send a packet from server to player using an IMessage and SimpleNetworkWrapper, however, whenever it tries to send the packet it gives me this exception:

     

    `io.netty.handler.codec.DecoderException: java.lang.IndexOutOfBoundsException: readerIndex(8 ) + length(4) exceeds writerIndex(8 ): SlicedByteBuf(ridx: 8, widx: 8, cap: 8/8, unwrapped: UnpooledHeapByteBuf(ridx: 1, widx: 9, cap: 9/9))`

     

    Does anybody know how would this exception raise for a simple packet send to player?

×
×
  • Create New...

Important Information

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