From 94476b11c74043e122da7b329fb51da1f2052b5a Mon Sep 17 00:00:00 2001 From: xtex Date: Thu, 29 Jun 2023 22:34:49 +0800 Subject: [PATCH] feat: projection block events --- common/src/main/kotlin/quaedam/Projector.kt | 13 +++++++++++++ .../kotlin/quaedam/projection/ProjectionBlock.kt | 12 ++++++++++++ .../kotlin/quaedam/projection/SkylightProjection.kt | 13 +------------ 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/common/src/main/kotlin/quaedam/Projector.kt b/common/src/main/kotlin/quaedam/Projector.kt index f62068c..8069df9 100644 --- a/common/src/main/kotlin/quaedam/Projector.kt +++ b/common/src/main/kotlin/quaedam/Projector.kt @@ -1,6 +1,8 @@ package quaedam 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.InteractionResult import net.minecraft.world.entity.player.Player @@ -36,6 +38,7 @@ object ProjectorBlock : Block(Properties.of() .strength(4.0f) .requiresCorrectToolForDrops()) { + @Suppress("OVERRIDE_DEPRECATION") override fun use( blockState: BlockState, level: Level, @@ -47,4 +50,14 @@ object ProjectorBlock : Block(Properties.of() return InteractionResult.SUCCESS } + @Suppress("OVERRIDE_DEPRECATION") + override fun randomTick( + blockState: BlockState, + serverLevel: ServerLevel, + blockPos: BlockPos, + randomSource: RandomSource + ) { + // @TODO: call projectorRandomTick + } + } diff --git a/common/src/main/kotlin/quaedam/projection/ProjectionBlock.kt b/common/src/main/kotlin/quaedam/projection/ProjectionBlock.kt index d1168ee..3967255 100644 --- a/common/src/main/kotlin/quaedam/projection/ProjectionBlock.kt +++ b/common/src/main/kotlin/quaedam/projection/ProjectionBlock.kt @@ -1,5 +1,8 @@ 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.level.block.Block import net.minecraft.world.level.block.state.BlockState @@ -19,4 +22,13 @@ abstract class ProjectionBlock(properties: Properties = createProperties()) : Bl @Suppress("OVERRIDE_DEPRECATION") 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) { + } + } \ No newline at end of file diff --git a/common/src/main/kotlin/quaedam/projection/SkylightProjection.kt b/common/src/main/kotlin/quaedam/projection/SkylightProjection.kt index baa52f3..758ae48 100644 --- a/common/src/main/kotlin/quaedam/projection/SkylightProjection.kt +++ b/common/src/main/kotlin/quaedam/projection/SkylightProjection.kt @@ -1,16 +1,7 @@ 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.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 object SkylightProjection { @@ -28,6 +19,4 @@ object SkylightProjection { } -object SkylightProjectionBlock : ProjectionBlock(createProperties().lightLevel { 3 }) { - -} +object SkylightProjectionBlock : ProjectionBlock(createProperties().lightLevel { 3 })