com.parzivail.util.network.PreciseEntitySpawnS2CPacket Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pswg Show documentation
Show all versions of pswg Show documentation
Explore the galaxy with Galaxies: Parzi's Star Wars Mod!
package com.parzivail.util.network;
import com.parzivail.util.data.PacketByteBufHelper;
import com.parzivail.util.entity.IPrecisionSpawnEntity;
import io.netty.buffer.Unpooled;
import net.fabricmc.fabric.api.networking.v1.PacketSender;
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
import net.minecraft.class_1297;
import net.minecraft.class_243;
import net.minecraft.class_2487;
import net.minecraft.class_2540;
import net.minecraft.class_2596;
import net.minecraft.class_2602;
import net.minecraft.class_2604;
import net.minecraft.class_2960;
import net.minecraft.class_310;
import net.minecraft.class_634;
public class PreciseEntitySpawnS2CPacket extends class_2604
{
private final class_243 velocity;
private final class_2487 data;
private PreciseEntitySpawnS2CPacket(class_1297 entity, int entityData)
{
super(entity, entityData);
this.velocity = entity.method_18798();
this.data = new class_2487();
if (entity instanceof IPrecisionSpawnEntity pse)
pse.writeSpawnData(data);
}
public PreciseEntitySpawnS2CPacket(class_2540 buf)
{
super(buf);
this.velocity = PacketByteBufHelper.readVec3d(buf);
this.data = buf.method_10798();
}
@Override
public void method_11052(class_2540 buf)
{
super.method_11052(buf);
PacketByteBufHelper.writeVec3d(buf, velocity);
buf.method_10794(data);
}
public class_243 getVelocity()
{
return velocity;
}
public class_2487 getData()
{
return data;
}
@SuppressWarnings("unchecked")
public static class_2596 createPacket(class_2960 id, class_1297 entity, int entityData)
{
var passedData = new class_2540(Unpooled.buffer());
new PreciseEntitySpawnS2CPacket(entity, entityData).method_11052(passedData);
return (class_2596)(Object)ServerPlayNetworking.createS2CPacket(id, passedData);
}
public static void handle(class_310 client, class_634 handler, class_2540 buf, PacketSender sender)
{
var packet = new PreciseEntitySpawnS2CPacket(buf);
client.execute(() -> handler.method_11112(packet));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy