Jump to content

Recommended Posts

Posted

So i'm trying to synchronise these arrays between the client and server, except i cant even get an int to sync using packets (must be packets, not datawatcher). Here's my packet class :

 

(Seriously, is there a problem with macs and that damn code button?)

 

package mine.packethandling;

 

import cpw.mods.fml.common.FMLCommonHandler;

import cpw.mods.fml.common.FMLLog;

import mine.player.PlayerSkills;

import mine.player.PlayerSkills.Skill;

import mine.util.Me;

import io.netty.buffer.ByteBuf;

import io.netty.channel.ChannelHandlerContext;

import net.minecraft.entity.player.EntityPlayer;

 

public class PacketSyncProps extends AbstractPacket {

 

int times;

public PacketSyncProps(){}

 

public PacketSyncProps(int times)

{

Me.log(this.getClass(),"When created, times = " + times);

this.times = times;

}

 

 

@Override

public void encodeInto(ChannelHandlerContext ctx, ByteBuf buffer) {

 

}

 

@Override

public void decodeInto(ChannelHandlerContext ctx, ByteBuf buffer) {

 

}

 

@Override

public void handleClientSide(EntityPlayer player)

{

Me.log(this.getClass(), "Client side syncing player with sent data");

Me.log(this.getClass(), "Existing data : Times : " + this.times);

}

 

@Override

public void handleServerSide(EntityPlayer player)

{

Me.log(this.getClass(), "Why was this sent to server?");

Me.log(this.getClass(), "Fish level pre death " + PlayerStats(player).getSkill(Skill.ONE));

PlayerStats(player).incrementSkill(Skill.ONE, player);

 

}

 

}

 

And that packet is created server-side with :

Me.packetPipeline.sendTo(new PacketSyncProps(12), (EntityPlayerMP) player);

 

(The Me.log spits out the class, the effective side and then the message, and everything is happeneing on the right side)

Why does this.times say 0 when i set it to 12?

Posted

I solved it now, but was away when i was doing it so couldnt update you all. Here's how it works for me :

 

@Override

public void encodeInto(ChannelHandlerContext ctx, ByteBuf buffer)

{

RSLogging.log(this.getClass(), "Encoding Exp " + ExpAmount + " " + SkillAmount + " for " + theSkill.ordinal());

buffer.writeInt(ExpAmount);

buffer.writeInt(SkillAmount);

buffer.writeInt(theSkill.ordinal());

}

 

@Override

public void decodeInto(ChannelHandlerContext ctx, ByteBuf buffer)

{

this.ExpAmount = buffer.readInt();

this.SkillAmount = buffer.readInt();

this.theSkill = Skill.getValue(buffer.readInt());

 

Me.log(this.getClass(), "Decoding : Exp " + ExpAmount + " " + SkillAmount + " for " + theSkill);

 

}

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Do you use Connector with fabric-api? The used build is not compatible with the Forge version
    • It gave me an error report. I don't understand what it means. Can you tell me what I should do?   report: [27Mar2025 13:52:28.379] [main/FATAL] [net.minecraftforge.server.loading.ServerModLoader/]: Crash report saved to ./crash-reports/crash-2025-03-27_13.52.28-fml.txt [27Mar2025 13:52:28.384] [main/ERROR] [net.minecraft.server.Main/FATAL]: Failed to start the minecraft server net.minecraftforge.fml.LoadingFailedException: Loading errors encountered: [ Mod §efabric_command_api_v2§r requires §6forge§r §o47.1.3§r §7Currently, §6forge§r§7 is §o47.4.0, Mod §efabric_model_loading_api_v1§r requires §6forge§r §o47.1.3§r §7Currently, §6forge§r§7 is §o47.4.0, Mod §efabric_content_registries_v0§r requires §6forge§r §o47.1.3§r §7Currently, §6forge§r§7 is §o47.4.0, Mod §efabric_api_base§r requires §6forge§r §o47.1.3§r §7Currently, §6forge§r§7 is §o47.4.0, Mod §efabric_item_api_v1§r requires §6forge§r §o47.1.3§r §7Currently, §6forge§r§7 is §o47.4.0, Mod §efabric_mining_level_api_v1§r requires §6forge§r §o47.1.3§r §7Currently, §6forge§r§7 is §o47.4.0, Mod §efabric_renderer_indigo§r requires §6forge§r §o47.1.3§r §7Currently, §6forge§r§7 is §o47.4.0, Mod §efabric_object_builder_api_v1§r requires §6forge§r §o47.1.3§r §7Currently, §6forge§r§7 is §o47.4.0, Mod §ewaystones§r requires §6balm§r §o7.0.0 or above§r §7Currently, §6balm§r§7 is §o§nnot installed, Mod §efabric_events_interaction_v0§r requires §6forge§r §o47.1.3§r §7Currently, §6forge§r§7 is §o47.4.0, Mod §efabric_transfer_api_v1§r requires §6forge§r §o47.1.3§r §7Currently, §6forge§r§7 is §o47.4.0, Mod §efabric_registry_sync_v0§r requires §6forge§r §o47.1.3§r §7Currently, §6forge§r§7 is §o47.4.0, Mod §efabric_screen_handler_api_v1§r requires §6forge§r §o47.1.3§r §7Currently, §6forge§r§7 is §o47.4.0, Mod §efabric_particles_v1§r requires §6forge§r §o47.1.3§r §7Currently, §6forge§r§7 is §o47.4.0, Mod §efabric_renderer_api_v1§r requires §6forge§r §o47.1.3§r §7Currently, §6forge§r§7 is §o47.4.0, Mod §efabric_resource_loader_v0§r requires §6forge§r §o47.1.3§r §7Currently, §6forge§r§7 is §o47.4.0, Mod §efabric_sound_api_v1§r requires §6forge§r §o47.1.3§r §7Currently, §6forge§r§7 is §o47.4.0, Mod §efabric_lifecycle_events_v1§r requires §6forge§r §o47.1.3§r §7Currently, §6forge§r§7 is §o47.4.0, Mod §efabric_data_generation_api_v1§r requires §6forge§r §o47.1.3§r §7Currently, §6forge§r§7 is §o47.4.0, Mod §efabric_networking_api_v1§r requires §6forge§r §o47.1.3§r §7Currently, §6forge§r§7 is §o47.4.0, Mod §efabric_item_group_api_v1§r requires §6forge§r §o47.1.3§r §7Currently, §6forge§r§7 is §o47.4.0, Mod §efabric_transitive_access_wideners_v1§r requires §6forge§r §o47.1.3§r §7Currently, §6forge§r§7 is §o47.4.0, Mod §efabric_rendering_fluids_v1§r requires §6forge§r §o47.1.3§r §7Currently, §6forge§r§7 is §o47.4.0, Mod §efabric_dimensions_v1§r requires §6forge§r §o47.1.3§r §7Currently, §6forge§r§7 is §o47.4.0, Mod §efabric_resource_conditions_api_v1§r requires §6forge§r §o47.1.3§r §7Currently, §6forge§r§7 is §o47.4.0, Mod §efabric_recipe_api_v1§r requires §6forge§r §o47.1.3§r §7Currently, §6forge§r§7 is §o47.4.0, Mod §efabric_screen_api_v1§r requires §6forge§r §o47.1.3§r §7Currently, §6forge§r§7 is §o47.4.0, Mod §eapoli§r requires §6caelus§r §o3.1.0 or above§r §7Currently, §6caelus§r§7 is §o§nnot installed, Mod §efabric_client_tags_api_v1§r requires §6forge§r §o47.1.3§r §7Currently, §6forge§r§7 is §o47.4.0, Mod §efabric_block_view_api_v2§r requires §6forge§r §o47.1.3§r §7Currently, §6forge§r§7 is §o47.4.0, Mod §efabric_models_v0§r requires §6forge§r §o47.1.3§r §7Currently, §6forge§r§7 is §o47.4.0, Mod §efabric_api§r requires §6forge§r §o47.1.3§r §7Currently, §6forge§r§7 is §o47.4.0, Mod §efabric_loot_api_v2§r requires §6forge§r §o47.1.3§r §7Currently, §6forge§r§7 is §o47.4.0, Mod §efabric_rendering_data_attachment_v1§r requires §6forge§r §o47.1.3§r §7Currently, §6forge§r§7 is §o47.4.0, Mod §efabric_rendering_v1§r requires §6forge§r §o47.1.3§r §7Currently, §6forge§r§7 is §o47.4.0, Mod §efabric_convention_tags_v1§r requires §6forge§r §o47.1.3§r §7Currently, §6forge§r§7 is §o47.4.0, Mod §efabric_key_binding_api_v1§r requires §6forge§r §o47.1.3§r §7Currently, §6forge§r§7 is §o47.4.0, Mod §efabric_biome_api_v1§r requires §6forge§r §o47.1.3§r §7Currently, §6forge§r§7 is §o47.4.0, Mod §efabric_message_api_v1§r requires §6forge§r §o47.1.3§r §7Currently, §6forge§r§7 is §o47.4.0, Mod §efabric_block_api_v1§r requires §6forge§r §o47.1.3§r §7Currently, §6forge§r§7 is §o47.4.0, Mod §efabric_api_lookup_api_v1§r requires §6forge§r §o47.1.3§r §7Currently, §6forge§r§7 is §o47.4.0, Mod §efabric_game_rule_api_v1§r requires §6forge§r §o47.1.3§r §7Currently, §6forge§r§7 is §o47.4.0, Mod §efabric_blockrenderlayer_v1§r requires §6forge§r §o47.1.3§r §7Currently, §6forge§r§7 is §o47.4.0, Mod §efabric_entity_events_v1§r requires §6forge§r §o47.1.3§r §7Currently, §6forge§r§7 is §o47.4.0 ] at net.minecraftforge.fml.ModLoader.gatherAndInitializeMods(ModLoader.java:149) ~[fmlcore-1.20.1-47.4.0.jar%23154!/:?] at net.minecraftforge.server.loading.ServerModLoader.load(ServerModLoader.java:30) ~[forge-1.20.1-47.4.0-universal.jar%23158!/:?] at net.minecraft.server.Main.main(Main.java:125) ~[server-1.20.1-20230612.114412-srg.jar%23153!/:?] at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?] at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[?:?] at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?] at java.lang.reflect.Method.invoke(Method.java:568) ~[?:?] at net.minecraftforge.fml.loading.targets.CommonLaunchHandler.runTarget(CommonLaunchHandler.java:111) ~[fmlloader-1.20.1-47.4.0.jar%2369!/:?] at net.minecraftforge.fml.loading.targets.CommonLaunchHandler.serverService(CommonLaunchHandler.java:103) ~[fmlloader-1.20.1-47.4.0.jar%2369!/:?] at net.minecraftforge.fml.loading.targets.CommonServerLaunchHandler.lambda$makeService$0(CommonServerLaunchHandler.java:27) ~[fmlloader-1.20.1-47.4.0.jar%2369!/:?] at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:30) ~[modlauncher-10.0.9.jar%2355!/:?] at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:53) ~[modlauncher-10.0.9.jar%2355!/:?] at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:71) ~[modlauncher-10.0.9.jar%2355!/:?] at cpw.mods.modlauncher.Launcher.run(Launcher.java:108) ~[modlauncher-10.0.9.jar%2355!/:?] at cpw.mods.modlauncher.Launcher.main(Launcher.java:78) ~[modlauncher-10.0.9.jar%2355!/:?] at cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:26) ~[modlauncher-10.0.9.jar%2355!/:?] at cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:23) ~[modlauncher-10.0.9.jar%2355!/:?] at cpw.mods.bootstraplauncher.BootstrapLauncher.main(BootstrapLauncher.java:141) ~[bootstraplauncher-1.1.2.jar:?]
  • Topics

  • Who's Online (See full list)

    • There are no registered users currently online
×
×
  • Create New...

Important Information

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