27 juil. 2016, 22:54

@‘robin4002’:

0 = normal
1 = flèche de feu
2 = autre truc
etc …

Ok^^

J’ai fais ça:


package net.legacymod.packets;

import io.netty.buffer.ByteBuf;
import net.legacymod.LegacyMod;
import net.legacymod.gui.ClassesGUI;
import net.minecraft.client.Minecraft;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;

public class PacketKey implements IMessage {

public PacketKey(){

}

@Override
public void fromBytes(ByteBuf buf) {

}

@Override
public void toBytes(ByteBuf buf) {

}

public static class Handler implements IMessageHandler <packetkey, imessage="">{

   public IMessage onMessage(PacketKey message, MessageContext ctx) {

    ItemStack stack = ctx.getServerHandler().playerEntity.inventory.getItemStack();
    if(stack != null){
    stack.setTagCompound(new NBTTagCompound());
    NBTTagCompound nbt = (NBTTagCompound) stack.getTagCompound();
    stack.getTagCompound().setInteger("key", 3);
    System.out.println("packet");
    }
    return null;

       }
   }
}

Arc:


           else if (!world.isRemote && stack.getTagCompound().getInteger("key") == 3)
           {
            LegacyMod.network.sendToServer(new PacketArrow(f * 2.0F, 3));
            System.out.println("flèche en feu");
            //stack.getTagCompound().setInteger("timer2", 0);
           }

console:


[00:54:44] [Server thread/INFO]: floriangabet a rejoint la partie
[00:54:45] [Client thread/INFO] [STDOUT]: [net.legacymod.proxy.ClientProxy:keyTestTyped2:91]: num pad 6
[00:54:47] [Server thread/INFO] [STDOUT]: [net.legacymod.items.FlameBow:onPlayerStoppedUsing:142]: flèche normale

Marche pas.</packetkey,>