feat: CTS block
This commit is contained in:
parent
849a88bbf6
commit
c290984202
@ -10,6 +10,7 @@ import net.minecraft.world.item.CreativeModeTab
|
|||||||
import net.minecraft.world.item.ItemStack
|
import net.minecraft.world.item.ItemStack
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
import quaedam.config.QuaedamConfig
|
import quaedam.config.QuaedamConfig
|
||||||
|
import quaedam.misc.cts.ConstantTemporalSink
|
||||||
import quaedam.projection.ProjectionCommand
|
import quaedam.projection.ProjectionCommand
|
||||||
import quaedam.projection.ProjectionEffectType
|
import quaedam.projection.ProjectionEffectType
|
||||||
import quaedam.projection.SimpleProjectionUpdate
|
import quaedam.projection.SimpleProjectionUpdate
|
||||||
@ -54,6 +55,7 @@ object Quaedam {
|
|||||||
ProjectionCommand
|
ProjectionCommand
|
||||||
SimpleProjectionUpdate
|
SimpleProjectionUpdate
|
||||||
ProjectionShell
|
ProjectionShell
|
||||||
|
ConstantTemporalSink
|
||||||
|
|
||||||
creativeModeTabs.register()
|
creativeModeTabs.register()
|
||||||
items.register()
|
items.register()
|
||||||
|
15
common/src/main/kotlin/quaedam/misc/cts/CTSBlock.kt
Normal file
15
common/src/main/kotlin/quaedam/misc/cts/CTSBlock.kt
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
package quaedam.misc.cts
|
||||||
|
|
||||||
|
import net.minecraft.core.BlockPos
|
||||||
|
import net.minecraft.world.level.block.Block
|
||||||
|
import net.minecraft.world.level.block.EntityBlock
|
||||||
|
import net.minecraft.world.level.block.state.BlockState
|
||||||
|
|
||||||
|
object CTSBlock : Block(
|
||||||
|
Properties.of()
|
||||||
|
.lightLevel { 2 }
|
||||||
|
), EntityBlock {
|
||||||
|
|
||||||
|
override fun newBlockEntity(pos: BlockPos, state: BlockState) = CTSBlockEntity(pos, state)
|
||||||
|
|
||||||
|
}
|
19
common/src/main/kotlin/quaedam/misc/cts/CTSBlockEntity.kt
Normal file
19
common/src/main/kotlin/quaedam/misc/cts/CTSBlockEntity.kt
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
package quaedam.misc.cts
|
||||||
|
|
||||||
|
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
|
||||||
|
import quaedam.projector.Projector
|
||||||
|
|
||||||
|
class CTSBlockEntity(pos: BlockPos, state: BlockState) :
|
||||||
|
BlockEntity(Projector.blockEntity.get(), pos, state) {
|
||||||
|
|
||||||
|
override fun getUpdateTag(): CompoundTag = saveWithoutMetadata()
|
||||||
|
|
||||||
|
override fun getUpdatePacket(): Packet<ClientGamePacketListener> = ClientboundBlockEntityDataPacket.create(this)
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
package quaedam.misc.cts
|
||||||
|
|
||||||
|
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 ConstantTemporalSink {
|
||||||
|
|
||||||
|
const val ID = "cts"
|
||||||
|
|
||||||
|
val block = Quaedam.blocks.register(ID) { CTSBlock }!!
|
||||||
|
|
||||||
|
val item = Quaedam.items.register(ID) {
|
||||||
|
BlockItem(
|
||||||
|
CTSBlock, Item.Properties()
|
||||||
|
.stacksTo(1)
|
||||||
|
.`arch$tab`(Quaedam.creativeModeTab)
|
||||||
|
)
|
||||||
|
}!!
|
||||||
|
|
||||||
|
val blockEntity = Quaedam.blockEntities.register(ID) {
|
||||||
|
BlockEntityType.Builder.of(::CTSBlockEntity, block.get()).build(null)
|
||||||
|
}!!
|
||||||
|
|
||||||
|
fun checkEffect(level: Level, pos: BlockPos) = level.getChunkAt(pos)
|
||||||
|
.blockEntities
|
||||||
|
.any { (_, v) -> v is CTSBlockEntity }
|
||||||
|
|
||||||
|
}
|
@ -26,6 +26,7 @@ import net.minecraft.world.entity.npc.InventoryCarrier
|
|||||||
import net.minecraft.world.level.Level
|
import net.minecraft.world.level.Level
|
||||||
import net.minecraft.world.level.ServerLevelAccessor
|
import net.minecraft.world.level.ServerLevelAccessor
|
||||||
import quaedam.Quaedam
|
import quaedam.Quaedam
|
||||||
|
import quaedam.misc.cts.ConstantTemporalSink
|
||||||
import quaedam.projection.misc.SoundProjection
|
import quaedam.projection.misc.SoundProjection
|
||||||
import quaedam.projection.swarm.ai.ProjectedPersonAI
|
import quaedam.projection.swarm.ai.ProjectedPersonAI
|
||||||
import quaedam.projection.swarm.ai.ProjectedPersonNavigation
|
import quaedam.projection.swarm.ai.ProjectedPersonNavigation
|
||||||
@ -177,7 +178,7 @@ class ProjectedPersonEntity(entityType: EntityType<out PathfinderMob>, level: Le
|
|||||||
|
|
||||||
override fun checkDespawn() {
|
override fun checkDespawn() {
|
||||||
super.checkDespawn()
|
super.checkDespawn()
|
||||||
if (!checkProjectionEffect()) {
|
if (!checkProjectionEffect() && !ConstantTemporalSink.checkEffect(level(), blockPosition())) {
|
||||||
dropEquipment()
|
dropEquipment()
|
||||||
remove(RemovalReason.KILLED)
|
remove(RemovalReason.KILLED)
|
||||||
}
|
}
|
||||||
@ -253,4 +254,6 @@ class ProjectedPersonEntity(entityType: EntityType<out PathfinderMob>, level: Le
|
|||||||
|
|
||||||
override fun getAmbientSoundInterval() = 80 - random.nextInt(700)
|
override fun getAmbientSoundInterval() = 80 - random.nextInt(700)
|
||||||
|
|
||||||
|
override fun isEffectiveAi() = super.isEffectiveAi() && checkProjectionEffect()
|
||||||
|
|
||||||
}
|
}
|
@ -94,5 +94,29 @@
|
|||||||
"type": "file"
|
"type": "file"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
"quaedam.projection.noise": {
|
||||||
|
"sounds": [
|
||||||
|
{
|
||||||
|
"name": "entity.villager.work_librarian",
|
||||||
|
"weight": 2,
|
||||||
|
"type": "event"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "entity.villager.work_cleric",
|
||||||
|
"weight": 2,
|
||||||
|
"type": "event"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "entity.villager.work_mason",
|
||||||
|
"weight": 2,
|
||||||
|
"type": "event"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "entity.villager.work_shepherd",
|
||||||
|
"weight": 2,
|
||||||
|
"type": "event"
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user