Package codechicken.lib.packet
Class PacketCustom
java.lang.Object
codechicken.lib.data.MCDataByteBuf
codechicken.lib.packet.PacketCustom
- All Implemented Interfaces:
MCDataInput,MCDataOutput
-
Nested Class Summary
Nested classes/interfaces inherited from interface codechicken.lib.data.MCDataInput
MCDataInput.InputStreamWrapperNested classes/interfaces inherited from interface codechicken.lib.data.MCDataOutput
MCDataOutput.OutputStreamWrapper -
Field Summary
Fields inherited from class codechicken.lib.data.MCDataByteBuf
buf -
Constructor Summary
ConstructorsConstructorDescriptionPacketCustom(net.minecraft.resources.ResourceLocation channel, int type, @Nullable net.minecraft.core.RegistryAccess registryAccess) -
Method Summary
Modifier and TypeMethodDescriptionappend(byte[] bytes) Appends the content of the array to the end of this buffer.append(io.netty.buffer.ByteBuf buf) Appends aByteBufto the end of this stream.net.minecraft.resources.ResourceLocationintgetType()booleanvoidsendToAllAround(double x, double y, double z, double range, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim) voidsendToAllAround(net.minecraft.core.BlockPos pos, double range, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim) voidvoidsendToChunk(net.minecraft.server.level.ServerLevel level, int chunkX, int chunkZ) voidsendToChunk(net.minecraft.server.level.ServerLevel level, net.minecraft.core.BlockPos pos) voidsendToChunk(net.minecraft.server.level.ServerLevel level, net.minecraft.world.level.ChunkPos pos) voidsendToChunk(net.minecraft.world.level.block.entity.BlockEntity tile) voidsendToDimension(net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim) voidvoidsendToPlayer(@Nullable net.minecraft.server.level.ServerPlayer player) voidnet.minecraft.network.protocol.Packet<?> net.minecraft.network.protocol.common.custom.CustomPacketPayloadnet.minecraft.network.protocol.Packet<?> writeBoolean(boolean b) Writes a boolean to the stream.writeBooleans(boolean[] b) Writes an array to the stream, including its length.writeBooleans(boolean[] b, int off, int len) Writes an array to the stream, including its length.writeByte(int p0) Writes a byte to the stream.writeByteBuf(io.netty.buffer.ByteBuf buf) Writes aByteBufto the stream, including its length.writeByteBuffer(ByteBuffer buffer) Writes aByteBufferto the stream.writeBytes(byte[] b) Writes an array to the stream, including its length.writeBytes(byte[] b, int off, int len) Writes an array to the stream, including its length.writeChar(int c) Writes a char to the stream.writeCharBuffer(CharBuffer buffer) Writes aCharBufferto the stream.writeChars(char[] c) Writes an array to the stream, including its length.writeChars(char[] c, int off, int len) Writes an array to the stream, including its length.writeCompoundNBT(net.minecraft.nbt.CompoundTag tag) Writes aCompoundTagto the stream.writeCuboid(Cuboid6 cuboid) Writes aCuboid6to the stream.writeDirection(net.minecraft.core.Direction dir) Writes aDirectionto the stream.writeDouble(double p0) Writes a double to the stream.writeDoubleBuffer(DoubleBuffer buffer) Writes aDoubleBufferto the stream.writeDoubles(double[] d) Writes an array to the stream, including its length.writeDoubles(double[] d, int off, int len) Writes an array to the stream, including its length.Writes anEnumvalue to the stream.writeFloat(float f) Writes a float to the stream.writeFloatBuffer(FloatBuffer buffer) Writes aFloatBufferto the stream.writeFloats(float[] f) Writes an array to the stream, including its length.writeFloats(float[] f, int off, int len) Writes an array to the stream, including its length.writeFluidStack(net.neoforged.neoforge.fluids.FluidStack stack) Writes aFluidStackto the stream.writeInt(int p0) Writes a int to the stream.writeIntBuffer(IntBuffer buffer) Writes aIntBufferto the stream.writeInts(int[] i) Writes an array to the stream, including its length.writeInts(int[] i, int off, int len) Writes an array to the stream, including its length.writeItemStack(net.minecraft.world.item.ItemStack stack) Writes anItemStackto the stream.writeLong(long l) Writes a long to the stream.writeLongBuffer(LongBuffer buffer) Writes aLongBufferto the stream.writeLongs(long[] l) Writes an array to the stream, including its length.writeLongs(long[] l, int off, int len) Writes an array to the stream, including its length.writeNullableCompoundNBT(@Nullable net.minecraft.nbt.CompoundTag tag) Writes a NullableCompoundTagto the stream.writePos(net.minecraft.core.BlockPos pos) Writes aBlockPosto the stream.<T> PacketCustomwriteRegistryId(net.minecraft.core.Registry<T> registry, net.minecraft.resources.ResourceLocation entry) Writes the id associated with the given name to the stream encoding both the registry name and object's id.<T> PacketCustomwriteRegistryId(net.minecraft.core.Registry<T> registry, T entry) Writes the given object to the stream encoding both the registry name and object's id.<T> PacketCustomwriteRegistryIdDirect(net.minecraft.core.Registry<T> registry, net.minecraft.resources.ResourceLocation entry) Writes the id associated with the given name to the stream.<T> PacketCustomwriteRegistryIdDirect(net.minecraft.core.Registry<T> registry, T entry) Writes a forge registry object's id to the stream.writeResourceLocation(net.minecraft.resources.ResourceLocation loc) Writes aResourceLocationto the stream.writeShort(int p0) Writes a short to the stream.writeShortBuffer(ShortBuffer buffer) Writes aShortBufferto the stream.writeShorts(short[] s) Writes an array to the stream, including its length.writeShorts(short[] s, int off, int len) Writes an array to the stream, including its length.Writes a UTF-8 EncodedStringto the stream.writeString(String s, int maxLen) Writes a UTF-8 EncodedStringto the stream.writeTextComponent(net.minecraft.network.chat.Component component) Writes aComponentto the stream.Writes aUUIDto the stream.writeVarInt(int i) Writes a Variable length int.writeVarInts(int[] i) Writes an array of Variable length ints to the stream.writeVarInts(int[] i, int off, int len) Writes an array of Variable length ints to the stream.writeVarLong(long l) Writes a Variable length long.writeVarLongs(long[] l) Writes an array of Variable length longs to the stream.writeVarLongs(long[] l, int off, int len) Writes an array of Variable length longs to the stream.writeVec3d(net.minecraft.world.phys.Vec3 vec) Writes aVec3to the stream.writeVec3i(net.minecraft.core.Vec3i vec) Writes aVec3ito the stream.writeVector(Vector3 vec) Writes aVector3to the stream.Methods inherited from class codechicken.lib.data.MCDataByteBuf
fromTag, readBoolean, readByte, readChar, readDouble, readFloat, readFromNBT, readInt, readLong, readShort, readUByte, readUShort, readWithCodec, readWithRegistryCodec, toFriendlyByteBuf, toRegistryFriendlyByteBuf, toTag, writeToNBT, writeWithCodec, writeWithRegistryCodecMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface codechicken.lib.data.MCDataInput
readBooleans, readByteBuf, readByteBuffer, readBytes, readCharBuffer, readChars, readCompoundNBT, readCuboid, readDirection, readDoubleBuffer, readDoubles, readEnum, readFloatBuffer, readFloats, readFluidStack, readIntBuffer, readInts, readItemStack, readLongBuffer, readLongs, readNullableCompoundNBT, readPos, readRegistryId, readRegistryIdDirect, readResourceLocation, readShortBuffer, readShorts, readSignedVarInt, readSignedVarInts, readSignedVarLong, readSignedVarLongs, readString, readTextComponent, readUUID, readVarInt, readVarInts, readVarLong, readVarLongs, readVec3d, readVec3f, readVec3i, readVector, toDataInput, toInputStreamMethods inherited from interface codechicken.lib.data.MCDataOutput
toDataOutput, toOutputStream, writeSignedVarInt, writeSignedVarInts, writeSignedVarInts, writeSignedVarLong, writeSignedVarLongs, writeSignedVarLongs, writeVec3f
-
Constructor Details
-
PacketCustom
public PacketCustom(net.minecraft.resources.ResourceLocation channel, int type, @Nullable @Nullable net.minecraft.core.RegistryAccess registryAccess)
-
-
Method Details
-
isInbound
public boolean isInbound() -
getType
public int getType() -
getChannel
public net.minecraft.resources.ResourceLocation getChannel() -
toCustomPayload
public net.minecraft.network.protocol.common.custom.CustomPacketPayload toCustomPayload() -
toClientPacket
public net.minecraft.network.protocol.Packet<?> toClientPacket() -
sendToPlayer
public void sendToPlayer(@Nullable @Nullable net.minecraft.server.level.ServerPlayer player) -
sendToAllPlayers
public void sendToAllPlayers() -
sendToAllAround
public void sendToAllAround(net.minecraft.core.BlockPos pos, double range, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim) -
sendToAllAround
public void sendToAllAround(double x, double y, double z, double range, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim) -
sendToDimension
public void sendToDimension(net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim) -
sendToChunk
public void sendToChunk(net.minecraft.world.level.block.entity.BlockEntity tile) -
sendToChunk
public void sendToChunk(net.minecraft.server.level.ServerLevel level, net.minecraft.core.BlockPos pos) -
sendToChunk
public void sendToChunk(net.minecraft.server.level.ServerLevel level, int chunkX, int chunkZ) -
sendToChunk
public void sendToChunk(net.minecraft.server.level.ServerLevel level, net.minecraft.world.level.ChunkPos pos) -
sendToOps
public void sendToOps() -
toServerPacket
public net.minecraft.network.protocol.Packet<?> toServerPacket() -
sendToServer
public void sendToServer() -
writeByte
Description copied from interface:MCDataOutputWrites a byte to the stream.- Specified by:
writeBytein interfaceMCDataOutput- Overrides:
writeBytein classMCDataByteBuf- Parameters:
p0- The byte.- Returns:
- The same stream.
-
writeChar
Description copied from interface:MCDataOutputWrites a char to the stream.- Specified by:
writeCharin interfaceMCDataOutput- Overrides:
writeCharin classMCDataByteBuf- Parameters:
c- The char.- Returns:
- The same stream.
-
writeShort
Description copied from interface:MCDataOutputWrites a short to the stream.- Specified by:
writeShortin interfaceMCDataOutput- Overrides:
writeShortin classMCDataByteBuf- Parameters:
p0- The short.- Returns:
- The same stream.
-
writeInt
Description copied from interface:MCDataOutputWrites a int to the stream.- Specified by:
writeIntin interfaceMCDataOutput- Overrides:
writeIntin classMCDataByteBuf- Parameters:
p0- The int.- Returns:
- The same stream.
-
writeLong
Description copied from interface:MCDataOutputWrites a long to the stream.- Specified by:
writeLongin interfaceMCDataOutput- Overrides:
writeLongin classMCDataByteBuf- Parameters:
l- The long.- Returns:
- The same stream.
-
writeFloat
Description copied from interface:MCDataOutputWrites a float to the stream.- Specified by:
writeFloatin interfaceMCDataOutput- Overrides:
writeFloatin classMCDataByteBuf- Parameters:
f- The float.- Returns:
- The same stream.
-
writeDouble
Description copied from interface:MCDataOutputWrites a double to the stream.- Specified by:
writeDoublein interfaceMCDataOutput- Overrides:
writeDoublein classMCDataByteBuf- Parameters:
p0- The double.- Returns:
- The same stream.
-
writeBoolean
Description copied from interface:MCDataOutputWrites a boolean to the stream.- Specified by:
writeBooleanin interfaceMCDataOutput- Overrides:
writeBooleanin classMCDataByteBuf- Parameters:
b- The boolean.- Returns:
- The same stream.
-
writeBytes
Description copied from interface:MCDataOutputWrites an array to the stream, including its length. First writes the arrays length as a varInt, followed by the array data.- Parameters:
b- The array.- Returns:
- The same stream.
-
writeBytes
Description copied from interface:MCDataOutputWrites an array to the stream, including its length. First writes the arrays length as a varInt, followed by the array data.- Parameters:
b- The array.off- An offset into the array to start reading from.len- How many elements to read.- Returns:
- The same stream.
-
writeChars
Description copied from interface:MCDataOutputWrites an array to the stream, including its length. First writes the arrays length as a varInt, followed by the array data.- Parameters:
c- The array.- Returns:
- The same stream.
-
writeChars
Description copied from interface:MCDataOutputWrites an array to the stream, including its length. First writes the arrays length as a varInt, followed by the array data.- Parameters:
c- The array.off- An offset into the array to start reading from.len- How many elements to read.- Returns:
- The same stream.
-
writeShorts
Description copied from interface:MCDataOutputWrites an array to the stream, including its length. First writes the arrays length as a varInt, followed by the array data.- Parameters:
s- The array.- Returns:
- The same stream.
-
writeShorts
Description copied from interface:MCDataOutputWrites an array to the stream, including its length. First writes the arrays length as a varInt, followed by the array data.- Parameters:
s- The array.off- An offset into the array to start reading from.len- How many elements to read.- Returns:
- The same stream.
-
writeInts
Description copied from interface:MCDataOutputWrites an array to the stream, including its length. First writes the arrays length as a varInt, followed by the array data.- Parameters:
i- The array.- Returns:
- The same stream.
-
writeInts
Description copied from interface:MCDataOutputWrites an array to the stream, including its length. First writes the arrays length as a varInt, followed by the array data.- Parameters:
i- The array.off- An offset into the array to start reading from.len- How many elements to read.- Returns:
- The same stream.
-
writeLongs
Description copied from interface:MCDataOutputWrites an array to the stream, including its length. First writes the arrays length as a varInt, followed by the array data.- Parameters:
l- The array.- Returns:
- The same stream.
-
writeLongs
Description copied from interface:MCDataOutputWrites an array to the stream, including its length. First writes the arrays length as a varInt, followed by the array data.- Parameters:
l- The array.off- An offset into the array to start reading from.len- How many elements to read.- Returns:
- The same stream.
-
writeFloats
Description copied from interface:MCDataOutputWrites an array to the stream, including its length. First writes the arrays length as a varInt, followed by the array data.- Parameters:
f- The array.- Returns:
- The same stream.
-
writeFloats
Description copied from interface:MCDataOutputWrites an array to the stream, including its length. First writes the arrays length as a varInt, followed by the array data.- Parameters:
f- The array.off- An offset into the array to start reading from.len- How many elements to read.- Returns:
- The same stream.
-
writeDoubles
Description copied from interface:MCDataOutputWrites an array to the stream, including its length. First writes the arrays length as a varInt, followed by the array data.- Parameters:
d- The array.- Returns:
- The same stream.
-
writeDoubles
Description copied from interface:MCDataOutputWrites an array to the stream, including its length. First writes the arrays length as a varInt, followed by the array data.- Parameters:
d- The array.off- An offset into the array to start reading from.len- How many elements to read.- Returns:
- The same stream.
-
writeBooleans
Description copied from interface:MCDataOutputWrites an array to the stream, including its length. First writes the arrays length as a varInt, followed by the array data.- Parameters:
b- The array.- Returns:
- The same stream.
-
writeBooleans
Description copied from interface:MCDataOutputWrites an array to the stream, including its length. First writes the arrays length as a varInt, followed by the array data.- Parameters:
b- The array.off- An offset into the array to start reading from.len- How many elements to read.- Returns:
- The same stream.
-
append
Description copied from interface:MCDataOutputAppends the content of the array to the end of this buffer.- Parameters:
bytes- The array.- Returns:
- The same stream.
-
writeVarInt
Description copied from interface:MCDataOutputWrites a Variable length int. Doesn't handle Signed ints well, they end up as 5 bytes, instead of 4, UseMCDataOutput.writeSignedVarInt(int)if you require numbers<= -1- Parameters:
i- The int.- Returns:
- The same stream.
-
writeVarLong
Description copied from interface:MCDataOutputWrites a Variable length long. Doesn't handle Signed longs well, they end up as 10 bytes, instead of 8, UseMCDataOutput.writeSignedVarLong(long)if you require numbers<= -1- Parameters:
l- The long.- Returns:
- The same stream.
-
writeVarInts
Description copied from interface:MCDataOutputWrites an array of Variable length ints to the stream. First writes the arrays length as a varInt, followed by the array data.- Parameters:
i- The array.- Returns:
- The same stream.
-
writeVarInts
Description copied from interface:MCDataOutputWrites an array of Variable length ints to the stream. First writes the arrays length as a varInt, followed by the array data.- Parameters:
i- The array.off- An offset into the array to start reading from.len- How many elements to read.- Returns:
- The same stream.
-
writeVarLongs
Description copied from interface:MCDataOutputWrites an array of Variable length longs to the stream. First writes the arrays length as a varInt, followed by the array data.- Parameters:
l- The array.- Returns:
- The same stream.
-
writeVarLongs
Description copied from interface:MCDataOutputWrites an array of Variable length longs to the stream. First writes the arrays length as a varInt, followed by the array data.- Parameters:
l- The array.off- An offset into the array to start reading from.len- How many elements to read.- Returns:
- The same stream.
-
writeString
Description copied from interface:MCDataOutputWrites a UTF-8 EncodedStringto the stream. Forces a length of 32767 encoded bytes.- Parameters:
s- TheString.- Returns:
- The same stream.
-
writeString
Description copied from interface:MCDataOutputWrites a UTF-8 EncodedStringto the stream.- Parameters:
s- TheString.maxLen- The maximum number of bytes to write, extra bytes will cause an EncoderException.- Returns:
- The same stream.
-
writeUUID
Description copied from interface:MCDataOutputWrites aUUIDto the stream.- Parameters:
uuid- TheUUID.- Returns:
- The same stream.
-
writeEnum
Description copied from interface:MCDataOutputWrites anEnumvalue to the stream.- Parameters:
value- TheEnumvalue to write.- Returns:
- The same stream.
-
writeByteBuffer
Description copied from interface:MCDataOutputWrites aByteBufferto the stream.- Parameters:
buffer- TheByteBuffer.- Returns:
- The same stream.
-
writeCharBuffer
Description copied from interface:MCDataOutputWrites aCharBufferto the stream.- Parameters:
buffer- TheCharBuffer.- Returns:
- The same stream.
-
writeShortBuffer
Description copied from interface:MCDataOutputWrites aShortBufferto the stream.- Parameters:
buffer- TheShortBuffer.- Returns:
- The same stream.
-
writeIntBuffer
Description copied from interface:MCDataOutputWrites aIntBufferto the stream.- Parameters:
buffer- TheIntBuffer.- Returns:
- The same stream.
-
writeLongBuffer
Description copied from interface:MCDataOutputWrites aLongBufferto the stream.- Parameters:
buffer- TheLongBuffer.- Returns:
- The same stream.
-
writeFloatBuffer
Description copied from interface:MCDataOutputWrites aFloatBufferto the stream.- Parameters:
buffer- TheFloatBuffer.- Returns:
- The same stream.
-
writeDoubleBuffer
Description copied from interface:MCDataOutputWrites aDoubleBufferto the stream.- Parameters:
buffer- TheDoubleBuffer.- Returns:
- The same stream.
-
writeVector
Description copied from interface:MCDataOutputWrites aVector3to the stream.- Parameters:
vec- TheVector3.- Returns:
- The same stream.
-
writeCuboid
Description copied from interface:MCDataOutputWrites aCuboid6to the stream.- Parameters:
cuboid- TheCuboid6- Returns:
- The same stream.
-
writeResourceLocation
Description copied from interface:MCDataOutputWrites aResourceLocationto the stream.- Parameters:
loc- TheResourceLocation.- Returns:
- The same stream.
-
writeDirection
Description copied from interface:MCDataOutputWrites aDirectionto the stream.- Parameters:
dir- TheDirection.- Returns:
- The same stream.
-
writePos
Description copied from interface:MCDataOutputWrites aBlockPosto the stream.- Parameters:
pos- TheBlockPos.- Returns:
- The same stream.
-
writeVec3i
Description copied from interface:MCDataOutputWrites aVec3ito the stream.- Parameters:
vec- TheVec3i.- Returns:
- The same stream.
-
writeVec3d
Description copied from interface:MCDataOutputWrites aVec3to the stream.- Parameters:
vec- TheVec3.- Returns:
- The same stream.
-
writeCompoundNBT
Description copied from interface:MCDataOutputWrites aCompoundTagto the stream.- Parameters:
tag- TheCompoundTag.- Returns:
- The same stream.
-
writeNullableCompoundNBT
Description copied from interface:MCDataOutputWrites a NullableCompoundTagto the stream.- Parameters:
tag- TheCompoundTagornull.- Returns:
- The same stream.
-
writeFluidStack
Description copied from interface:MCDataOutputWrites aFluidStackto the stream.- Parameters:
stack- TheFluidStack.- Returns:
- The same stream.
-
writeItemStack
Description copied from interface:MCDataOutputWrites anItemStackto the stream.It should also be noted that this implementation writes the
ItemStack.getCount()as a varInt opposed to a byte, as that is favourable in some cases.- Parameters:
stack- TheItemStack.- Returns:
- The same stream.
-
writeTextComponent
Description copied from interface:MCDataOutputWrites aComponentto the stream.- Parameters:
component- TheComponent.- Returns:
- The same stream.
-
writeRegistryIdDirect
Description copied from interface:MCDataOutputWrites a forge registry object's id to the stream. This method does not encode the Registry name to the packet, only the object's id.- Parameters:
registry- The registry that ownsentry.entry- The object to write to the stream.- Returns:
- The same stream.
-
writeRegistryIdDirect
public <T> PacketCustom writeRegistryIdDirect(net.minecraft.core.Registry<T> registry, net.minecraft.resources.ResourceLocation entry) Description copied from interface:MCDataOutputWrites the id associated with the given name to the stream. This method does not encode the Registry name to the packet, only the id.- Parameters:
registry- The registry that ownsentry.entry- The name of the registry object to write.- Returns:
- The same stream.
-
writeRegistryId
Description copied from interface:MCDataOutputWrites the given object to the stream encoding both the registry name and object's id.- Parameters:
registry- The registry that ownsentry.entry- The object to write to the stream.- Returns:
- The same stream.
-
writeRegistryId
public <T> PacketCustom writeRegistryId(net.minecraft.core.Registry<T> registry, net.minecraft.resources.ResourceLocation entry) Description copied from interface:MCDataOutputWrites the id associated with the given name to the stream encoding both the registry name and object's id.- Parameters:
registry- The registry that ownsentry.entry- The name of the registry object to write.- Returns:
- The same stream.
-
writeByteBuf
Description copied from interface:MCDataOutputWrites aByteBufto the stream, including its length. First writes the arrays length as a varInt, followed by the ByteBuf data.- Parameters:
buf- TheByteBuf.- Returns:
- The same stream.
-
append
Description copied from interface:MCDataOutputAppends aByteBufto the end of this stream.- Parameters:
buf- TheByteBufto append.- Returns:
- The same stream.
-