public class PacketUtil
extends java.lang.Object
| Constructor and Description |
|---|
PacketUtil() |
| Modifier and Type | Method and Description |
|---|---|
static <T extends net.minecraft.tileentity.TileEntity> |
getTE(net.minecraft.entity.player.PlayerEntity player,
net.minecraft.util.math.BlockPos pos,
java.lang.Class<T> cls)
Get the relevant target tile entity for packet purposes.
|
static <T extends net.minecraft.tileentity.TileEntity> |
getTE(net.minecraft.entity.player.PlayerEntity player,
java.lang.Class<T> cls)
Server-only variant of
getTE(PlayerEntity, BlockPos, Class) |
static net.minecraft.util.math.GlobalPos |
readGlobalPos(net.minecraft.network.PacketBuffer buf) |
static net.minecraft.block.BlockState |
readNullableBlockState(net.minecraft.network.PacketBuffer buf)
Read a (possibly null) blockstate from the network
|
static void |
writeGlobalPos(net.minecraft.network.PacketBuffer buf,
net.minecraft.util.math.GlobalPos gPos) |
static void |
writeNullableBlockState(net.minecraft.network.PacketBuffer buf,
net.minecraft.block.BlockState state)
Write a blockstate, which may be null, to the network
|
public static void writeGlobalPos(net.minecraft.network.PacketBuffer buf,
net.minecraft.util.math.GlobalPos gPos)
public static net.minecraft.util.math.GlobalPos readGlobalPos(net.minecraft.network.PacketBuffer buf)
@Nonnull
public static <T extends net.minecraft.tileentity.TileEntity> java.util.Optional<T> getTE(net.minecraft.entity.player.PlayerEntity player,
net.minecraft.util.math.BlockPos pos,
java.lang.Class<T> cls)
Important: cannot be used to sync changes after the server-side
container could be closed, i.e. don't use this in packets sent from a GUI onClose() method.
player - the player, will be null if packet is being received on clientpos - the blockpos, ignored if packet is being received on servercls - the desired tile entity class@Nonnull
public static <T extends net.minecraft.tileentity.TileEntity> java.util.Optional<T> getTE(net.minecraft.entity.player.PlayerEntity player,
java.lang.Class<T> cls)
getTE(PlayerEntity, BlockPos, Class)player - the playercls - the desired tile entity classpublic static void writeNullableBlockState(net.minecraft.network.PacketBuffer buf,
@Nullable
net.minecraft.block.BlockState state)
buf - the packet bufferstate - the state to write@Nullable public static net.minecraft.block.BlockState readNullableBlockState(net.minecraft.network.PacketBuffer buf)
buf - the packet buffer