#Crash after adding packets/payloads
1 messages · Page 1 of 1 (latest)
Caused by: net.minecraft.util.InvalidIdentifierException: Non [a-z0-9/._-] character in path of location: minecraft:mrmrmrpizza_mod:add_draft_particles
AddDraftParticlesPayload.java
Line 16
There is nothing wrong in that class though, or that method. I can share the code, gimme a sec
public static final CustomPayload.Id<AddDraftParticlesPayload> ID = CustomPayload.id(Mrmrmrpizza_Mod.mod_id("add_draft_particles").toString());
public static final PacketCodec<PacketByteBuf, AddDraftParticlesPayload> CODEC = PacketCodec.tuple(PacketCodecs.VAR_INT, AddDraftParticlesPayload::entityId, AddDraftParticlesPayload::new);
@Override
public CustomPayload.Id<? extends CustomPayload> getId() {
return ID;
}
public static void send(ServerPlayerEntity player, int id) {
ServerPlayNetworking.send(player, new AddDraftParticlesPayload(id));
}
public static class Receiver implements ClientPlayNetworking.PlayPayloadHandler<AddDraftParticlesPayload> {
@Override
public void receive(AddDraftParticlesPayload payload, ClientPlayNetworking.Context context) {
Entity entity = context.player().getWorld().getEntityById(payload.entityId());
if (entity != null) {
DraftEnchantmentUtil.addDraftParticles(entity);
}
}
}
}
Line 16: public static final CustomPayload.Id<AddDraftParticlesPayload> ID = CustomPayload.id(Mrmrmrpizza_Mod.mod_id("add_draft_particles").toString());
public record AddDraftParticlesPayload(int entityId) implements CustomPayload {
public static final CustomPayload.Id<AddDraftParticlesPayload> ID = CustomPayload.id(Mrmrmrpizza_Mod.mod_id("add_draft_particles").toString());
public static final PacketCodec<PacketByteBuf, AddDraftParticlesPayload> CODEC = PacketCodec.tuple(PacketCodecs.VAR_INT, AddDraftParticlesPayload::entityId, AddDraftParticlesPayload::new);
@Override
public CustomPayload.Id<? extends CustomPayload> getId() {
return ID;
}
public static void send(ServerPlayerEntity player, int id) {
ServerPlayNetworking.send(player, new AddDraftParticlesPayload(id));
}
public static class Receiver implements ClientPlayNetworking.PlayPayloadHandler<AddDraftParticlesPayload> {
@Override
public void receive(AddDraftParticlesPayload payload, ClientPlayNetworking.Context context) {
Entity entity = context.player().getWorld().getEntityById(payload.entityId());
if (entity != null) {
DraftEnchantmentUtil.addDraftParticles(entity);
}
}
}
Now it readable
How did u do that?
```java
code
```
public record AddDraftParticlesPayload(int entityId) implements CustomPayload {
public static final CustomPayload.Id<AddDraftParticlesPayload> ID = CustomPayload.id(Mrmrmrpizza_Mod.mod_id("add_draft_particles").toString());
public static final PacketCodec<PacketByteBuf, AddDraftParticlesPayload> CODEC = PacketCodec.tuple(PacketCodecs.VAR_INT, AddDraftParticlesPayload::entityId, AddDraftParticlesPayload::new);
@Override
public CustomPayload.Id<? extends CustomPayload> getId() {
return ID;
}
public static void send(ServerPlayerEntity player, int id) {
ServerPlayNetworking.send(player, new AddDraftParticlesPayload(id));
}
public static class Receiver implements ClientPlayNetworking.PlayPayloadHandler<AddDraftParticlesPayload> {
@Override
public void receive(AddDraftParticlesPayload payload, ClientPlayNetworking.Context context) {
Entity entity = context.player().getWorld().getEntityById(payload.entityId());
if (entity != null) {
DraftEnchantmentUtil.addDraftParticles(entity);
}
}
}
Ooooh
What the hell is that Mrmrmrpizza_Mod.mod_id("add_draft_particles").toString()
Its an id for this line of code: Line 20:
public CustomPayload.Id<? extends CustomPayload> getId() {
return ID;
}
Problem is here. What the hell is this, why and how it is writed inside?
Wym?
Ill give u the variables involved
public static final String MOD_ID = "mrmrmrpizza_mod";
public static Identifier mod_id(String path) {
return Identifier.of(MOD_ID, path);
}
The class must return an id for it to be valid
Hence the mention of the id
Oh yeah, and here is the initialization:
PayloadTypeRegistry.playS2C().register(AddDraftParticlesPayload.ID, AddDraftParticlesPayload.CODEC);
PayloadTypeRegistry.playC2S().register(DraftPayload.ID, DraftPayload.CODEC);
ServerPlayNetworking.registerGlobalReceiver(DraftPayload.ID, new DraftPayload.Receiver());
- Method in java are
snakeCase, notlower_case - Why return is as
toString() - Use
public static final CustomPayload.Id<AddDraftParticlesPayload> ID = CustomPayload.Id(Mrmrmrpizza_Mod.mod_id("add_draft_particles"));
That look fine
Ok good
I just tried that and it threw the same error
Screen code and error
Not text
But i had to adapt it to this, becuase this line needs/wants a method call:
public static final CustomPayload.Id<AddDraftParticlesPayload> ID = new Id(Mrmrmrpizza_Mod.mod_id("add_draft_particles"));
?
Ok,
I'm sure with same mistake
Lemme check
Yep, the exact same
Ill try that
These lines of code are yelling now because they expect Id<T>, but insead got Id<AddDraftParticles
PayloadTypeRegistry.playC2S().register(DraftPayload.ID, DraftPayload.CODEC);
ServerPlayNetworking.registerGlobalReceiver(DraftPayload.ID, new DraftPayload.Receiver());
Ye. I modify my Kotlin and in it we not use new so I idk without IDE where in Java need new key and where no
Lol
Let me open my project
Alr alr
6 IDEAs same time
It do be like that sometimes tho
I'm implementing logic on same level as registration instead of in packet
For java my looks like this
ServerPlayNetworking.registerGlobalReceiver(Packet.ID, (payload, context) -> {
})
Ok,
Ok
And for extract IDEA suggest just void method. But I mostly keep Mojang like ways (so I don't extract)
ServerPlayNetworking.registerGlobalReceiver(Packet.ID, BoxRenderer::receive);
}
private static void receive(DeaconPacket payload, ServerPlayNetworking.Context context) {
}
Soo, i put that into something?
I also dont use Kotlin
Thats why I "try" to convert all to java for this chat
Ahh, gotcha
I can't totally say about your Reciver implementation. Never used it. But found sometimes weeks ago made my java example
public record S2CPingPacket(String userName) implements CustomPayload {
public static final CustomPayload.Id<S2CPingPacket> PACKET_ID = new CustomPayload.Id<>(Identifier.of("mod_id", "ping"));
public static final PacketCodec<RegistryByteBuf, S2CPingPacket> PACKET_CODEC = PacketCodec.of((value, buf) -> {
buf.writeString(value.userName);
}, buf -> {
return new S2CPingPacket(buf.readString());
});
@Override
public Id<? extends CustomPayload> getId() {
return PACKET_ID;
}
}
public class Java implements ModInitializer {
@Override
public void onInitialize() {
PayloadTypeRegistry.playS2C().register(S2CPingPacket.PACKET_ID, S2CPingPacket.PACKET_CODEC);
ClientPlayNetworking.registerGlobalReceiver(S2CPingPacket.PACKET_ID, (payload, context) -> {
System.out.println("CLIENT RECEIVE: " + payload.userName());
});
PlayerBlockBreakEvents.AFTER.register((world, player, pos, state, blockEntity) -> {
ServerPlayNetworking.send((ServerPlayerEntity) player, new S2CPingPacket(player.getName().getString()));
});
}
}
It should be compatible with almost all cases (That is Server to Client but I'm sure you understand how it should looks on Client to Server. For you main case is PACKET_CODEC)
Ok, so that seems to be fine, ill run the client just to make sure
Ok, the probel now is that its complaining that i didnt send the packet right in my previoud code. So how would i send this packet?
DraftPayload.send();
that no longer works
In my example that one send packet
ServerPlayNetworking.send((ServerPlayerEntity) player, new S2CPingPacket(player.getName().getString()));
Use that table to select correct method
My code almost all based on MC sourse + support from mod-dev-1 channel on first day when 1.21 was release
Ok, so i am trying to run this packet from the client, not the server, and its throwing the "Inconvertible types;" error
Yes, it works, but the sending part is the part that is not working anymore. Aswell as the fact idk where to put my call to the actual particles themselves
Where/when you call it?
Where/When/How i call "AddDraftParticles"

Yeah,
Where you previosly call it?
public static class Receiver implements ServerPlayNetworking.PlayPayloadHandler<DraftPayload> {
@Override
public void receive(DraftPayload payload, ServerPlayNetworking.Context context) {
PlayerLookup.tracking(context.player()).forEach(foundPlayer -> AddDraftParticlesPayload.send(foundPlayer, context.player().getId()));
}
}
}```
So
Replacy with you correct lines. I don't have time for it xD
ServerPlayNetworking.registerGlobalReceiver(DraftPayload.ID, (payload, context) -> {
PlayerLookup.tracking(context.player()).forEach(foundPlayer -> AddDraftParticlesPayload.send(foundPlayer, context.player().getId()))
};
I only now saw that you call one network from other. Never did that before. But that should works
Is that for the new system you suggested, or the old one I had?
For my example
It replacy your old ServerPlayNetworking.registerGlobalReceiver(DraftPayload.ID, new DraftPayload.Receiver())
Ok, then do I put it in a method? Because the old method doesn't exist anymore in your example
Sorry if I am being a bit demanding, this is just my first time doing packets and I am very confused
So re-import my old method, but replace what is in there with your code?
If I understand question correctly - yes
If I missunderstode, then you can just share Github and I will make Pull request
I code a packet as same as Mrpizza
but I confuse which one is c2s / s2c
Ah. We there now maybe have confused chat. Because my example is for S2C and he make C2S
But techincally its 1:1. Just replace class by table above
I should later make better example
But I don't have time right now
which one did you want to send? Mrpizza?
?
I am just trying to get this to work, and its so confusing
I appriciate the help that Syorito gave, but i dont understand how it works, or how to use it
Based on that
Both
it not hard as you think
Take my example. Put it without modifications into you (or new project). Break a block and you will understand (that how I teach previos guy)
Much easier that before. At least for me how come from 1.7.10
@torpid steeple My example send packet when player break block
AddDraftParticlesPayload.send(entity.getId); //server side
I am executing from only Client side, thats y i needed to send a packet to the server for it to do the particles in the first place
My original issue is that the particles and sounds that were playing wouldnt play for the other players nearby
So i looked it up, saw i needed to use packets, and tried to go off of the little i knew
that still need to send form server to make client side excute
Nothing happened
?
I am trying to execute code on the server side, but from the client side
Ye. My another example is for tuples. But I prefer to send example that is easy to customize
which one is your client payload
like this
Ahh,
ClientPlayNetworking.send()
public record AddDraftParticlesPayload(int entityId) implements CustomPayload {
public static final CustomPayload.Id<AddDraftParticlesPayload> ID = new Id(Mrmrmrpizza_Mod.mod_id("add_draft_particles"));
public static final PacketCodec<PacketByteBuf, AddDraftParticlesPayload> CODEC = PacketCodec.tuple(PacketCodecs.VAR_INT, AddDraftParticlesPayload::entityId, AddDraftParticlesPayload::new);
@Override
public CustomPayload.Id<? extends CustomPayload> getId() {
return ID;
}
public static void send(ServerPlayerEntity player, int id) {
ServerPlayNetworking.send(player, new AddDraftParticlesPayload(id));
}
public static class Receiver implements ClientPlayNetworking.PlayPayloadHandler<AddDraftParticlesPayload> {
@Override
public void receive(AddDraftParticlesPayload payload, ClientPlayNetworking.Context context) {
Entity entity = context.player().getWorld().getEntityById(payload.entityId());
if (entity != null) {
DraftEnchantmentUtil.addDraftParticles(entity);
}
}
}
}
this one is server side you make it wrong
Ahh
it s2c it why you can't hear the sound
With that it wont even launch the game. It just crashes, i dont have a single chance to hear the sound anyways
where is PayloadTypeRegistry of AddDraftParticlesPayload?
PayloadTypeRegistry.playS2C().register(AddDraftParticlesPayload.ID, AddDraftParticlesPayload.CODEC);```
I dont know the difference, should i change it?
He execute client
Client go to server
Server execute another to client
That how I understand
yes
Yes, the client goes to the server with the request, the server authorizes it and sends the displayed sound and particle effect packets to everyone nearby
I just tried that, and it still crashes
did you update playS2C to C2S yet?
PayloadTypeRegistry.playC2S().register(AddDraftParticlesPayload.ID, AddDraftParticlesPayload.CODEC);
yes
and change to ClientNetwork in AddDraftParticlesPayload?
e
What?
public static class Receiver implements ClientPlayNetworking.PlayPayloadHandler<AddDraftParticlesPayload> {
@Override
public void receive(AddDraftParticlesPayload payload, ClientPlayNetworking.Context context) {
Entity entity = context.player().getWorld().getEntityById(payload.entityId());
if (entity != null) {
DraftEnchantmentUtil.addDraftParticles(entity);
}
}
}
}
in there?
public static void send(int id) {
ClientPlayNetworking.send(new AddDraftParticlesPayload(id));
}
public static class Receiver implements ServerPlayNetworking.PlayPayloadHandler<AddDraftParticlesPayload> {
@Override
public void receive(AddDraftParticlesPayload payload, ServerPlayNetworking.Context context) {
Entity entity = context.player().getWorld().getEntityById(payload.entityId());
if (entity != null) {
DraftEnchantmentUtil.addDraftParticles(entity);
}
}
}
this in your AddDraftParticlesPayload
PlayerLookup.tracking(context.player()).forEach(foundPlayer -> AddDraftParticlesPayload.send(foundPlayer, context.player().getId()));
this is then complaining about that it has the serverplayerentity instead of an int, do i just add the peramiter to ur code?
Do i do this?
public static void send(ServerPlayerEntity foundPlayer, int id) {
ClientPlayNetworking.send(new AddDraftParticlesPayload(id));
}```
Sure, i dont know which ones are which, so ill just give you all the classes involved
did you have repo?
Nope
I'm confuse on your code which one is server which one is client
"DraftPayload.java"
public record DraftPayload() implements CustomPayload {
public static final CustomPayload.Id<DraftPayload> ID = CustomPayload.id(Mrmrmrpizza_Mod.mod_id("draft").toString());
public static final PacketCodec<PacketByteBuf, DraftPayload> CODEC = PacketCodec.unit(new DraftPayload());
@Override
public CustomPayload.Id<? extends CustomPayload> getId() {
return ID;
}
public static void send(int id) {
ClientPlayNetworking.send(new AddDraftParticlesPayload(id));
}
public static class Receiver implements ServerPlayNetworking.PlayPayloadHandler<AddDraftParticlesPayload> {
@Override
public void receive(AddDraftParticlesPayload payload, ServerPlayNetworking.Context context) {
Entity entity = context.player().getWorld().getEntityById(payload.entityId());
if (entity != null) {
DraftEnchantmentUtil.addDraftParticles(entity);
}
}
}
}```
Me too, i didnt know there was a difference
then you just send this one
"AddDraftParticlesPayload.java"
public record AddDraftParticlesPayload(int entityId) implements CustomPayload {
public static final CustomPayload.Id<AddDraftParticlesPayload> ID = new Id(Mrmrmrpizza_Mod.mod_id("add_draft_particles"));
public static final PacketCodec<PacketByteBuf, AddDraftParticlesPayload> CODEC = PacketCodec.tuple(PacketCodecs.VAR_INT, AddDraftParticlesPayload::entityId, AddDraftParticlesPayload::new);
@Override
public CustomPayload.Id<? extends CustomPayload> getId() {
return ID;
}
public static void send(int id) {
ClientPlayNetworking.send(new AddDraftParticlesPayload(id));
}
public static class Receiver implements ServerPlayNetworking.PlayPayloadHandler<AddDraftParticlesPayload> {
@Override
public void receive(AddDraftParticlesPayload payload, ServerPlayNetworking.Context context) {
Entity entity = context.player().getWorld().getEntityById(payload.entityId());
if (entity != null) {
DraftEnchantmentUtil.addDraftParticles(entity);
}
}
}
}
Ye. Contribute can be much faster. One guy contribute in many mods on KaupenJoe server by resolve that kind of issues
ok my bad
that is your serverside
public record AddDraftParticlesPayload(int entityId) implements CustomPayload {
public static final CustomPayload.Id<AddDraftParticlesPayload> ID = new Id(Mrmrmrpizza_Mod.mod_id("add_draft_particles"));
public static final PacketCodec<PacketByteBuf, AddDraftParticlesPayload> CODEC = PacketCodec.tuple(PacketCodecs.VAR_INT, AddDraftParticlesPayload::entityId, AddDraftParticlesPayload::new);
@Override
public CustomPayload.Id<? extends CustomPayload> getId() {
return ID;
}
public static void send(ServerPlayerEntity player, int id) {
ServerPlayNetworking.send(player, new AddDraftParticlesPayload(id));
}
public static class Receiver implements ClientPlayNetworking.PlayPayloadHandler<AddDraftParticlesPayload> {
@Override
public void receive(AddDraftParticlesPayload payload, ClientPlayNetworking.Context context) {
Entity entity = context.player().getWorld().getEntityById(payload.entityId());
if (entity != null) {
DraftEnchantmentUtil.addDraftParticles(entity);
}
}
}
}
"DraftEnchantmentUtil.java"
public abstract class DraftEnchantmentUtil extends PlayerEntity {
public DraftEnchantmentUtil(World world, BlockPos pos, float yaw, GameProfile gameProfile) {
super(world, pos, yaw, gameProfile);
}
public static void addDraftParticles(Entity entity) {
if (MinecraftClient.getInstance().gameRenderer.getCamera().isThirdPerson() || entity != MinecraftClient.getInstance().cameraEntity) {
for (int i = 0; i < 8; i++) {
entity.getWorld().addParticle(ParticleTypes.CLOUD, entity.getParticleX(1), entity.getY(), entity.getParticleZ(1), 0, 0, 0);
}
}
}
public static boolean hasCustomEnchantment(PlayerEntity player) {
ItemStack boots = player.getInventory().armor.get(0);
if (!boots.isEmpty()) {
DynamicRegistryManager registryManager = player.getWorld().getRegistryManager();
Identifier draftIdentifier = Identifier.of("mrmrmrpizza_mod", "draft");
Optional<RegistryEntry.Reference<Enchantment>> draftEnchantmentEntry = registryManager.get(RegistryKeys.ENCHANTMENT)
.getEntry(draftIdentifier);
if (draftEnchantmentEntry.isPresent()) {
return EnchantmentHelper.getLevel(draftEnchantmentEntry.get(), boots) > 0;
}
}
return false;
}
ok now playload registry
Ok,
hold on bro
💀
"Mrmrmrpizza_Mod.java"
public class Mrmrmrpizza_Mod implements ModInitializer {
public static final String MOD_ID = "mrmrmrpizza_mod";
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
public static Identifier mod_id(String path) {
return Identifier.of(MOD_ID, path);
}
@Override
public void onInitialize() {
ModBlocks.initialize();
ModItems.initialize();
ModEffects.initialize();
ModArmor.initialize();
ModDataTracker.initialize();
PayloadTypeRegistry.playC2S().register(AddDraftParticlesPayload.ID, AddDraftParticlesPayload.CODEC);
PayloadTypeRegistry.playC2S().register(DraftPayload.ID, DraftPayload.CODEC);
ServerPlayNetworking.registerGlobalReceiver(DraftPayload.ID, new DraftPayload.Receiver());
}
}
Alr alr i will
ok now clientside one
Maybe he gonna make 
I sent all the classes that are associated with the payloads/packets, there are no more classes that have any code that pertain to this
you missing client..
I think you miss client one
ClientPlayNetworking.registerGlobalReceiver() thing
on your AddDraftParticlesPayload
Are you sure its not this?
that one already correct
but you missing client receiver
same as ServerPlayNetworking.registerGlobalReceiver(DraftPayload.ID, new DraftPayload.Receiver());
but change to client and put client playload instead
Ok, ill try that
Yeahh, so i didnt split client and server when creating this mod Lmao

I SPACED IT
💀
I MADE THE TEMPLATE
AND I COMPLETELY SPACED IT
I didnt want to recreate it and have to put everything in the riht places again, so i just didnt
So how do i do this then?
How do i just do the system
I am done with trying to modify this, just tell me how to remake it, please.
You should have github repo with our origin unwork version and re create thread
With Repository is much easier to help
I can try to throw this on a github real quick
It doesnt let me upload my project, the file is apperantly too big
You shouldn't upload all
What should i upload then? Just the files involved?

Only that
Screenshot of CoFH repo
It still doesnt let me upload it
Github/Git tutorials on YT will help you
or ChatGPT
Ok, i did it, its in a repo
Now how do i give access to you?
Or let you see it?
Ahh, ok
🧑🍳
ehehehheh
im lurking
im waiting
for the repo
and then its mine
rtahahhahahahha
RHAHAHAHHAHAHAHHAHAHAH
?

And because I'm right now ending today job I'm go sleep. So 🍵 and 🐱 maybe help you
Ok, goodnight
Thank you for all your help
Resolved?
Nope
If you would like, I can share the github repo that I made for it so you could get a better scope of the problems
Didn't you should share it yesterday?
At least kittycat is await for it too
Yeah Lol
He wants it a little too much
