feat: projection block events

This commit is contained in:
xtex 2023-06-29 22:34:49 +08:00
parent 81735d5f12
commit 94476b11c7
Signed by: xtex
GPG Key ID: B918086ED8045B91
3 changed files with 26 additions and 12 deletions

View File

@ -1,6 +1,8 @@
package quaedam package quaedam
import net.minecraft.core.BlockPos import net.minecraft.core.BlockPos
import net.minecraft.server.level.ServerLevel
import net.minecraft.util.RandomSource
import net.minecraft.world.InteractionHand import net.minecraft.world.InteractionHand
import net.minecraft.world.InteractionResult import net.minecraft.world.InteractionResult
import net.minecraft.world.entity.player.Player import net.minecraft.world.entity.player.Player
@ -36,6 +38,7 @@ object ProjectorBlock : Block(Properties.of()
.strength(4.0f) .strength(4.0f)
.requiresCorrectToolForDrops()) { .requiresCorrectToolForDrops()) {
@Suppress("OVERRIDE_DEPRECATION")
override fun use( override fun use(
blockState: BlockState, blockState: BlockState,
level: Level, level: Level,
@ -47,4 +50,14 @@ object ProjectorBlock : Block(Properties.of()
return InteractionResult.SUCCESS return InteractionResult.SUCCESS
} }
@Suppress("OVERRIDE_DEPRECATION")
override fun randomTick(
blockState: BlockState,
serverLevel: ServerLevel,
blockPos: BlockPos,
randomSource: RandomSource
) {
// @TODO: call projectorRandomTick
}
} }

View File

@ -1,5 +1,8 @@
package quaedam.projection package quaedam.projection
import net.minecraft.core.BlockPos
import net.minecraft.server.level.ServerLevel
import net.minecraft.util.RandomSource
import net.minecraft.world.item.ItemStack import net.minecraft.world.item.ItemStack
import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.Block
import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.block.state.BlockState
@ -19,4 +22,13 @@ abstract class ProjectionBlock(properties: Properties = createProperties()) : Bl
@Suppress("OVERRIDE_DEPRECATION") @Suppress("OVERRIDE_DEPRECATION")
override fun getDrops(blockState: BlockState, builder: LootParams.Builder) = listOf(ItemStack(asItem())) override fun getDrops(blockState: BlockState, builder: LootParams.Builder) = listOf(ItemStack(asItem()))
fun projectionActivated(level: ServerLevel, projectorPos: BlockPos, projectionPos: BlockPos) {
}
fun projectionDeactivated(level: ServerLevel, projectorPos: BlockPos, projectionPos: BlockPos) {
}
fun projectorRandomTick(level: ServerLevel, projectorPos: BlockPos, projectionPos: BlockPos, random: RandomSource) {
}
} }

View File

@ -1,16 +1,7 @@
package quaedam.projection package quaedam.projection
import net.minecraft.core.BlockPos
import net.minecraft.world.InteractionHand
import net.minecraft.world.InteractionResult
import net.minecraft.world.entity.player.Player
import net.minecraft.world.item.BlockItem import net.minecraft.world.item.BlockItem
import net.minecraft.world.item.Item import net.minecraft.world.item.Item
import net.minecraft.world.level.Level
import net.minecraft.world.level.block.Block
import net.minecraft.world.level.block.state.BlockState
import net.minecraft.world.level.material.MapColor
import net.minecraft.world.phys.BlockHitResult
import quaedam.Quaedam import quaedam.Quaedam
object SkylightProjection { object SkylightProjection {
@ -28,6 +19,4 @@ object SkylightProjection {
} }
object SkylightProjectionBlock : ProjectionBlock(createProperties().lightLevel { 3 }) { object SkylightProjectionBlock : ProjectionBlock(createProperties().lightLevel { 3 })
}