Package net.minecraft.world.chunk
Class PalettedContainer<T>
java.lang.Object
net.minecraft.world.chunk.PalettedContainer<T>
- All Implemented Interfaces:
PaletteResizeListener<T>
,ReadableContainer<T>
public class PalettedContainer<T>
extends Object
implements PaletteResizeListener<T>, ReadableContainer<T>
A paletted container stores objects in 3D voxels as small integer indices,
governed by "palettes" that map between these objects and indices.
- See Also:
- Mappings:
Namespace Name named net/minecraft/world/chunk/PalettedContainer
intermediary net/minecraft/class_2841
official dus
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
A counter that receives a palette entry and its number of occurrences in the container.private static final record
Runtime representation of data in a paletted container.private static final record
A palette data provider constructs an empty data for a paletted container given a palette provider and a desired entry size in bits.static class
A palette provider determines what type of palette to choose given the bits used to represent each element.Nested classes/interfaces inherited from interface net.minecraft.world.chunk.ReadableContainer
ReadableContainer.Reader<T,
C extends ReadableContainer<T>>, ReadableContainer.Serialized<T> -
Field Summary
Modifier and TypeFieldDescriptionprivate PalettedContainer.Data
<T> private final PaletteResizeListener
<T> private static final int
private final IndexedIterable
<T> private final LockHelper
private final PalettedContainer.PaletteProvider
-
Constructor Summary
ModifierConstructorDescriptionprivate
PalettedContainer
(IndexedIterable<T> idList, PalettedContainer.PaletteProvider paletteProvider, PalettedContainer.Data<T> data) PalettedContainer
(IndexedIterable<T> idList, PalettedContainer.PaletteProvider paletteProvider, PalettedContainer.DataProvider<T> dataProvider, PaletteStorage storage, List<T> paletteEntries) PalettedContainer
(IndexedIterable<T> idList, T object, PalettedContainer.PaletteProvider paletteProvider) -
Method Summary
Modifier and TypeMethodDescriptionprivate static <T> void
applyEach
(int[] is, IntUnaryOperator applier) Appliesapplier
to each value ofis
, modifying the array.copy()
void
count
(PalettedContainer.Counter<T> counter) private static <T,
C extends ReadableContainer<T>>
com.mojang.serialization.Codec<C> createCodec
(IndexedIterable<T> idList, com.mojang.serialization.Codec<T> entryCodec, PalettedContainer.PaletteProvider provider, T defaultValue, ReadableContainer.Reader<T, C> reader) Creates a codec for a paletted container with a specific palette provider.static <T> com.mojang.serialization.Codec
<PalettedContainer<T>> createPalettedContainerCodec
(IndexedIterable<T> idList, com.mojang.serialization.Codec<T> entryCodec, PalettedContainer.PaletteProvider paletteProvider, T defaultValue) static <T> com.mojang.serialization.Codec
<ReadableContainer<T>> createReadableContainerCodec
(IndexedIterable<T> idList, com.mojang.serialization.Codec<T> entryCodec, PalettedContainer.PaletteProvider paletteProvider, T defaultValue) void
forEachValue
(Consumer<T> action) protected T
get
(int index) get
(int x, int y, int z) private PalettedContainer.Data
<T> getCompatibleData
(@Nullable PalettedContainer.Data<T> previousData, int bits) Returns a compatible data object for the given entrybits
size.int
boolean
Returnstrue
if any object in this container's palette matches this predicate.void
lock()
Acquires the semaphore on this container, and crashes if it cannot be acquired.int
Callback for a palette's request to resize to at leastnewBits
for each entry and to update the storage correspondingly in order to accommodate the new object.private static <T> com.mojang.serialization.DataResult
<PalettedContainer<T>> read
(IndexedIterable<T> idList, PalettedContainer.PaletteProvider paletteProvider, ReadableContainer.Serialized<T> serialized) void
readPacket
(PacketByteBuf buf) Reads data from the packet byte buffer into this container.serialize
(IndexedIterable<T> idList, PalettedContainer.PaletteProvider paletteProvider) void
private void
slice()
private T
swapUnsafe
(int x, int y, int z, T value) void
unlock()
Releases the semaphore on this container.void
writePacket
(PacketByteBuf buf) Writes this container to the packet byte buffer.
-
Field Details
-
field_34557
private static final int field_34557- See Also:
- Mappings:
Namespace Name Mixin selector named field_34557
Lnet/minecraft/world/chunk/PalettedContainer;field_34557:I
intermediary field_34557
Lnet/minecraft/class_2841;field_34557:I
official a
Ldus;a:I
-
dummyListener
- Mappings:
Namespace Name Mixin selector named dummyListener
Lnet/minecraft/world/chunk/PalettedContainer;dummyListener:Lnet/minecraft/world/chunk/PaletteResizeListener;
intermediary field_34558
Lnet/minecraft/class_2841;field_34558:Lnet/minecraft/class_2835;
official b
Ldus;b:Ldur;
-
idList
- Mappings:
Namespace Name Mixin selector named idList
Lnet/minecraft/world/chunk/PalettedContainer;idList:Lnet/minecraft/util/collection/IndexedIterable;
intermediary field_34559
Lnet/minecraft/class_2841;field_34559:Lnet/minecraft/class_2359;
official c
Ldus;c:Ljn;
-
data
- Mappings:
Namespace Name Mixin selector named data
Lnet/minecraft/world/chunk/PalettedContainer;data:Lnet/minecraft/world/chunk/PalettedContainer$Data;
intermediary field_34560
Lnet/minecraft/class_2841;field_34560:Lnet/minecraft/class_2841$class_6561;
official d
Ldus;d:Ldus$c;
-
paletteProvider
- Mappings:
Namespace Name Mixin selector named paletteProvider
Lnet/minecraft/world/chunk/PalettedContainer;paletteProvider:Lnet/minecraft/world/chunk/PalettedContainer$PaletteProvider;
intermediary field_34561
Lnet/minecraft/class_2841;field_34561:Lnet/minecraft/class_2841$class_6563;
official e
Ldus;e:Ldus$d;
-
lockHelper
- Mappings:
Namespace Name Mixin selector named lockHelper
Lnet/minecraft/world/chunk/PalettedContainer;lockHelper:Lnet/minecraft/util/thread/LockHelper;
intermediary field_36300
Lnet/minecraft/class_2841;field_36300:Lnet/minecraft/class_5798;
official f
Ldus;f:Lazx;
-
-
Constructor Details
-
PalettedContainer
public PalettedContainer(IndexedIterable<T> idList, PalettedContainer.PaletteProvider paletteProvider, PalettedContainer.DataProvider<T> dataProvider, PaletteStorage storage, List<T> paletteEntries) - Mappings:
Namespace Name Mixin selector named <init>
Lnet/minecraft/world/chunk/PalettedContainer;<init>(Lnet/minecraft/util/collection/IndexedIterable;Lnet/minecraft/world/chunk/PalettedContainer$PaletteProvider;Lnet/minecraft/world/chunk/PalettedContainer$DataProvider;Lnet/minecraft/util/collection/PaletteStorage;Ljava/util/List;)V
intermediary <init>
Lnet/minecraft/class_2841;<init>(Lnet/minecraft/class_2359;Lnet/minecraft/class_2841$class_6563;Lnet/minecraft/class_2841$class_6560;Lnet/minecraft/class_6490;Ljava/util/List;)V
official <init>
Ldus;<init>(Ljn;Ldus$d;Ldus$a;Laxn;Ljava/util/List;)V
-
PalettedContainer
private PalettedContainer(IndexedIterable<T> idList, PalettedContainer.PaletteProvider paletteProvider, PalettedContainer.Data<T> data) - Mappings:
Namespace Name Mixin selector named <init>
Lnet/minecraft/world/chunk/PalettedContainer;<init>(Lnet/minecraft/util/collection/IndexedIterable;Lnet/minecraft/world/chunk/PalettedContainer$PaletteProvider;Lnet/minecraft/world/chunk/PalettedContainer$Data;)V
intermediary <init>
Lnet/minecraft/class_2841;<init>(Lnet/minecraft/class_2359;Lnet/minecraft/class_2841$class_6563;Lnet/minecraft/class_2841$class_6561;)V
official <init>
Ldus;<init>(Ljn;Ldus$d;Ldus$c;)V
-
PalettedContainer
public PalettedContainer(IndexedIterable<T> idList, T object, PalettedContainer.PaletteProvider paletteProvider) - Mappings:
Namespace Name Mixin selector named <init>
Lnet/minecraft/world/chunk/PalettedContainer;<init>(Lnet/minecraft/util/collection/IndexedIterable;Ljava/lang/Object;Lnet/minecraft/world/chunk/PalettedContainer$PaletteProvider;)V
intermediary <init>
Lnet/minecraft/class_2841;<init>(Lnet/minecraft/class_2359;Ljava/lang/Object;Lnet/minecraft/class_2841$class_6563;)V
official <init>
Ldus;<init>(Ljn;Ljava/lang/Object;Ldus$d;)V
-
-
Method Details
-
lock
public void lock()Acquires the semaphore on this container, and crashes if it cannot be acquired.- Mappings:
Namespace Name Mixin selector named lock
Lnet/minecraft/world/chunk/PalettedContainer;lock()V
intermediary method_12334
Lnet/minecraft/class_2841;method_12334()V
official a
Ldus;a()V
-
unlock
public void unlock()Releases the semaphore on this container.- Mappings:
Namespace Name Mixin selector named unlock
Lnet/minecraft/world/chunk/PalettedContainer;unlock()V
intermediary method_12335
Lnet/minecraft/class_2841;method_12335()V
official b
Ldus;b()V
-
createPalettedContainerCodec
public static <T> com.mojang.serialization.Codec<PalettedContainer<T>> createPalettedContainerCodec(IndexedIterable<T> idList, com.mojang.serialization.Codec<T> entryCodec, PalettedContainer.PaletteProvider paletteProvider, T defaultValue) - Mappings:
Namespace Name Mixin selector named createPalettedContainerCodec
Lnet/minecraft/world/chunk/PalettedContainer;createPalettedContainerCodec(Lnet/minecraft/util/collection/IndexedIterable;Lcom/mojang/serialization/Codec;Lnet/minecraft/world/chunk/PalettedContainer$PaletteProvider;Ljava/lang/Object;)Lcom/mojang/serialization/Codec;
intermediary method_44343
Lnet/minecraft/class_2841;method_44343(Lnet/minecraft/class_2359;Lcom/mojang/serialization/Codec;Lnet/minecraft/class_2841$class_6563;Ljava/lang/Object;)Lcom/mojang/serialization/Codec;
official a
Ldus;a(Ljn;Lcom/mojang/serialization/Codec;Ldus$d;Ljava/lang/Object;)Lcom/mojang/serialization/Codec;
-
createReadableContainerCodec
public static <T> com.mojang.serialization.Codec<ReadableContainer<T>> createReadableContainerCodec(IndexedIterable<T> idList, com.mojang.serialization.Codec<T> entryCodec, PalettedContainer.PaletteProvider paletteProvider, T defaultValue) - Mappings:
Namespace Name Mixin selector named createReadableContainerCodec
Lnet/minecraft/world/chunk/PalettedContainer;createReadableContainerCodec(Lnet/minecraft/util/collection/IndexedIterable;Lcom/mojang/serialization/Codec;Lnet/minecraft/world/chunk/PalettedContainer$PaletteProvider;Ljava/lang/Object;)Lcom/mojang/serialization/Codec;
intermediary method_44347
Lnet/minecraft/class_2841;method_44347(Lnet/minecraft/class_2359;Lcom/mojang/serialization/Codec;Lnet/minecraft/class_2841$class_6563;Ljava/lang/Object;)Lcom/mojang/serialization/Codec;
official b
Ldus;b(Ljn;Lcom/mojang/serialization/Codec;Ldus$d;Ljava/lang/Object;)Lcom/mojang/serialization/Codec;
-
createCodec
private static <T,C extends ReadableContainer<T>> com.mojang.serialization.Codec<C> createCodec(IndexedIterable<T> idList, com.mojang.serialization.Codec<T> entryCodec, PalettedContainer.PaletteProvider provider, T defaultValue, ReadableContainer.Reader<T, C> reader) Creates a codec for a paletted container with a specific palette provider.- Parameters:
entryCodec
- the codec for each entry in the paletteprovider
- the palette provider that controls how the data are serialized and what types of palette are used for what entry bit sizes- Returns:
- the created codec
- Mappings:
Namespace Name Mixin selector named createCodec
Lnet/minecraft/world/chunk/PalettedContainer;createCodec(Lnet/minecraft/util/collection/IndexedIterable;Lcom/mojang/serialization/Codec;Lnet/minecraft/world/chunk/PalettedContainer$PaletteProvider;Ljava/lang/Object;Lnet/minecraft/world/chunk/ReadableContainer$Reader;)Lcom/mojang/serialization/Codec;
intermediary method_38298
Lnet/minecraft/class_2841;method_38298(Lnet/minecraft/class_2359;Lcom/mojang/serialization/Codec;Lnet/minecraft/class_2841$class_6563;Ljava/lang/Object;Lnet/minecraft/class_7522$class_7523;)Lcom/mojang/serialization/Codec;
official a
Ldus;a(Ljn;Lcom/mojang/serialization/Codec;Ldus$d;Ljava/lang/Object;Ldut$b;)Lcom/mojang/serialization/Codec;
-
getCompatibleData
private PalettedContainer.Data<T> getCompatibleData(@Nullable @Nullable PalettedContainer.Data<T> previousData, int bits) Returns a compatible data object for the given entrybits
size. This may return a new data object or returnpreviousData
if it can be reused.- Parameters:
previousData
- the previous data, may be reused if suitablebits
- the number of bits each entry uses- Returns:
- a compatible data object for the given entry
bits
size - Mappings:
Namespace Name Mixin selector named getCompatibleData
Lnet/minecraft/world/chunk/PalettedContainer;getCompatibleData(Lnet/minecraft/world/chunk/PalettedContainer$Data;I)Lnet/minecraft/world/chunk/PalettedContainer$Data;
intermediary method_38297
Lnet/minecraft/class_2841;method_38297(Lnet/minecraft/class_2841$class_6561;I)Lnet/minecraft/class_2841$class_6561;
official a
Ldus;a(Ldus$c;I)Ldus$c;
-
onResize
Callback for a palette's request to resize to at leastnewBits
for each entry and to update the storage correspondingly in order to accommodate the new object. After the resize is completed in this method, returns the ID assigned to theobject
in the updated palette.- Specified by:
onResize
in interfacePaletteResizeListener<T>
- Returns:
- the ID for the
object
in the (possibly new) palette - Mappings:
Namespace Name Mixin selector named onResize
Lnet/minecraft/world/chunk/PaletteResizeListener;onResize(ILjava/lang/Object;)I
intermediary onResize
Lnet/minecraft/class_2835;onResize(ILjava/lang/Object;)I
official onResize
Ldur;onResize(ILjava/lang/Object;)I
-
swap
- Mappings:
Namespace Name Mixin selector named swap
Lnet/minecraft/world/chunk/PalettedContainer;swap(IIILjava/lang/Object;)Ljava/lang/Object;
intermediary method_12328
Lnet/minecraft/class_2841;method_12328(IIILjava/lang/Object;)Ljava/lang/Object;
official a
Ldus;a(IIILjava/lang/Object;)Ljava/lang/Object;
-
swapUnsafe
- Mappings:
Namespace Name Mixin selector named swapUnsafe
Lnet/minecraft/world/chunk/PalettedContainer;swapUnsafe(IIILjava/lang/Object;)Ljava/lang/Object;
intermediary method_16678
Lnet/minecraft/class_2841;method_16678(IIILjava/lang/Object;)Ljava/lang/Object;
official b
Ldus;b(IIILjava/lang/Object;)Ljava/lang/Object;
-
swap
- Mappings:
Namespace Name Mixin selector named swap
Lnet/minecraft/world/chunk/PalettedContainer;swap(ILjava/lang/Object;)Ljava/lang/Object;
intermediary method_12336
Lnet/minecraft/class_2841;method_12336(ILjava/lang/Object;)Ljava/lang/Object;
official a
Ldus;a(ILjava/lang/Object;)Ljava/lang/Object;
-
set
- Mappings:
Namespace Name Mixin selector named set
Lnet/minecraft/world/chunk/PalettedContainer;set(IIILjava/lang/Object;)V
intermediary method_35321
Lnet/minecraft/class_2841;method_35321(IIILjava/lang/Object;)V
official c
Ldus;c(IIILjava/lang/Object;)V
-
set
- Mappings:
Namespace Name Mixin selector named set
Lnet/minecraft/world/chunk/PalettedContainer;set(ILjava/lang/Object;)V
intermediary method_12322
Lnet/minecraft/class_2841;method_12322(ILjava/lang/Object;)V
official b
Ldus;b(ILjava/lang/Object;)V
-
get
- Specified by:
get
in interfaceReadableContainer<T>
- Mappings:
Namespace Name Mixin selector named get
Lnet/minecraft/world/chunk/ReadableContainer;get(III)Ljava/lang/Object;
intermediary method_12321
Lnet/minecraft/class_7522;method_12321(III)Ljava/lang/Object;
official a
Ldut;a(III)Ljava/lang/Object;
-
get
- Mappings:
Namespace Name Mixin selector named get
Lnet/minecraft/world/chunk/PalettedContainer;get(I)Ljava/lang/Object;
intermediary method_12331
Lnet/minecraft/class_2841;method_12331(I)Ljava/lang/Object;
official a
Ldus;a(I)Ljava/lang/Object;
-
forEachValue
- Specified by:
forEachValue
in interfaceReadableContainer<T>
- Mappings:
Namespace Name Mixin selector named forEachValue
Lnet/minecraft/world/chunk/ReadableContainer;forEachValue(Ljava/util/function/Consumer;)V
intermediary method_39793
Lnet/minecraft/class_7522;method_39793(Ljava/util/function/Consumer;)V
official a
Ldut;a(Ljava/util/function/Consumer;)V
-
readPacket
Reads data from the packet byte buffer into this container. Previous data in this container is discarded.- Parameters:
buf
- the packet byte buffer- Mappings:
Namespace Name Mixin selector named readPacket
Lnet/minecraft/world/chunk/PalettedContainer;readPacket(Lnet/minecraft/network/PacketByteBuf;)V
intermediary method_12326
Lnet/minecraft/class_2841;method_12326(Lnet/minecraft/class_2540;)V
official a
Ldus;a(Lwm;)V
-
writePacket
Writes this container to the packet byte buffer.- Specified by:
writePacket
in interfaceReadableContainer<T>
- Parameters:
buf
- the packet byte buffer- Mappings:
Namespace Name Mixin selector named writePacket
Lnet/minecraft/world/chunk/ReadableContainer;writePacket(Lnet/minecraft/network/PacketByteBuf;)V
intermediary method_12325
Lnet/minecraft/class_7522;method_12325(Lnet/minecraft/class_2540;)V
official b
Ldut;b(Lwm;)V
-
read
private static <T> com.mojang.serialization.DataResult<PalettedContainer<T>> read(IndexedIterable<T> idList, PalettedContainer.PaletteProvider paletteProvider, ReadableContainer.Serialized<T> serialized) - Mappings:
Namespace Name Mixin selector named read
Lnet/minecraft/world/chunk/PalettedContainer;read(Lnet/minecraft/util/collection/IndexedIterable;Lnet/minecraft/world/chunk/PalettedContainer$PaletteProvider;Lnet/minecraft/world/chunk/ReadableContainer$Serialized;)Lcom/mojang/serialization/DataResult;
intermediary method_44346
Lnet/minecraft/class_2841;method_44346(Lnet/minecraft/class_2359;Lnet/minecraft/class_2841$class_6563;Lnet/minecraft/class_7522$class_6562;)Lcom/mojang/serialization/DataResult;
official a
Ldus;a(Ljn;Ldus$d;Ldut$a;)Lcom/mojang/serialization/DataResult;
-
serialize
public ReadableContainer.Serialized<T> serialize(IndexedIterable<T> idList, PalettedContainer.PaletteProvider paletteProvider) - Specified by:
serialize
in interfaceReadableContainer<T>
- Mappings:
Namespace Name Mixin selector named serialize
Lnet/minecraft/world/chunk/ReadableContainer;serialize(Lnet/minecraft/util/collection/IndexedIterable;Lnet/minecraft/world/chunk/PalettedContainer$PaletteProvider;)Lnet/minecraft/world/chunk/ReadableContainer$Serialized;
intermediary method_44345
Lnet/minecraft/class_7522;method_44345(Lnet/minecraft/class_2359;Lnet/minecraft/class_2841$class_6563;)Lnet/minecraft/class_7522$class_6562;
official a
Ldut;a(Ljn;Ldus$d;)Ldut$a;
-
applyEach
Appliesapplier
to each value ofis
, modifying the array.- Implementation Note:
- This caches the last value to be applied and its result, so
applier
might not be called for all values. Note that this also causes the applier to not be applied for initial-1
s. - Mappings:
Namespace Name Mixin selector named applyEach
Lnet/minecraft/world/chunk/PalettedContainer;applyEach([ILjava/util/function/IntUnaryOperator;)V
intermediary method_39894
Lnet/minecraft/class_2841;method_39894([ILjava/util/function/IntUnaryOperator;)V
official a
Ldus;a([ILjava/util/function/IntUnaryOperator;)V
-
getPacketSize
public int getPacketSize()- Specified by:
getPacketSize
in interfaceReadableContainer<T>
- Mappings:
Namespace Name Mixin selector named getPacketSize
Lnet/minecraft/world/chunk/ReadableContainer;getPacketSize()I
intermediary method_12327
Lnet/minecraft/class_7522;method_12327()I
official c
Ldut;c()I
-
hasAny
Returnstrue
if any object in this container's palette matches this predicate.- Specified by:
hasAny
in interfaceReadableContainer<T>
- Returns:
true
if any object in this container's palette matches this predicate- Mappings:
Namespace Name Mixin selector named hasAny
Lnet/minecraft/world/chunk/ReadableContainer;hasAny(Ljava/util/function/Predicate;)Z
intermediary method_19526
Lnet/minecraft/class_7522;method_19526(Ljava/util/function/Predicate;)Z
official a
Ldut;a(Ljava/util/function/Predicate;)Z
-
copy
- Mappings:
Namespace Name Mixin selector named copy
Lnet/minecraft/world/chunk/PalettedContainer;copy()Lnet/minecraft/world/chunk/PalettedContainer;
intermediary method_39957
Lnet/minecraft/class_2841;method_39957()Lnet/minecraft/class_2841;
official d
Ldus;d()Ldus;
-
slice
- Specified by:
slice
in interfaceReadableContainer<T>
- Mappings:
Namespace Name Mixin selector named slice
Lnet/minecraft/world/chunk/ReadableContainer;slice()Lnet/minecraft/world/chunk/PalettedContainer;
intermediary method_44350
Lnet/minecraft/class_7522;method_44350()Lnet/minecraft/class_2841;
official e
Ldut;e()Ldus;
-
count
- Specified by:
count
in interfaceReadableContainer<T>
- Mappings:
Namespace Name Mixin selector named count
Lnet/minecraft/world/chunk/ReadableContainer;count(Lnet/minecraft/world/chunk/PalettedContainer$Counter;)V
intermediary method_21732
Lnet/minecraft/class_7522;method_21732(Lnet/minecraft/class_2841$class_4464;)V
official a
Ldut;a(Ldus$b;)V
-