mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-13 09:26:11 -04:00
ItemStack replace hideflags getter and setter with variables
This commit is contained in:
parent
770fe6551d
commit
a69f576e11
@ -28,7 +28,7 @@ import de.bixilon.minosoft.data.mappings.ResourceLocation
|
|||||||
import de.bixilon.minosoft.data.mappings.items.Item
|
import de.bixilon.minosoft.data.mappings.items.Item
|
||||||
import de.bixilon.minosoft.data.mappings.versions.Version
|
import de.bixilon.minosoft.data.mappings.versions.Version
|
||||||
import de.bixilon.minosoft.data.text.ChatComponent
|
import de.bixilon.minosoft.data.text.ChatComponent
|
||||||
import de.bixilon.minosoft.util.BitByte
|
import de.bixilon.minosoft.util.BitByte.isBit
|
||||||
import de.bixilon.minosoft.util.KUtil.nullCast
|
import de.bixilon.minosoft.util.KUtil.nullCast
|
||||||
import de.bixilon.minosoft.util.nbt.tag.NBTUtil.compoundCast
|
import de.bixilon.minosoft.util.nbt.tag.NBTUtil.compoundCast
|
||||||
import de.bixilon.minosoft.util.nbt.tag.NBTUtil.getAndRemove
|
import de.bixilon.minosoft.util.nbt.tag.NBTUtil.getAndRemove
|
||||||
@ -168,36 +168,37 @@ data class ItemStack(
|
|||||||
return ChatComponent.of(item.toString())
|
return ChatComponent.of(item.toString())
|
||||||
}
|
}
|
||||||
|
|
||||||
fun shouldHideEnchantments(): Boolean {
|
var shouldHideEnchantments: Boolean
|
||||||
return BitByte.isBitSet(hideFlags, HIDE_ENCHANTMENT_BIT)
|
get() = hideFlags.isBit(HIDE_ENCHANTMENT_BIT)
|
||||||
}
|
set(value) = setHideFlag(HIDE_ENCHANTMENT_BIT, value)
|
||||||
|
|
||||||
fun shouldHideModifiers(): Boolean {
|
var shouldHideModifiers: Boolean
|
||||||
return BitByte.isBitSet(hideFlags, HIDE_MODIFIERS_BIT)
|
get() = hideFlags.isBit(HIDE_MODIFIERS_BIT)
|
||||||
}
|
set(value) = setHideFlag(HIDE_MODIFIERS_BIT, value)
|
||||||
|
|
||||||
fun shouldHideUnbreakable(): Boolean {
|
var shouldHideUnbreakable: Boolean
|
||||||
return BitByte.isBitSet(hideFlags, HIDE_UNBREAKABLE_BIT)
|
get() = hideFlags.isBit(HIDE_UNBREAKABLE_BIT)
|
||||||
}
|
set(value) = setHideFlag(HIDE_UNBREAKABLE_BIT, value)
|
||||||
|
|
||||||
fun shouldHideCanDestroy(): Boolean {
|
var shouldHideCanDestroy: Boolean
|
||||||
return BitByte.isBitSet(hideFlags, HIDE_CAN_DESTROY_BIT)
|
get() = hideFlags.isBit(HIDE_CAN_DESTROY_BIT)
|
||||||
}
|
set(value) = setHideFlag(HIDE_CAN_DESTROY_BIT, value)
|
||||||
|
|
||||||
fun shouldHideCanPlaceOn(): Boolean {
|
var shouldHideCanPlaceOn: Boolean
|
||||||
return BitByte.isBitSet(hideFlags, HIDE_CAN_PLACE_BIT)
|
get() = hideFlags.isBit(HIDE_CAN_PLACE_BIT)
|
||||||
}
|
set(value) = setHideFlag(HIDE_CAN_PLACE_BIT, value)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return hides other information, including potion effects, shield pattern info, "StoredEnchantments", written book "generation" and "author", "Explosion", "Fireworks", and map tooltips
|
* @return hides other information, including potion effects, shield pattern info, "StoredEnchantments", written book "generation" and "author", "Explosion", "Fireworks", and map tooltips
|
||||||
*/
|
*/
|
||||||
fun shouldHideOtherInformation(): Boolean {
|
var shouldHideOtherInformation: Boolean
|
||||||
return BitByte.isBitSet(hideFlags, HIDE_OTHER_INFORMATION_BIT)
|
get() = hideFlags.isBit(HIDE_OTHER_INFORMATION_BIT)
|
||||||
}
|
set(value) = setHideFlag(HIDE_OTHER_INFORMATION_BIT, value)
|
||||||
|
|
||||||
fun shouldHideLeatherDyeColor(): Boolean {
|
|
||||||
return BitByte.isBitSet(hideFlags, HIDE_LEATHER_DYE_COLOR_BIT)
|
var shouldHideLeatherDyeColor: Boolean
|
||||||
}
|
get() = hideFlags.isBit(HIDE_LEATHER_DYE_COLOR_BIT)
|
||||||
|
set(value) = setHideFlag(HIDE_LEATHER_DYE_COLOR_BIT, value)
|
||||||
|
|
||||||
private fun setHideFlag(bit: Int, setOrRemove: Boolean) {
|
private fun setHideFlag(bit: Int, setOrRemove: Boolean) {
|
||||||
val mask = (1 shl bit)
|
val mask = (1 shl bit)
|
||||||
@ -208,37 +209,6 @@ data class ItemStack(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setShouldHideEnchantments(hideEnchantments: Boolean) {
|
|
||||||
setHideFlag(HIDE_ENCHANTMENT_BIT, hideEnchantments)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun setShouldHideModifiers(hideModifiers: Boolean) {
|
|
||||||
setHideFlag(HIDE_MODIFIERS_BIT, hideModifiers)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun setShouldHideUnbreakable(hideUnbreakable: Boolean) {
|
|
||||||
setHideFlag(HIDE_UNBREAKABLE_BIT, hideUnbreakable)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun setShouldHideCanDestroy(hideCanDestroy: Boolean) {
|
|
||||||
setHideFlag(HIDE_CAN_DESTROY_BIT, hideCanDestroy)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun setShouldHideCanPlaceOn(hideCanPlaceOn: Boolean) {
|
|
||||||
setHideFlag(HIDE_CAN_PLACE_BIT, hideCanPlaceOn)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ hides other information, including potion effects, shield pattern info, "StoredEnchantments", written book "generation" and "author", "Explosion", "Fireworks", and map tooltips
|
|
||||||
*/
|
|
||||||
fun setShouldHideOtherInformation(hideOtherInformation: Boolean) {
|
|
||||||
setHideFlag(HIDE_OTHER_INFORMATION_BIT, hideOtherInformation)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun setShouldHideLeatherDyeColor(hideLeatherDyeColor: Boolean) {
|
|
||||||
setHideFlag(HIDE_LEATHER_DYE_COLOR_BIT, hideLeatherDyeColor)
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private const val HIDE_ENCHANTMENT_BIT = 0
|
private const val HIDE_ENCHANTMENT_BIT = 0
|
||||||
private const val HIDE_MODIFIERS_BIT = 1
|
private const val HIDE_MODIFIERS_BIT = 1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user