Compare commits

...
Author SHA1 Message Date
Nadja Reitzenstein 4320964a0c Add simplistic glitched / damaged monitor states
The current implementation has an extremely big flaw in that the future is completely detached from the entity and thus can break stuff easily.
2025-07-08 19:02:45 +02:00
12 changed files with 467 additions and 6 deletions
@@ -398,6 +398,7 @@ object Cobblemon {
playerDataManager.saveAllStores()
playerDataManager.saveExecutor.shutdown()
playerDataManager.saveExecutor.awaitTermination(30L, TimeUnit.SECONDS)
ServerTaskTracker.clear()
}
PlatformEvents.SERVER_STARTED.subscribe { event ->
bestSpawner.onServerStarted(event.server)
@@ -10,6 +10,9 @@ package com.cobblemon.mod.common.block
import com.cobblemon.mod.common.CobblemonBlockEntities
import com.cobblemon.mod.common.api.multiblock.MultiblockBlock
import com.cobblemon.mod.common.block.MonitorBlock.Companion.DAMAGED
import com.cobblemon.mod.common.block.MonitorBlock.Companion.SCREEN
import com.cobblemon.mod.common.block.MonitorBlock.MonitorScreen
import com.cobblemon.mod.common.block.entity.FossilAnalyzerBlockEntity
import com.cobblemon.mod.common.block.entity.FossilMultiblockEntity
import com.cobblemon.mod.common.block.multiblock.FossilMultiblockBuilder
@@ -72,6 +75,22 @@ class FossilAnalyzerBlock(settings: Properties) : MultiblockBlock(settings), Wor
builder.add(ON)
}
override fun neighborChanged(
state: BlockState,
level: Level,
pos: BlockPos,
neighborBlock: Block,
neighborPos: BlockPos,
movedByPiston: Boolean
) {
if (level.hasNeighborSignal(pos)) {
level.setBlockAndUpdate(pos, state.setValue(ON, true))
} else {
level.setBlockAndUpdate(pos, state.setValue(ON, false))
}
super.neighborChanged(state, level, pos, neighborBlock, neighborPos, movedByPiston)
}
companion object {
val ON = BooleanProperty.create("on")
@@ -8,14 +8,21 @@
package com.cobblemon.mod.common.block
import com.cobblemon.mod.common.CobblemonItems
import com.cobblemon.mod.common.api.multiblock.MultiblockBlock
import com.cobblemon.mod.common.api.multiblock.MultiblockEntity
import com.cobblemon.mod.common.api.scheduling.ScheduledTask
import com.cobblemon.mod.common.api.scheduling.afterOnServer
import com.cobblemon.mod.common.block.entity.FossilMultiblockEntity
import com.cobblemon.mod.common.block.multiblock.FossilMultiblockBuilder
import com.mojang.serialization.MapCodec
import net.minecraft.core.BlockPos
import net.minecraft.core.Direction
import net.minecraft.util.StringRepresentable
import net.minecraft.world.InteractionHand
import net.minecraft.world.ItemInteractionResult
import net.minecraft.world.entity.player.Player
import net.minecraft.world.item.ItemStack
import net.minecraft.world.item.context.BlockPlaceContext
import net.minecraft.world.level.BlockGetter
import net.minecraft.world.level.Level
@@ -25,8 +32,10 @@ import net.minecraft.world.level.block.Rotation
import net.minecraft.world.level.block.state.BlockState
import net.minecraft.world.level.block.state.StateDefinition
import net.minecraft.world.level.block.state.properties.BlockStateProperties.HORIZONTAL_FACING
import net.minecraft.world.level.block.state.properties.BooleanProperty
import net.minecraft.world.level.block.state.properties.EnumProperty
import net.minecraft.world.level.pathfinder.PathComputationType
import net.minecraft.world.phys.BlockHitResult
import net.minecraft.world.phys.shapes.CollisionContext
import net.minecraft.world.phys.shapes.Shapes
import net.minecraft.world.phys.shapes.VoxelShape
@@ -34,7 +43,8 @@ import net.minecraft.world.phys.shapes.VoxelShape
class MonitorBlock(settings: Properties) : MultiblockBlock(settings) {
init {
registerDefaultState(stateDefinition.any()
.setValue(HORIZONTAL_FACING, Direction.NORTH))
.setValue(HORIZONTAL_FACING, Direction.NORTH)
.setValue(DAMAGED, false))
}
override fun createMultiBlockEntity(
@@ -57,6 +67,7 @@ class MonitorBlock(settings: Properties) : MultiblockBlock(settings) {
override fun createBlockStateDefinition(builder: StateDefinition.Builder<Block, BlockState>) {
builder.add(HORIZONTAL_FACING)
builder.add(SCREEN)
builder.add(DAMAGED)
}
override fun hasAnalogOutputSignal(state: BlockState): Boolean {
@@ -92,11 +103,52 @@ class MonitorBlock(settings: Properties) : MultiblockBlock(settings) {
return false
}
override fun useItemOn(
stack: ItemStack,
state: BlockState,
level: Level,
pos: BlockPos,
player: Player,
hand: InteractionHand,
hitResult: BlockHitResult
): ItemInteractionResult? {
if (stack.item == CobblemonItems.UPGRADE && !(state.getValue(DAMAGED) || state.getValue(SCREEN) == MonitorScreen.GLITCHING)) {
level.setBlockAndUpdate(pos, state.setValue(SCREEN, MonitorScreen.GLITCHING))
stack.consume(1, player)
afterOnServer(40, level, {
level.setBlockAndUpdate(pos, state.setValue(DAMAGED, true))
})
return ItemInteractionResult.sidedSuccess(level.isClientSide)
}
return super.useItemOn(stack, state, level, pos, player, hand, hitResult)
}
override fun neighborChanged(
state: BlockState,
level: Level,
pos: BlockPos,
neighborBlock: Block,
neighborPos: BlockPos,
movedByPiston: Boolean
) {
if (state.getValue(DAMAGED)) {
if (level.hasNeighborSignal(pos)) {
level.setBlockAndUpdate(pos, state.setValue(SCREEN, MonitorScreen.GLITCHING))
} else {
level.setBlockAndUpdate(pos, state.setValue(SCREEN, MonitorScreen.OFF))
}
}
super.neighborChanged(state, level, pos, neighborBlock, neighborPos, movedByPiston)
}
companion object {
val CODEC = simpleCodec(::MonitorBlock)
//0 is off
val SCREEN = EnumProperty.create("screen", MonitorScreen::class.java)
val DAMAGED = BooleanProperty.create("damaged")
val HITBOX = Shapes.or(
Shapes.box(0.0625, 0.0, 0.0625, 0.9375, 0.375, 0.9375),
Shapes.box(0.0625, 0.875, 0.0625, 0.9375, 1.0, 0.9375),
@@ -116,7 +168,9 @@ class MonitorBlock(settings: Properties) : MultiblockBlock(settings) {
BLUE_PROGRESS_7,
BLUE_PROGRESS_8,
BLUE_PROGRESS_9,
GREEN_PROGRESS_9;
GREEN_PROGRESS_9,
GLITCHING;
override fun getSerializedName(): String = this.name.lowercase()
}
@@ -1,17 +1,17 @@
{
"variants": {
"facing=south,screen=off": {
"facing=south,screen=off,damaged=false": {
"model": "cobblemon:block/monitor"
},
"facing=west,screen=off": {
"facing=west,screen=off,damaged=false": {
"model": "cobblemon:block/monitor",
"y": 90
},
"facing=north,screen=off": {
"facing=north,screen=off,damaged=false": {
"model": "cobblemon:block/monitor",
"y": 180
},
"facing=east,screen=off": {
"facing=east,screen=off,damaged=false": {
"model": "cobblemon:block/monitor",
"y": 270
},
@@ -164,6 +164,51 @@
"facing=east,screen=green_progress_9": {
"model": "cobblemon:block/monitor_locked",
"y": 270
},
"facing=south,screen=off,damaged=true": {
"model": "cobblemon:block/monitor_damaged"
},
"facing=west,screen=off,damaged=true": {
"model": "cobblemon:block/monitor_damaged",
"y": 90
},
"facing=north,screen=off,damaged=true": {
"model": "cobblemon:block/monitor_damaged",
"y": 180
},
"facing=east,screen=off,damaged=true": {
"model": "cobblemon:block/monitor_damaged",
"y": 270
},
"facing=south,screen=glitching,damaged=true": {
"model": "cobblemon:block/monitor_damaged_glitching"
},
"facing=west,screen=glitching,damaged=true": {
"model": "cobblemon:block/monitor_damaged_glitching",
"y": 90
},
"facing=north,screen=glitching,damaged=true": {
"model": "cobblemon:block/monitor_damaged_glitching",
"y": 180
},
"facing=east,screen=glitching,damaged=true": {
"model": "cobblemon:block/monitor_damaged_glitching",
"y": 270
},
"facing=south,screen=glitching,damaged=false": {
"model": "cobblemon:block/monitor_glitching"
},
"facing=west,screen=glitching,damaged=false": {
"model": "cobblemon:block/monitor_glitching",
"y": 90
},
"facing=north,screen=glitching,damaged=false": {
"model": "cobblemon:block/monitor_glitching",
"y": 180
},
"facing=east,screen=glitching,damaged=false": {
"model": "cobblemon:block/monitor_glitching",
"y": 270
}
}
}
@@ -0,0 +1,110 @@
{
"format_version": "1.21.6",
"credit": "Made with Blockbench",
"texture_size": [64, 64],
"textures": {
"2": "cobblemon:block/monitor_damaged",
"particle": "cobblemon:block/monitor_particle"
},
"elements": [
{
"from": [1, 0, 1],
"to": [15, 6, 15],
"rotation": {"angle": 0, "axis": "y", "origin": [24, 16, 8.25]},
"faces": {
"north": {"uv": [0.25, 2.5, 3.75, 4], "texture": "#2"},
"east": {"uv": [4.25, 2.5, 7.75, 4], "texture": "#2"},
"south": {"uv": [0.25, 6.5, 3.75, 8], "texture": "#2"},
"west": {"uv": [7.75, 2.5, 4.25, 4], "texture": "#2"},
"up": {"uv": [3.75, 4, 0.25, 0.5], "texture": "#2"},
"down": {"uv": [11.75, 0.25, 8.25, 3.75], "texture": "#2"}
}
},
{
"from": [1, 14, 1],
"to": [15, 16, 15],
"rotation": {"angle": 0, "axis": "y", "origin": [24, 16, 8.25]},
"faces": {
"north": {"uv": [0.25, 0, 3.75, 0.5], "texture": "#2"},
"east": {"uv": [4.25, 0, 7.75, 0.5], "texture": "#2"},
"south": {"uv": [0.25, 4, 3.75, 4.5], "texture": "#2"},
"west": {"uv": [7.75, 0, 4.25, 0.5], "texture": "#2"},
"up": {"uv": [11.75, 3.75, 8.25, 0.25], "texture": "#2"},
"down": {"uv": [7.75, 0.5, 4.25, 4], "texture": "#2"}
}
},
{
"from": [13, 6, 1],
"to": [15, 14, 15],
"rotation": {"angle": 0, "axis": "y", "origin": [24, 16, 8.25]},
"faces": {
"north": {"uv": [0.25, 0.5, 0.75, 2.5], "texture": "#2"},
"east": {"uv": [4.25, 0.5, 7.75, 2.5], "texture": "#2"},
"south": {"uv": [3.25, 4.5, 3.75, 6.5], "texture": "#2"},
"west": {"uv": [4.25, 0.5, 7.75, 2.5], "texture": "#2"},
"up": {"uv": [9.5, 14.25, 9, 10.75], "texture": "#2"},
"down": {"uv": [10, 10.75, 9.5, 14.25], "texture": "#2"}
}
},
{
"from": [3, 6, 2],
"to": [13, 14, 15],
"rotation": {"angle": 0, "axis": "y", "origin": [24, 16, 8.25]},
"faces": {
"north": {"uv": [0.75, 0.5, 3.25, 2.5], "texture": "#2"},
"east": {"uv": [2.5, 9, 5.75, 11], "texture": "#2"},
"south": {"uv": [0.75, 4.5, 3.25, 6.5], "texture": "#2"},
"west": {"uv": [5.75, 9.25, 9, 11.25], "texture": "#2"},
"up": {"uv": [2.5, 10.25, 0, 7], "texture": "#2"},
"down": {"uv": [9.5, 0, 7, 3.25], "texture": "#2"}
}
},
{
"from": [1, 6, 1],
"to": [3, 14, 15],
"rotation": {"angle": 0, "axis": "y", "origin": [24, 16, 8.25]},
"faces": {
"north": {"uv": [3.25, 0.5, 3.75, 2.5], "texture": "#2"},
"east": {"uv": [4.25, 0.5, 7.75, 2.5], "texture": "#2"},
"south": {"uv": [0.25, 4.5, 0.75, 6.5], "texture": "#2"},
"west": {"uv": [7.75, 0.5, 4.25, 2.5], "texture": "#2"},
"up": {"uv": [10.5, 14.25, 10, 10.75], "texture": "#2"},
"down": {"uv": [11, 10.75, 10.5, 14.25], "texture": "#2"}
}
}
],
"display": {
"thirdperson_righthand": {
"rotation": [75, 135, 0],
"translation": [0, 2.5, 0],
"scale": [0.375, 0.375, 0.375]
},
"firstperson_righthand": {
"rotation": [0, 135, 0],
"scale": [0.4, 0.4, 0.4]
},
"firstperson_lefthand": {
"rotation": [0, 135, 0],
"scale": [0.4, 0.4, 0.4]
},
"ground": {
"translation": [0, 3, 0],
"scale": [0.25, 0.25, 0.25]
},
"gui": {
"rotation": [30, -135, 0],
"scale": [0.625, 0.625, 0.625]
},
"fixed": {
"scale": [0.5, 0.5, 0.5]
}
},
"groups": [
{
"name": "monitor",
"origin": [0, 0, 0],
"color": 0,
"children": [0, 1, 2, 3, 4]
}
]
}
@@ -0,0 +1,111 @@
{
"format_version": "1.21.6",
"credit": "Made with Blockbench",
"texture_size": [64, 64],
"textures": {
"2": "cobblemon:block/monitor_damaged",
"3": "cobblemon:block/monitor_damaged_glitching",
"particle": "cobblemon:block/monitor_particle"
},
"elements": [
{
"from": [1, 0, 1],
"to": [15, 6, 15],
"rotation": {"angle": 0, "axis": "y", "origin": [24, 16, 8.25]},
"faces": {
"north": {"uv": [0.25, 2.5, 3.75, 4], "texture": "#2"},
"east": {"uv": [4.25, 2.5, 7.75, 4], "texture": "#2"},
"south": {"uv": [0.25, 6.5, 3.75, 8], "texture": "#2"},
"west": {"uv": [7.75, 2.5, 4.25, 4], "texture": "#2"},
"up": {"uv": [3.75, 4, 0.25, 0.5], "texture": "#2"},
"down": {"uv": [11.75, 0.25, 8.25, 3.75], "texture": "#2"}
}
},
{
"from": [1, 14, 1],
"to": [15, 16, 15],
"rotation": {"angle": 0, "axis": "y", "origin": [24, 16, 8.25]},
"faces": {
"north": {"uv": [0.25, 0, 3.75, 0.5], "texture": "#2"},
"east": {"uv": [4.25, 0, 7.75, 0.5], "texture": "#2"},
"south": {"uv": [0.25, 4, 3.75, 4.5], "texture": "#2"},
"west": {"uv": [7.75, 0, 4.25, 0.5], "texture": "#2"},
"up": {"uv": [11.75, 3.75, 8.25, 0.25], "texture": "#2"},
"down": {"uv": [7.75, 0.5, 4.25, 4], "texture": "#2"}
}
},
{
"from": [13, 6, 1],
"to": [15, 14, 15],
"rotation": {"angle": 0, "axis": "y", "origin": [24, 16, 8.25]},
"faces": {
"north": {"uv": [0.25, 0.5, 0.75, 2.5], "texture": "#2"},
"east": {"uv": [4.25, 0.5, 7.75, 2.5], "texture": "#2"},
"south": {"uv": [3.25, 4.5, 3.75, 6.5], "texture": "#2"},
"west": {"uv": [4.25, 0.5, 7.75, 2.5], "texture": "#2"},
"up": {"uv": [9.5, 14.25, 9, 10.75], "texture": "#2"},
"down": {"uv": [10, 10.75, 9.5, 14.25], "texture": "#2"}
}
},
{
"from": [3, 6, 2],
"to": [13, 14, 15],
"rotation": {"angle": 0, "axis": "y", "origin": [24, 16, 8.25]},
"faces": {
"north": {"uv": [3, 0, 13, 8], "texture": "#3"},
"east": {"uv": [2.5, 9, 5.75, 11], "texture": "#2"},
"south": {"uv": [0.75, 4.5, 3.25, 6.5], "texture": "#2"},
"west": {"uv": [5.75, 9.25, 9, 11.25], "texture": "#2"},
"up": {"uv": [2.5, 10.25, 0, 7], "texture": "#2"},
"down": {"uv": [9.5, 0, 7, 3.25], "texture": "#2"}
}
},
{
"from": [1, 6, 1],
"to": [3, 14, 15],
"rotation": {"angle": 0, "axis": "y", "origin": [24, 16, 8.25]},
"faces": {
"north": {"uv": [3.25, 0.5, 3.75, 2.5], "texture": "#2"},
"east": {"uv": [4.25, 0.5, 7.75, 2.5], "texture": "#2"},
"south": {"uv": [0.25, 4.5, 0.75, 6.5], "texture": "#2"},
"west": {"uv": [7.75, 0.5, 4.25, 2.5], "texture": "#2"},
"up": {"uv": [10.5, 14.25, 10, 10.75], "texture": "#2"},
"down": {"uv": [11, 10.75, 10.5, 14.25], "texture": "#2"}
}
}
],
"display": {
"thirdperson_righthand": {
"rotation": [75, 135, 0],
"translation": [0, 2.5, 0],
"scale": [0.375, 0.375, 0.375]
},
"firstperson_righthand": {
"rotation": [0, 135, 0],
"scale": [0.4, 0.4, 0.4]
},
"firstperson_lefthand": {
"rotation": [0, 135, 0],
"scale": [0.4, 0.4, 0.4]
},
"ground": {
"translation": [0, 3, 0],
"scale": [0.25, 0.25, 0.25]
},
"gui": {
"rotation": [30, -135, 0],
"scale": [0.625, 0.625, 0.625]
},
"fixed": {
"scale": [0.5, 0.5, 0.5]
}
},
"groups": [
{
"name": "monitor",
"origin": [0, 0, 0],
"color": 0,
"children": [0, 1, 2, 3, 4]
}
]
}
@@ -0,0 +1,111 @@
{
"format_version": "1.21.6",
"credit": "Made with Blockbench",
"texture_size": [64, 64],
"textures": {
"2": "cobblemon:block/monitor",
"3": "cobblemon:block/monitor_glitching",
"particle": "cobblemon:block/monitor_particle"
},
"elements": [
{
"from": [1, 0, 1],
"to": [15, 6, 15],
"rotation": {"angle": 0, "axis": "y", "origin": [24, 16, 8.25]},
"faces": {
"north": {"uv": [0.25, 2.5, 3.75, 4], "texture": "#2"},
"east": {"uv": [4.25, 2.5, 7.75, 4], "texture": "#2"},
"south": {"uv": [0.25, 6.5, 3.75, 8], "texture": "#2"},
"west": {"uv": [7.75, 2.5, 4.25, 4], "texture": "#2"},
"up": {"uv": [3.75, 4, 0.25, 0.5], "texture": "#2"},
"down": {"uv": [11.75, 0.25, 8.25, 3.75], "texture": "#2"}
}
},
{
"from": [1, 14, 1],
"to": [15, 16, 15],
"rotation": {"angle": 0, "axis": "y", "origin": [24, 16, 8.25]},
"faces": {
"north": {"uv": [0.25, 0, 3.75, 0.5], "texture": "#2"},
"east": {"uv": [4.25, 0, 7.75, 0.5], "texture": "#2"},
"south": {"uv": [0.25, 4, 3.75, 4.5], "texture": "#2"},
"west": {"uv": [7.75, 0, 4.25, 0.5], "texture": "#2"},
"up": {"uv": [11.75, 3.75, 8.25, 0.25], "texture": "#2"},
"down": {"uv": [7.75, 0.5, 4.25, 4], "texture": "#2"}
}
},
{
"from": [13, 6, 1],
"to": [15, 14, 15],
"rotation": {"angle": 0, "axis": "y", "origin": [24, 16, 8.25]},
"faces": {
"north": {"uv": [0.25, 0.5, 0.75, 2.5], "texture": "#2"},
"east": {"uv": [4.25, 0.5, 7.75, 2.5], "texture": "#2"},
"south": {"uv": [3.25, 4.5, 3.75, 6.5], "texture": "#2"},
"west": {"uv": [4.25, 0.5, 7.75, 2.5], "texture": "#2"},
"up": {"uv": [9.5, 14.25, 9, 10.75], "texture": "#2"},
"down": {"uv": [10, 10.75, 9.5, 14.25], "texture": "#2"}
}
},
{
"from": [3, 6, 2],
"to": [13, 14, 15],
"rotation": {"angle": 0, "axis": "y", "origin": [24, 16, 8.25]},
"faces": {
"north": {"uv": [3, 0, 13, 8], "texture": "#3"},
"east": {"uv": [2.5, 9, 5.75, 11], "texture": "#2"},
"south": {"uv": [0.75, 4.5, 3.25, 6.5], "texture": "#2"},
"west": {"uv": [5.75, 9.25, 9, 11.25], "texture": "#2"},
"up": {"uv": [2.5, 10.25, 0, 7], "texture": "#2"},
"down": {"uv": [9.5, 0, 7, 3.25], "texture": "#2"}
}
},
{
"from": [1, 6, 1],
"to": [3, 14, 15],
"rotation": {"angle": 0, "axis": "y", "origin": [24, 16, 8.25]},
"faces": {
"north": {"uv": [3.25, 0.5, 3.75, 2.5], "texture": "#2"},
"east": {"uv": [4.25, 0.5, 7.75, 2.5], "texture": "#2"},
"south": {"uv": [0.25, 4.5, 0.75, 6.5], "texture": "#2"},
"west": {"uv": [7.75, 0.5, 4.25, 2.5], "texture": "#2"},
"up": {"uv": [10.5, 14.25, 10, 10.75], "texture": "#2"},
"down": {"uv": [11, 10.75, 10.5, 14.25], "texture": "#2"}
}
}
],
"display": {
"thirdperson_righthand": {
"rotation": [75, 135, 0],
"translation": [0, 2.5, 0],
"scale": [0.375, 0.375, 0.375]
},
"firstperson_righthand": {
"rotation": [0, 135, 0],
"scale": [0.4, 0.4, 0.4]
},
"firstperson_lefthand": {
"rotation": [0, 135, 0],
"scale": [0.4, 0.4, 0.4]
},
"ground": {
"translation": [0, 3, 0],
"scale": [0.25, 0.25, 0.25]
},
"gui": {
"rotation": [30, -135, 0],
"scale": [0.625, 0.625, 0.625]
},
"fixed": {
"scale": [0.5, 0.5, 0.5]
}
},
"groups": [
{
"name": "monitor",
"origin": [0, 0, 0],
"color": 0,
"children": [0, 1, 2, 3, 4]
}
]
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

@@ -0,0 +1,5 @@
{
"animation": {
"frametime": 2
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 848 B

@@ -0,0 +1,5 @@
{
"animation": {
"frametime": 2
}
}