Resolve mattery block errors
This commit is contained in:
parent
ce119269e0
commit
0c47de93c1
@ -8,6 +8,7 @@ import net.minecraft.ChatFormatting
|
||||
import net.minecraft.Util
|
||||
import net.minecraft.core.BlockPos
|
||||
import net.minecraft.core.Direction
|
||||
import net.minecraft.core.component.DataComponents
|
||||
import net.minecraft.core.particles.DustParticleOptions
|
||||
import net.minecraft.network.chat.Component
|
||||
import net.minecraft.util.RandomSource
|
||||
@ -44,6 +45,7 @@ import ru.dbotthepony.mc.otm.core.math.component1
|
||||
import ru.dbotthepony.mc.otm.core.math.component2
|
||||
import ru.dbotthepony.mc.otm.core.math.component3
|
||||
import ru.dbotthepony.mc.otm.once
|
||||
import ru.dbotthepony.mc.otm.registry.MDataComponentTypes
|
||||
import java.util.concurrent.Callable
|
||||
import java.util.function.Function
|
||||
import java.util.function.Supplier
|
||||
@ -93,12 +95,12 @@ open class MatteryBlock(properties: Properties = DEFAULT_PROPERTIES) : Block(pro
|
||||
entity: LivingEntity?,
|
||||
itemStack: ItemStack
|
||||
) {
|
||||
if (this is EntityBlock && itemStack.hasCustomHoverName() && !level.isClientSide) {
|
||||
if (this is EntityBlock && itemStack.has(DataComponents.CUSTOM_NAME) && !level.isClientSide) {
|
||||
val tile = level.getBlockEntity(blockPos)
|
||||
|
||||
if (tile is MatteryDeviceBlockEntity) {
|
||||
try {
|
||||
tile.customDisplayName = Component.Serializer.fromJson(itemStack.tagNotNull.getCompound("display").getString("Name"))
|
||||
tile.customDisplayName = itemStack.get(DataComponents.CUSTOM_NAME)
|
||||
} catch(_: Exception) {
|
||||
|
||||
}
|
||||
@ -248,14 +250,16 @@ open class MatteryBlock(properties: Properties = DEFAULT_PROPERTIES) : Block(pro
|
||||
super.onRemove(oldBlockState, level, blockPos, newBlockState, movedByPiston)
|
||||
}
|
||||
|
||||
override fun playerWillDestroy(level: Level, blockPos: BlockPos, blockState: BlockState, player: Player) {
|
||||
super.playerWillDestroy(level, blockPos, blockState, player)
|
||||
override fun playerWillDestroy(level: Level, blockPos: BlockPos, blockState: BlockState, player: Player): BlockState {
|
||||
val result = super.playerWillDestroy(level, blockPos, blockState, player)
|
||||
|
||||
val blockentity = level.getBlockEntity(blockPos)
|
||||
|
||||
if (blockentity is MatteryBlockEntity) {
|
||||
blockentity.beforeDestroyedByPlayer(level, blockPos, blockState, player)
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
override fun appendHoverText(
|
||||
|
Loading…
Reference in New Issue
Block a user