feat: reality stabler
This commit is contained in:
parent
3cab891af0
commit
dfa5627ddd
31
common/src/main/kotlin/quaedam/misc/reality/RSBlock.kt
Normal file
31
common/src/main/kotlin/quaedam/misc/reality/RSBlock.kt
Normal file
@ -0,0 +1,31 @@
|
||||
package quaedam.misc.reality
|
||||
|
||||
import net.minecraft.core.BlockPos
|
||||
import net.minecraft.core.Direction
|
||||
import net.minecraft.world.level.block.EntityBlock
|
||||
import net.minecraft.world.level.block.HorizontalDirectionalBlock
|
||||
import net.minecraft.world.level.block.SimpleWaterloggedBlock
|
||||
import net.minecraft.world.level.block.entity.BlockEntity
|
||||
import net.minecraft.world.level.block.state.BlockState
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties
|
||||
import net.minecraft.world.level.material.MapColor
|
||||
|
||||
object RSBlock : HorizontalDirectionalBlock(
|
||||
Properties.of()
|
||||
.noOcclusion()
|
||||
.strength(3f)
|
||||
.requiresCorrectToolForDrops()
|
||||
.mapColor(MapColor.COLOR_CYAN)
|
||||
), EntityBlock, SimpleWaterloggedBlock {
|
||||
|
||||
init {
|
||||
registerDefaultState(
|
||||
defaultBlockState()
|
||||
.setValue(FACING, Direction.EAST)
|
||||
.setValue(BlockStateProperties.WATERLOGGED, false)
|
||||
)
|
||||
}
|
||||
|
||||
override fun newBlockEntity(pos: BlockPos, state: BlockState) = RSBlockEntity(pos, state)
|
||||
|
||||
}
|
18
common/src/main/kotlin/quaedam/misc/reality/RSBlockEntity.kt
Normal file
18
common/src/main/kotlin/quaedam/misc/reality/RSBlockEntity.kt
Normal file
@ -0,0 +1,18 @@
|
||||
package quaedam.misc.reality
|
||||
|
||||
import net.minecraft.core.BlockPos
|
||||
import net.minecraft.nbt.CompoundTag
|
||||
import net.minecraft.network.protocol.Packet
|
||||
import net.minecraft.network.protocol.game.ClientGamePacketListener
|
||||
import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket
|
||||
import net.minecraft.world.level.block.entity.BlockEntity
|
||||
import net.minecraft.world.level.block.state.BlockState
|
||||
|
||||
class RSBlockEntity(pos: BlockPos, state: BlockState) :
|
||||
BlockEntity(RealityStabler.blockEntity.get(), pos, state) {
|
||||
|
||||
override fun getUpdateTag(): CompoundTag = saveWithoutMetadata()
|
||||
|
||||
override fun getUpdatePacket(): Packet<ClientGamePacketListener> = ClientboundBlockEntityDataPacket.create(this)
|
||||
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package quaedam.misc.reality
|
||||
|
||||
import net.minecraft.core.BlockPos
|
||||
import net.minecraft.world.item.BlockItem
|
||||
import net.minecraft.world.item.Item
|
||||
import net.minecraft.world.level.Level
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType
|
||||
import quaedam.Quaedam
|
||||
|
||||
object RealityStabler {
|
||||
|
||||
const val ID = "reality_stabler"
|
||||
|
||||
val block = Quaedam.blocks.register(ID) { RSBlock }!!
|
||||
|
||||
val item = Quaedam.items.register(ID) {
|
||||
BlockItem(
|
||||
RSBlock, Item.Properties()
|
||||
.stacksTo(1)
|
||||
.`arch$tab`(Quaedam.creativeModeTab)
|
||||
)
|
||||
}!!
|
||||
|
||||
val blockEntity = Quaedam.blockEntities.register(ID) {
|
||||
BlockEntityType.Builder.of(::RSBlockEntity, block.get()).build(null)
|
||||
}!!
|
||||
|
||||
fun checkEffect(level: Level, pos: BlockPos) = level.getChunkAt(pos)
|
||||
.blockEntities
|
||||
.any { (_, v) -> v is RSBlockEntity }
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user