Package cn.nukkit.blockproperty
Class BlockProperty<T extends Serializable>
java.lang.Object
cn.nukkit.blockproperty.BlockProperty<T>
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
ArrayBlockProperty
,BooleanBlockProperty
,IntBlockProperty
,UnsignedIntBlockProperty
@PowerNukkitOnly
@Since("1.4.0.0-PN")
@ParametersAreNonnullByDefault
public abstract class BlockProperty<T extends Serializable>
extends Object
implements Serializable
- See Also:
-
Constructor Summary
ConstructorDescriptionBlockProperty
(String name, boolean exportedToItem, int bitSize, String persistenceName) -
Method Summary
Modifier and TypeMethodDescriptionabstract BlockProperty<T>
copy()
abstract BlockProperty<T>
exportingToItems
(boolean exportedToItem) int
boolean
int
abstract T
int
getIntValue
(int currentMeta, int bitOffset) int
getIntValue
(long currentMeta, int bitOffset) int
getIntValue
(BigInteger currentMeta, int bitOffset) abstract int
getIntValueForMeta
(int meta) abstract int
getMetaForPersistenceValue
(String persistenceValue) abstract int
getMetaForValue
(T value) final int
getMetaFromBigInt
(BigInteger currentMeta, int bitOffset) final int
getMetaFromInt
(int currentMeta, int bitOffset) final int
getMetaFromLong
(long currentMeta, int bitOffset) getName()
getPersistenceValue
(int currentMeta, int bitOffset) getPersistenceValue
(long currentMeta, int bitOffset) getPersistenceValue
(BigInteger currentMeta, int bitOffset) abstract String
getPersistenceValueForMeta
(int meta) getValue
(int currentMeta, int bitOffset) getValue
(long currentBigMeta, int bitOffset) getValue
(BigInteger currentHugeMeta, int bitOffset) abstract T
getValueForMeta
(int meta) boolean
isDefaultBooleanValue
(boolean value) boolean
isDefaultIntValue
(int value) final boolean
isDefaultPersistentValue
(String value) abstract boolean
isDefaultValue
(T value) boolean
int
long
setValue
(BigInteger currentHugeMeta, int bitOffset, T newValue) toString()
protected void
validateDirectly
(T value) final void
validateMeta
(int meta, int offset) final void
validateMeta
(long meta, int offset) final void
validateMeta
(BigInteger meta, int offset) protected abstract void
validateMetaDirectly
(int meta)
-
Constructor Details
-
BlockProperty
@PowerNukkitOnly @Since("1.4.0.0-PN") public BlockProperty(String name, boolean exportedToItem, int bitSize, String persistenceName) - Throws:
IllegalArgumentException
- If the bit size is negative
-
-
Method Details
-
setValue
@PowerNukkitOnly @Since("1.4.0.0-PN") public int setValue(int currentMeta, int bitOffset, @Nullable T newValue) - Throws:
IllegalArgumentException
- If the offset is negative or would cause memory overflowInvalidBlockPropertyValueException
- If the new value is not accepted by this property
-
setValue
@PowerNukkitOnly @Since("1.4.0.0-PN") public long setValue(long currentBigMeta, int bitOffset, @Nullable T newValue) - Throws:
InvalidBlockPropertyValueException
- If the new value is not accepted by this propertyIllegalArgumentException
- If the offset is negative or would cause memory overflow
-
setValue
@PowerNukkitOnly @Since("1.4.0.0-PN") public BigInteger setValue(BigInteger currentHugeMeta, int bitOffset, @Nullable T newValue) - Throws:
InvalidBlockPropertyValueException
- If the new value is not accepted by this propertyIllegalArgumentException
- If the offset is negative or would cause memory overflow
-
getMetaFromInt
@PowerNukkitOnly @Since("1.4.0.0-PN") public final int getMetaFromInt(int currentMeta, int bitOffset) - Throws:
IllegalArgumentException
- If the offset is negative or would cause memory overflow
-
getMetaFromLong
@PowerNukkitOnly @Since("1.4.0.0-PN") public final int getMetaFromLong(long currentMeta, int bitOffset) - Throws:
IllegalArgumentException
- If the offset is negative or would cause memory overflow
-
getMetaFromBigInt
@PowerNukkitOnly @Since("1.4.0.0-PN") public final int getMetaFromBigInt(BigInteger currentMeta, int bitOffset) - Throws:
IllegalArgumentException
- If the offset is negative or would cause memory overflow
-
getValue
- Throws:
InvalidBlockPropertyMetaException
- If the meta contains invalid dataIllegalArgumentException
- If the offset is negative or would cause memory overflow
-
getValue
@PowerNukkitOnly @Since("1.4.0.0-PN") @Nonnull public T getValue(long currentBigMeta, int bitOffset) - Throws:
InvalidBlockPropertyMetaException
- If the meta contains invalid dataIllegalArgumentException
- If the offset is negative or would cause memory overflow
-
getValue
@PowerNukkitOnly @Since("1.4.0.0-PN") @Nonnull public T getValue(BigInteger currentHugeMeta, int bitOffset) - Throws:
InvalidBlockPropertyMetaException
- If the meta contains invalid dataIllegalArgumentException
- If the offset is negative or would cause memory overflow
-
getIntValue
- Throws:
InvalidBlockPropertyMetaException
- If the meta contains invalid dataIllegalArgumentException
- If the offset is negative or would cause memory overflow
-
getIntValue
- Throws:
InvalidBlockPropertyMetaException
- If the meta contains invalid dataIllegalArgumentException
- If the offset is negative or would cause memory overflow
-
getIntValue
- Throws:
InvalidBlockPropertyMetaException
- If the meta contains invalid dataIllegalArgumentException
- If the offset is negative or would cause memory overflow
-
getPersistenceValue
@PowerNukkitOnly @Since("1.4.0.0-PN") @Nonnull public String getPersistenceValue(int currentMeta, int bitOffset) - Throws:
InvalidBlockPropertyMetaException
- If the meta contains invalid dataIllegalArgumentException
- If the offset is negative or would cause memory overflow
-
getPersistenceValue
@PowerNukkitOnly @Since("1.4.0.0-PN") @Nonnull public String getPersistenceValue(long currentMeta, int bitOffset) - Throws:
InvalidBlockPropertyMetaException
- If the meta contains invalid dataIllegalArgumentException
- If the offset is negative or would cause memory overflow
-
getPersistenceValue
@PowerNukkitOnly @Since("1.4.0.0-PN") @Nonnull public String getPersistenceValue(BigInteger currentMeta, int bitOffset) - Throws:
InvalidBlockPropertyMetaException
- If the meta contains invalid dataIllegalArgumentException
- If the offset is negative or would cause memory overflow
-
getMetaForValue
- Throws:
InvalidBlockPropertyValueException
- If the value is invalid for this property
-
getValueForMeta
- Throws:
InvalidBlockPropertyMetaException
- If the meta contains invalid data
-
getIntValueForMeta
- Throws:
InvalidBlockPropertyMetaException
- If the meta contains invalid data
-
getPersistenceValueForMeta
- Throws:
InvalidBlockPropertyMetaException
- If the meta contains invalid data
-
getMetaForPersistenceValue
@PowerNukkitOnly @Since("1.4.0.0-PN") public abstract int getMetaForPersistenceValue(String persistenceValue) - Throws:
InvalidBlockPropertyPersistenceValueException
- IF the persistence value is not valid for this property
-
validateDirectly
- Throws:
RuntimeException
- Any runtime exception to indicate an invalid value
-
validateMetaDirectly
- Throws:
RuntimeException
- Any runtime exception to indicate an invalid meta
-
validateMeta
- Throws:
InvalidBlockPropertyMetaException
- if the value in the meta at the given offset is not validIllegalArgumentException
- If the offset is negative or would cause memory overflow
-
validateMeta
- Throws:
InvalidBlockPropertyMetaException
- if the value in the meta at the given offset is not validIllegalArgumentException
- If the offset is negative or would cause memory overflow
-
validateMeta
- Throws:
InvalidBlockPropertyMetaException
- if the value in the meta at the given offset is not validIllegalArgumentException
- If the offset is negative or would cause memory overflow
-
getBitSize
-
getName
-
getPersistenceName
-
getValueClass
-
isExportedToItem
-
toString
-
isDefaultValue
-
isDefaultPersistentValue
@PowerNukkitOnly @Since("1.5.2.0-PN") public final boolean isDefaultPersistentValue(@Nonnull String value) -
getDefaultValue
-
isDefaultIntValue
-
isDefaultBooleanValue
-
getDefaultIntValue
-
getDefaultBooleanValue
-
copy
-
exportingToItems
@PowerNukkitOnly @Since("1.4.0.0-PN") public abstract BlockProperty<T> exportingToItems(boolean exportedToItem)
-