Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

How addParticles Totem particles?


3mptysl
 Share

Recommended Posts

Look at ClientPacketListener.handleEntityEvent() for how vanilla does this.

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Link to comment
Share on other sites

See the bottom of here for how to broadcast packets: https://forge.gemwire.uk/wiki/SimpleChannel

You probably want to use something like

PacketDistributor.TRACKING_ENTITY.with(() -> player);

 which sends the packet to all other players in range of that "player".

 

You will need to include the player.getId() in the packet you send.

So on the client side you can then use it to do Minecraft.getInstance().level.getEntity() - check this is not null

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Link to comment
Share on other sites

Okay, i think i understand but im getting issues, i create another packet to sync entity to another players like this

package com.naim.belloto.networking.packet;

import com.naim.belloto.networking.handler.ClientSyncHandler;
import net.minecraft.client.Minecraft;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.DistExecutor;
import net.minecraftforge.network.NetworkEvent;

import java.util.Objects;
import java.util.function.Supplier;

public class ClientSyncPacket {

    public ClientSyncPacket() {

    }

    public ClientSyncPacket(FriendlyByteBuf buf) {

    }

    public void toBytes(FriendlyByteBuf buf) {

    }

    public boolean handle(Supplier<NetworkEvent.Context> ctx) {
        NetworkEvent.Context context = ctx.get();
        context.enqueueWork(() -> {

            assert Minecraft.getInstance().player != null;
            int idplayer = Minecraft.getInstance().player.getId();

            DistExecutor.unsafeCallWhenOn(Dist.CLIENT,() -> () -> ClientSyncHandler.handlePacket(ctx, idplayer));

        });
        return true;
    }
}

And in the handler:

public class ClientSyncHandler {

    public static boolean handlePacket(Supplier<NetworkEvent.Context> ctx, int idPlayer) {
        Minecraft.getInstance().level.getEntity(idPlayer);
        return true;
    }

        
}

But is not working :// 

Link to comment
Share on other sites

What do you mean "not working"? Your code (if it were logical) does nothing.

Additionally, you have the following issues:

  • You are using a client-only class (Minecraft) from common code (ClientSyncPacket).
  • Your packet does not tell the client which player this is about. It needs to do so using the player's ID. Currently your packet just uses Minecraft#player, which is not necessarily the correct player.
Link to comment
Share on other sites

Aah i though Minecraft.level.getIstance().getEntity(playerid) sincronice what is happen with player using getEntity() i was wrong.

So u said playerid is not the correct player? And how i get the correct player id?

Or im wrong too?

Sry if is a stupid question Minecraft is not difficult but im lerning :D

Link to comment
Share on other sites

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
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.

 Share



×
×
  • Create New...

Important Information

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