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

I didn't understand some things in this thread

Looks like I need this

https://ibb.co/3zkRxWf

How to use NetworkHooks.getEntitySpawningPacket ? (And do I need to use it?)
and

Where to send the custom package. From what point in the code will it be correct to send it. How to form correctly.
I messed with the package a bit and was able to spawn a cow through the server, but that seems to be all I can :3

Edited by Luckydel

11 hours ago, Luckydel said:

How to use NetworkHooks.getEntitySpawningPacket ? (And do I need to use it?)

Call it in `#getAddEntityPacket`.

11 hours ago, Luckydel said:

Where to send the custom package. From what point in the code will it be correct to send it. How to form correctly.

You'll basically need to send it pretty much every tick, otherwise the data may be wrong at certain times. As for how to:ย https://docs.minecraftforge.net/en/latest/networking/simpleimpl/

  • Author

I tried this

public Packet<?> getAddEntityPacket(){
        Entity entity = this.getOwner();
        int i = entity == null ? 0 : entity.getId();
        
        double xPower = getDeltaMovement().x;
        double yPower = getDeltaMovement().y;
        double zPower = getDeltaMovement().z;
        
        return new ClientboundAddEntityPacket(this.getId(), this.getUUID(), this.getX(), this.getY(), this.getZ(), this.getXRot(), this.getYRot(), this.getType(), i, new Vec3(xPower, yPower, zPower), 0.0D);

    }

ย 

The entity just hangs in the air and disappears

I tried to make my class like ClientboundAddEntityPacket

public class sendVecEntity2 implements Packet<ClientGamePacketListener> {
    private final int id;
    private final UUID uuid;
    private final EntityType<?> type;
    private final double x;
    private final double y;
    private final double z;
    private final int xa;
    private final int ya;
    private final int za;
    private final byte xRot;
    private final byte yRot;
    private final byte yHeadRot;
    private final int data;
    public sendVecEntity2(int p_237546_, UUID p_237547_, double p_237548_, double p_237549_, double p_237550_, float p_237551_, float p_237552_, EntityType<?> p_237553_, int p_237554_, Vec3 p_237555_, double p_237556_) {
        this.id = p_237546_;
        this.uuid = p_237547_;
        this.x = p_237548_;
        this.y = p_237549_;
        this.z = p_237550_;
        this.xRot = (byte) Mth.floor(p_237551_ * 256.0F / 360.0F);
        this.yRot = (byte)Mth.floor(p_237552_ * 256.0F / 360.0F);
        this.yHeadRot = (byte)Mth.floor(p_237556_ * 256.0D / 360.0D);
        this.type = p_237553_;
        this.data = p_237554_;
        this.xa = (int)(Mth.clamp(p_237555_.x, -3.9D, 3.9D) * 8000.0D);
        this.ya = (int)(Mth.clamp(p_237555_.y, -3.9D, 3.9D) * 8000.0D);
        this.za = (int)(Mth.clamp(p_237555_.z, -3.9D, 3.9D) * 8000.0D);
    }
    public void write(FriendlyByteBuf p_131498_) {
        p_131498_.writeVarInt(this.id);
        p_131498_.writeUUID(this.uuid);
        p_131498_.writeId(Registry.ENTITY_TYPE, this.type);
        p_131498_.writeDouble(this.x);
        p_131498_.writeDouble(this.y);
        p_131498_.writeDouble(this.z);
        p_131498_.writeByte(this.xRot);
        p_131498_.writeByte(this.yRot);
        p_131498_.writeByte(this.yHeadRot);
        p_131498_.writeVarInt(this.data);
        p_131498_.writeShort(this.xa);
        p_131498_.writeShort(this.ya);
        p_131498_.writeShort(this.za);
    }
    //maybe
    @Override
    public void handle(ClientGamePacketListener p_131342_) {
        //p_131495_.handleAddEntity(this);
    }

}

But obviously it didn't help.
I probably need to register it, but I don't understand how

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.