Posted October 13, 20222 yr 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 October 13, 20222 yr by Luckydel
October 13, 20222 yr 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/
October 13, 20222 yr 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
October 14, 20222 yr 15 hours ago, Luckydel said: I tried this You provided the method you need to call, so why are you calling something else? Just call that method you mentioned.
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.