J’ai un petit problème, j’utilise
| public static final PacketManager rcModPacketHandler = new PacketManager("fr.lmac.packet", "Fr_mod", "Fr_mod"); |
| ``` mais l'information ne change pas :s |
| Savez vous d'où viens le problème ? |
| ```java |
| public class Fr_mod { |
| |
| @Instance("Fr_mod") |
| public static Fr_mod instance; |
| |
| @SidedProxy(clientSide = "fr.lmac.proxy.ClientProxy", serverSide = "fr.lmac.proxy.CommonProxy") |
| public static CommonProxy proxy; |
| |
| public static final PacketManager rcModPacketHandler = new PacketManager("fr.lmac.packet", "Fr_mod", "Fr_mod"); |
| |
| @EventHandler |
| public void initConfig(FMLPreInitializationEvent event) |
| { |
| } |
| @EventHandler |
| public void load(FMLInitializationEvent event) |
| { |
| FMLCommonHandler.instance().bus().register(new PlayerTracker()); |
| MinecraftForge.EVENT_BUS.register(new PlayerTracker()); |
| } |
| |
| @EventHandler |
| public void afterLoad(FMLPostInitializationEvent event) |
| { |
| } |
| } |
| public class PacketFr extends FFMTPacket |
| { |
| |
| public boolean DoubleJump; |
| |
| public PacketFr(){ |
| |
| } |
| |
| public PacketFr(boolean DoubleJump){ |
| this.DoubleJump = DoubleJump; |
| } |
| |
| @Override |
| public void writeData(ByteBuf buffer) throws IOException { |
| buffer.writeBoolean(DoubleJump); |
| |
| } |
| |
| @Override |
| public void readData(ByteBuf buffer) { |
| this.DoubleJump = buffer.readBoolean(); |
| |
| } |
| |
| @Override |
| public void handleClientSide(EntityPlayer player) { |
| ExtendedEntityPropFr props = ExtendedEntityPropFr |
| .get(player); |
| props.DoubleJump = this.DoubleJump; |
| } |
| |
| @Override |
| public void handleServerSide(EntityPlayer player) { |
| ExtendedEntityPropFr props = ExtendedEntityPropFr |
| .get(player); |
| props.DoubleJump = this.DoubleJump; |
| } |
| |
| } |
| |
| public class ExtendedEntityPropFr implements IExtendedEntityProperties { |
| |
| public final static String EXT_PROP_NAME = "ExtPropFr"; |
| |
| private final EntityPlayer player; |
| |
| public boolean DoubleJump; |
| |
| public ExtendedEntityPropFr(EntityPlayer player) { |
| this.player = player; |
| this.DoubleJump = false; |
| |
| } |
| |
| @Override |
| public void saveNBTData(NBTTagCompound compound) { |
| |
| NBTTagCompound properties = new NBTTagCompound(); |
| |
| properties.setBoolean("DoubleJump", this.DoubleJump); |
| |
| compound.setTag(EXT_PROP_NAME, properties); |
| |
| } |
| |
| @Override |
| public void loadNBTData(NBTTagCompound compound) { |
| NBTTagCompound properties = (NBTTagCompound) compound.getTag(EXT_PROP_NAME); |
| this.DoubleJump = properties.getBoolean("DoubleJump"); |
| |
| } |
| |
| @Override |
| public void init(Entity entity, World world) { |
| |
| |
| } |
| |
| public static final void register(EntityPlayer player) { |
| player.registerExtendedProperties(ExtendedEntityPropFr.EXT_PROP_NAME, |
| new ExtendedEntityPropFr(player)); |
| } |
| |
| public static final ExtendedEntityPropFr get(EntityPlayer player) { |
| return (ExtendedEntityPropFr) player.getExtendedProperties(EXT_PROP_NAME); |
| } |
| |
| public final void sync() { |
| PacketFr packetFr = new PacketFr(this.DoubleJump); |
| Fr_mod.rcModPacketHandler.sendToServer(packetFr); |
| |
| if (!player.worldObj.isRemote) { |
| EntityPlayerMP player1 = (EntityPlayerMP) player; |
| |
| Fr_mod.rcModPacketHandler.sendTo(packetFr, player1); |
| |
| } |
| } |
| private static String getSaveKey(EntityPlayer player) { |
| return player.getDisplayName() + ":" + EXT_PROP_NAME; |
| } |
| |
| public static void saveProxyData(EntityPlayer player) { |
| ExtendedEntityPropFr playerData = ExtendedEntityPropFr.get(player); |
| NBTTagCompound savedData = new NBTTagCompound(); |
| |
| playerData.saveNBTData(savedData); |
| CommonProxy.storeEntityData(getSaveKey(player), savedData); |
| } |
| |
| public static void loadProxyData(EntityPlayer player) { |
| ExtendedEntityPropFr playerData = ExtendedEntityPropFr .get(player); |
| NBTTagCompound savedData = CommonProxy.getEntityData(getSaveKey(player)); |
| |
| if (savedData != null) { |
| playerData.loadNBTData(savedData); |
| } |
| playerData.sync(); |
| } |
| |
| public boolean getDoubleJump() { |
| return this.DoubleJump; |
| } |
| |
| public void setDoubleJump(boolean newDoubleJump) { |
| this.DoubleJump = newDoubleJump; |
| this.sync(); |
| } |
| |
| } |
| |
| @SideOnly(Side.CLIENT) |
| int timer; |
| boolean jumpLast = false; |
| @SideOnly(Side.CLIENT) |
| @SubscribeEvent |
| public void onTickPlayer(TickEvent.PlayerTickEvent event) |
| { |
| if(event.player.getCommandSenderName() == Minecraft.getMinecraft().thePlayer.getCommandSenderName()) |
| { |
| EntityPlayerSP player = Minecraft.getMinecraft().thePlayer; |
| |
| ExtendedEntityPropFr prop = new ExtendedEntityPropFr(player); |
| |
| if(player.worldObj.getGameRules().getGameRuleBooleanValue("enableRing")){ |
| |
| if(player.movementInput.jump) |
| { |
| if(!jumpLast) |
| { |
| jumpLast = true; |
| } |
| else if(timer > 2) |
| { |
| prop.setDoubleJump(true); |
| jumpLast = false; |
| |
| } |
| timer = 0; |
| } |
| else{ |
| prop.setDoubleJump(false); |
| } |
| |
| if(jumpLast) |
| { |
| timer ++; |
| if(timer > 20) |
| { |
| jumpLast = false; |
| timer = 0; |
| } |
| } |
| |
| } |
| } |
| } |
Normalement c’est bon sauf si je me suis encore gourré