Interface Palette
public sealed interface Palette
Represents a palette used to store blocks and biomes.
0 is the default value.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interface
static interface
static interface
static enum
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final NetworkBuffer.Type
<Palette> -
Method Summary
Modifier and TypeMethodDescriptionboolean
any
(int value) Checks if the palette contains the given value.static Palette
biomes()
static Palette
biomes
(int bitsPerEntry) static NetworkBuffer.Type
<Palette> biomeSerializer
(int biomeCount) int
Returns the number of bits used per entry.static Palette
blocks()
static Palette
blocks
(int bitsPerEntry) @NotNull Palette
clone()
boolean
Compare palettes content independently of their storage format.void
Efficiently copies values from another palette starting at position (0, 0, 0).void
Efficiently copies values from another palette with the given offset.int
count()
Returns the number of entries in this palette.int
count
(int value) Returns the number of entries in this palette that match the given value.int
static Palette
empty
(int dimension, int minBitsPerEntry, int maxBitsPerEntry, int directBits) void
fill
(int value) int
get
(int x, int y, int z) void
getAll
(@NotNull Palette.EntryConsumer consumer) void
getAllPresent
(@NotNull Palette.EntryConsumer consumer) long @Nullable []
Gets the value array if it has one, otherwise returns null (i.e.default int
maxSize()
Returns the maximum number of entries in this palette.void
offset
(int offset) void
optimize
(Palette.Optimization focus) int
paletteIndexToValue
(int value) void
replace
(int oldValue, int newValue) void
replace
(int x, int y, int z, @NotNull IntUnaryOperator operator) void
replaceAll
(@NotNull Palette.EntryFunction function) static NetworkBuffer.Type
<Palette> serializer
(int dimension, int minIndirect, int maxIndirect, int directBits) void
set
(int x, int y, int z, int value) void
setAll
(@NotNull Palette.EntrySupplier supplier) int
Gets the single value of this palette if it is a single value palette, otherwise returns -1.static Palette
sized
(int dimension, int minBitsPerEntry, int maxBitsPerEntry, int directBits, int bitsPerEntry) int
valueToPaletteIndex
(int value)
-
Field Details
-
BLOCK_DIMENSION
static final int BLOCK_DIMENSION- See Also:
-
BLOCK_PALETTE_MIN_BITS
static final int BLOCK_PALETTE_MIN_BITS- See Also:
-
BLOCK_PALETTE_MAX_BITS
static final int BLOCK_PALETTE_MAX_BITS- See Also:
-
BLOCK_PALETTE_DIRECT_BITS
static final int BLOCK_PALETTE_DIRECT_BITS- See Also:
-
BIOME_DIMENSION
static final int BIOME_DIMENSION- See Also:
-
BIOME_PALETTE_MIN_BITS
static final int BIOME_PALETTE_MIN_BITS- See Also:
-
BIOME_PALETTE_MAX_BITS
static final int BIOME_PALETTE_MAX_BITS- See Also:
-
BIOME_PALETTE_DIRECT_BITS
@Internal static final int BIOME_PALETTE_DIRECT_BITS- See Also:
-
BLOCK_SERIALIZER
-
-
Method Details
-
blocks
-
biomes
-
blocks
-
biomes
-
empty
-
sized
static Palette sized(int dimension, int minBitsPerEntry, int maxBitsPerEntry, int directBits, int bitsPerEntry) -
get
int get(int x, int y, int z) -
getAll
-
getAllPresent
-
set
void set(int x, int y, int z, int value) -
fill
void fill(int value) -
offset
void offset(int offset) -
replace
void replace(int oldValue, int newValue) -
setAll
-
replace
-
replaceAll
-
copyFrom
Efficiently copies values from another palette with the given offset.Both palettes must have the same dimension.
- Parameters:
source
- the source palette to copy fromoffsetX
- the X offset to apply when copyingoffsetY
- the Y offset to apply when copyingoffsetZ
- the Z offset to apply when copying
-
copyFrom
Efficiently copies values from another palette starting at position (0, 0, 0).Both palettes must have the same dimension.
This is a convenience method equivalent to calling
copyFrom(source, 0, 0, 0)
.- Parameters:
source
- the source palette to copy from
-
count
int count()Returns the number of entries in this palette. -
count
int count(int value) Returns the number of entries in this palette that match the given value.- Parameters:
value
- the value to count- Returns:
- the number of entries matching the value
-
any
boolean any(int value) Checks if the palette contains the given value.- Parameters:
value
- the value to check- Returns:
- true if the palette contains the value, false otherwise
-
bitsPerEntry
int bitsPerEntry()Returns the number of bits used per entry. -
dimension
int dimension() -
maxSize
default int maxSize()Returns the maximum number of entries in this palette. -
optimize
-
compare
Compare palettes content independently of their storage format.- Parameters:
palette
- the palette to compare with- Returns:
- true if the palettes are equivalent, false otherwise
-
clone
-
paletteIndexToValue
@Internal int paletteIndexToValue(int value) -
valueToPaletteIndex
@Internal int valueToPaletteIndex(int value) -
singleValue
@Internal int singleValue()Gets the single value of this palette if it is a single value palette, otherwise returns -1. -
indexedValues
@Internal long @Nullable [] indexedValues()Gets the value array if it has one, otherwise returns null (i.e. single value palette). -
biomeSerializer
-
serializer
static NetworkBuffer.Type<Palette> serializer(int dimension, int minIndirect, int maxIndirect, int directBits)
-