Merge remote-tracking branch 'origin/1.21' into 1.21
This commit is contained in:
commit
9c834e21e7
@ -10,10 +10,10 @@ fun addBlockModels(provider: MatteryBlockModelProvider) {
|
||||
resourceCubeAll(MBlocks.DEEPSLATE_TRITANIUM_ORE)
|
||||
resourceCubeAll(MBlocks.TRITANIUM_INGOT_BLOCK)
|
||||
|
||||
cable("crude_energy_cable", "block/power_cable_0")
|
||||
cable("regular_energy_cable", "block/power_cable_1")
|
||||
cable("advanced_energy_cable", "block/power_cable_2")
|
||||
cable("superconductor_energy_cable", "block/power_cable_3")
|
||||
cable("crude_energy_cable", "block/power_cable_0", powered = true)
|
||||
cable("regular_energy_cable", "block/power_cable_1", powered = true)
|
||||
cable("advanced_energy_cable", "block/power_cable_2", powered = true)
|
||||
cable("superconductor_energy_cable", "block/power_cable_3", powered = true)
|
||||
cable("matter_cable", "block/matter_cable", thin = true)
|
||||
cable("storage_cable", "block/storage_cable")
|
||||
|
||||
|
@ -250,11 +250,22 @@ fun addBlockStates(provider: MatteryBlockStateProvider) {
|
||||
.rotationY(dir.front.yRotationBlockstateSouth())
|
||||
.addModel()
|
||||
.condition(CableBlock.MAPPING_CONNECTION_PROP[dir.front]!!, true)
|
||||
.condition(BlockStateProperties.POWERED, false)
|
||||
.end()
|
||||
|
||||
part().modelFile(provider.models().getExistingFile(modLocation("${block.value.registryName!!.path}_connection_powered")))
|
||||
.rotationX(dir.front.xRotationBlockstateSouth())
|
||||
.rotationY(dir.front.yRotationBlockstateSouth())
|
||||
.addModel()
|
||||
.condition(CableBlock.MAPPING_CONNECTION_PROP[dir.front]!!, true)
|
||||
.condition(BlockStateProperties.POWERED, true)
|
||||
.end()
|
||||
}
|
||||
|
||||
part().modelFile(provider.models().getExistingFile(modLocation("${block.value.registryName!!.path}_core")))
|
||||
.addModel().end()
|
||||
.addModel().condition(BlockStateProperties.POWERED, false).end()
|
||||
part().modelFile(provider.models().getExistingFile(modLocation("${block.value.registryName!!.path}_core_powered")))
|
||||
.addModel().condition(BlockStateProperties.POWERED, true).end()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -143,7 +143,7 @@ class MatteryBlockModelProvider(event: GatherDataEvent) : BlockModelProvider(eve
|
||||
}
|
||||
}
|
||||
|
||||
fun cable(modelName: String, textureName: String, thin: Boolean = false) {
|
||||
fun cable(modelName: String, textureName: String, thin: Boolean = false, powered: Boolean = false) {
|
||||
val baseName = if (thin) "base_cable_thin" else "base_cable"
|
||||
|
||||
exec {
|
||||
@ -156,5 +156,15 @@ class MatteryBlockModelProvider(event: GatherDataEvent) : BlockModelProvider(eve
|
||||
withExistingParent("item/${modelName}", modLocation("item/${baseName}"))
|
||||
.texture("0", textureName)
|
||||
}
|
||||
|
||||
if (powered && !thin) {
|
||||
exec {
|
||||
withExistingParent("block/${modelName}_core_powered", modLocation("block/${baseName}_core_powered"))
|
||||
.texture("0", textureName)
|
||||
|
||||
withExistingParent("block/${modelName}_connection_powered", modLocation("block/${baseName}_connection_powered"))
|
||||
.texture("0", textureName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ import net.minecraft.world.level.block.SoundType
|
||||
import net.minecraft.world.level.block.entity.BlockEntity
|
||||
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
|
||||
import net.minecraft.world.level.block.state.properties.BooleanProperty
|
||||
import net.minecraft.world.level.material.MapColor
|
||||
import net.minecraft.world.level.material.PushReaction
|
||||
@ -142,6 +143,16 @@ class StorageCableBlock : CableBlock(Properties.of().mapColor(MapColor.METAL).re
|
||||
class EnergyCableBlock(val factory: (blockPos: BlockPos, blockState: BlockState) -> BlockEntity) : CableBlock(Properties.of().mapColor(MapColor.METAL).pushReaction(PushReaction.DESTROY).requiresCorrectToolForDrops().sound(SoundType.METAL).strength(1.0f, 6.0f)), EntityBlock {
|
||||
private val shapes = generateShapes(0.185)
|
||||
|
||||
init {
|
||||
registerDefaultState(defaultBlockState().setValue(BlockStateProperties.POWERED, false))
|
||||
}
|
||||
|
||||
override fun createBlockStateDefinition(builder: StateDefinition.Builder<Block, BlockState>) {
|
||||
super.createBlockStateDefinition(builder)
|
||||
|
||||
builder.add(BlockStateProperties.POWERED)
|
||||
}
|
||||
|
||||
@Suppress("OVERRIDE_DEPRECATION")
|
||||
override fun getShape(blockState: BlockState, accessor: BlockGetter, pos: BlockPos, context: CollisionContext): VoxelShape {
|
||||
return shapes[blockState] ?: Shapes.block()
|
||||
|
@ -6,6 +6,7 @@ import net.minecraft.world.level.Level
|
||||
import net.minecraft.world.level.block.Block
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType
|
||||
import net.minecraft.world.level.block.state.BlockState
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties
|
||||
import net.neoforged.neoforge.capabilities.Capabilities
|
||||
import ru.dbotthepony.mc.otm.SERVER_IS_LIVE
|
||||
import ru.dbotthepony.mc.otm.block.CableBlock
|
||||
@ -114,12 +115,30 @@ abstract class EnergyCableBlockEntity(type: BlockEntityType<*>, blockPos: BlockP
|
||||
if (!SERVER_IS_LIVE) return
|
||||
val level = level
|
||||
|
||||
val powered = node.graph.livelyNodes.filter {
|
||||
it.blockEntity.energySides.filter {
|
||||
side -> side.value.neighbour.isPresent && side.value.neighbour.get() !is CableSide
|
||||
}.isNotEmpty()
|
||||
}.size >= 2
|
||||
|
||||
level?.once {
|
||||
if (!node.isValid) return@once
|
||||
val newState = blockState.setValue(CableBlock.MAPPING_CONNECTION_PROP[side]!!, status)
|
||||
|
||||
val newState = blockState
|
||||
.setValue(CableBlock.MAPPING_CONNECTION_PROP[side]!!, status)
|
||||
.setValue(BlockStateProperties.POWERED, powered)
|
||||
|
||||
if (newState !== blockState && SERVER_IS_LIVE)
|
||||
level.setBlock(blockPos, newState, Block.UPDATE_CLIENTS)
|
||||
|
||||
node.graph.livelyNodes.forEach {
|
||||
if (it.isValid) {
|
||||
val newState = it.blockEntity.blockState.setValue(BlockStateProperties.POWERED, powered)
|
||||
|
||||
if (newState !== it.blockEntity.blockState && SERVER_IS_LIVE)
|
||||
level.setBlock(it.blockEntity.blockPos, newState, Block.UPDATE_CLIENTS)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,19 @@
|
||||
{
|
||||
"parent": "block/block",
|
||||
"texture_size": [16, 16],
|
||||
"textures": {
|
||||
"particle": "#0"
|
||||
},
|
||||
"elements": [
|
||||
{
|
||||
"from": [5, 5, 11],
|
||||
"to": [11, 11, 16],
|
||||
"faces": {
|
||||
"east": {"uv": [6, 6, 11, 12], "texture": "#0"},
|
||||
"west": {"uv": [6, 6, 11, 12], "texture": "#0"},
|
||||
"up": {"uv": [6, 6, 11, 12], "rotation": 90, "texture": "#0"},
|
||||
"down": {"uv": [6, 6, 11, 12], "rotation": 90, "texture": "#0"}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
{
|
||||
"parent": "block/block",
|
||||
"texture_size": [16, 16],
|
||||
"textures": {
|
||||
"particle": "#0"
|
||||
},
|
||||
"elements": [
|
||||
{
|
||||
"from": [5, 5, 5],
|
||||
"to": [11, 11, 11],
|
||||
"faces": {
|
||||
"north": {"uv": [0, 6, 6, 12], "texture": "#0"},
|
||||
"east": {"uv": [0, 6, 6, 12], "texture": "#0"},
|
||||
"south": {"uv": [0, 6, 6, 12], "texture": "#0"},
|
||||
"west": {"uv": [0, 6, 6, 12], "texture": "#0"},
|
||||
"up": {"uv": [0, 6, 6, 12], "texture": "#0"},
|
||||
"down": {"uv": [0, 6, 6, 12], "texture": "#0"}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue
Block a user