feat: reality stabler

This commit is contained in:
xtex 2023-07-28 10:00:40 +08:00
parent 3cab891af0
commit dfa5627ddd
Signed by: xtex
GPG Key ID: B918086ED8045B91
3 changed files with 81 additions and 0 deletions

View 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)
}

View 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)
}

View File

@ -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 }
}