Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (โ‹ฎ) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Im creating the totem of undying so i need to put the particles into an entity, but i dont know how, to use addParticles but dont work.

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.

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.

  • Author

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 ://ย 

  • Author

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

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions โ†’ Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.