Compare commits
No commits in common. "9683e5311591e725558b742b3812ff3d37e3ccbc" and "481f36c04abc3cf39d63ec3cd24928b1f3b9de25" have entirely different histories.
9683e53115
...
481f36c04a
@ -58,9 +58,6 @@ private fun decoratives(provider: MatteryLanguageProvider) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
with(provider.english) {
|
with(provider.english) {
|
||||||
misc("computer_terminal_tooltip", "Can be used as Redstone button, except it sends signal to block behind it, not under")
|
|
||||||
misc("decorative", "Decorative")
|
|
||||||
|
|
||||||
add(MItems.CARGO_CRATE_MINECARTS[null]!!, "Minecart with Cargo Crate")
|
add(MItems.CARGO_CRATE_MINECARTS[null]!!, "Minecart with Cargo Crate")
|
||||||
add(MEntityTypes.CARGO_CRATE_MINECARTS[null]!!, "Minecart with Cargo Crate")
|
add(MEntityTypes.CARGO_CRATE_MINECARTS[null]!!, "Minecart with Cargo Crate")
|
||||||
|
|
||||||
|
@ -67,9 +67,6 @@ private fun decoratives(provider: MatteryLanguageProvider) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
with(provider.russian) {
|
with(provider.russian) {
|
||||||
misc("computer_terminal_tooltip", "Может быть использован как кнопка, с оговоркой что он посылает сигнал блоку сзади, а не под ним")
|
|
||||||
misc("decorative", "Элемент декора")
|
|
||||||
|
|
||||||
add(MItems.CARGO_CRATE_MINECARTS[null]!!, "Вагонетка с грузовым ящиком")
|
add(MItems.CARGO_CRATE_MINECARTS[null]!!, "Вагонетка с грузовым ящиком")
|
||||||
add(MEntityTypes.CARGO_CRATE_MINECARTS[null]!!, "Вагонетка с грузовым ящиком")
|
add(MEntityTypes.CARGO_CRATE_MINECARTS[null]!!, "Вагонетка с грузовым ящиком")
|
||||||
|
|
||||||
|
@ -376,17 +376,4 @@ fun addDecorativesRecipes(provider: MatteryRecipeProvider, consumer: RecipeOutpu
|
|||||||
.rowB(MItemTags.TRITANIUM_INGOTS)
|
.rowB(MItemTags.TRITANIUM_INGOTS)
|
||||||
.row(MItemTags.TRITANIUM_INGOTS, MItemTags.TRITANIUM_INGOTS, MItemTags.TRITANIUM_INGOTS)
|
.row(MItemTags.TRITANIUM_INGOTS, MItemTags.TRITANIUM_INGOTS, MItemTags.TRITANIUM_INGOTS)
|
||||||
.build(consumer)
|
.build(consumer)
|
||||||
|
|
||||||
for ((color, item) in MRegistry.COMPUTER_TERMINAL.allItems) {
|
|
||||||
val builder = MatteryRecipe(item, category = RecipeCategory.DECORATIONS)
|
|
||||||
|
|
||||||
builder.rowB(MItemTags.BASIC_CIRCUIT)
|
|
||||||
builder.rowB(MItemTags.TRITANIUM_PLATES)
|
|
||||||
|
|
||||||
if (color != null) {
|
|
||||||
builder.rowB(color.tag)
|
|
||||||
}
|
|
||||||
|
|
||||||
builder.build(consumer)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -50,10 +50,10 @@ fun Block.getShapeForEachState(properties: List<Property<*>>, fn: (BlockState) -
|
|||||||
val builder = Object2ObjectArrayMap<BlockState, Supplier<VoxelShape>>()
|
val builder = Object2ObjectArrayMap<BlockState, Supplier<VoxelShape>>()
|
||||||
|
|
||||||
if (properties.isEmpty()) {
|
if (properties.isEmpty()) {
|
||||||
val shape = Util.backgroundExecutor().submit(Callable { fn(stateDefinition.possibleStates.first()) }).asSupplier()
|
val shape = Util.backgroundExecutor().submit(Callable { fn(stateDefinition.possibleStates.first()) })
|
||||||
|
|
||||||
for (state in stateDefinition.possibleStates) {
|
for (state in stateDefinition.possibleStates) {
|
||||||
builder[state] = shape
|
builder[state] = shape.asSupplier()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
val cache = Object2ObjectArrayMap<List<Any>, Supplier<VoxelShape>>()
|
val cache = Object2ObjectArrayMap<List<Any>, Supplier<VoxelShape>>()
|
||||||
|
@ -51,7 +51,9 @@ open class RotatableMatteryBlock(properties: Properties = DEFAULT_PROPERTIES) :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Suppress("OVERRIDE_DEPRECATION")
|
||||||
override fun rotate(blockState: BlockState, rotation: Rotation): BlockState {
|
override fun rotate(blockState: BlockState, rotation: Rotation): BlockState {
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
return super.rotate(blockState, rotation).setValue(rotationProperty, blockState[rotationProperty].rotate(rotation))
|
return super.rotate(blockState, rotation).setValue(rotationProperty, blockState[rotationProperty].rotate(rotation))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,121 +0,0 @@
|
|||||||
package ru.dbotthepony.mc.otm.block.decorative
|
|
||||||
|
|
||||||
import net.minecraft.ChatFormatting
|
|
||||||
import net.minecraft.core.BlockPos
|
|
||||||
import net.minecraft.core.Direction
|
|
||||||
import net.minecraft.server.level.ServerLevel
|
|
||||||
import net.minecraft.sounds.SoundEvent
|
|
||||||
import net.minecraft.sounds.SoundEvents
|
|
||||||
import net.minecraft.sounds.SoundSource
|
|
||||||
import net.minecraft.util.RandomSource
|
|
||||||
import net.minecraft.world.InteractionResult
|
|
||||||
import net.minecraft.world.entity.player.Player
|
|
||||||
import net.minecraft.world.item.DyeColor
|
|
||||||
import net.minecraft.world.item.context.BlockPlaceContext
|
|
||||||
import net.minecraft.world.level.BlockGetter
|
|
||||||
import net.minecraft.world.level.Level
|
|
||||||
import net.minecraft.world.level.block.Block
|
|
||||||
import net.minecraft.world.level.block.SoundType
|
|
||||||
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.gameevent.GameEvent
|
|
||||||
import net.minecraft.world.level.material.MapColor
|
|
||||||
import net.minecraft.world.phys.BlockHitResult
|
|
||||||
import net.minecraft.world.phys.shapes.CollisionContext
|
|
||||||
import net.minecraft.world.phys.shapes.VoxelShape
|
|
||||||
import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock
|
|
||||||
import ru.dbotthepony.mc.otm.block.getShapeForEachState
|
|
||||||
import ru.dbotthepony.mc.otm.core.TranslatableComponent
|
|
||||||
import ru.dbotthepony.mc.otm.core.get
|
|
||||||
import ru.dbotthepony.mc.otm.core.math.plus
|
|
||||||
import ru.dbotthepony.mc.otm.core.set
|
|
||||||
import ru.dbotthepony.mc.otm.shapes.BlockShapes
|
|
||||||
|
|
||||||
class ComputerTerminalBlock(val color: DyeColor?) : RotatableMatteryBlock(
|
|
||||||
Properties.of()
|
|
||||||
.mapColor(color?.mapColor ?: MapColor.COLOR_LIGHT_BLUE)
|
|
||||||
.sound(SoundType.METAL)
|
|
||||||
.explosionResistance(15f)
|
|
||||||
.destroyTime(1.5f)
|
|
||||||
) {
|
|
||||||
private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.COMPUTER_TERMINAL.rotateFromNorth(it[rotationProperty]).computeShape() }
|
|
||||||
|
|
||||||
init {
|
|
||||||
registerDefaultState(defaultBlockState().set(BlockStateProperties.POWERED, false))
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun createBlockStateDefinition(builder: StateDefinition.Builder<Block, BlockState>) {
|
|
||||||
super.createBlockStateDefinition(builder)
|
|
||||||
builder.add(BlockStateProperties.POWERED)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getSignal(p_60483_: BlockState, p_60484_: BlockGetter, p_60485_: BlockPos, p_60486_: Direction): Int {
|
|
||||||
return if (p_60483_[BlockStateProperties.POWERED]) 15 else 0
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getDirectSignal(
|
|
||||||
p_60559_: BlockState,
|
|
||||||
p_60560_: BlockGetter,
|
|
||||||
p_60561_: BlockPos,
|
|
||||||
p_60562_: Direction
|
|
||||||
): Int {
|
|
||||||
// weird that p_60559_[rotationProperty].front should be used and not p_60559_[rotationProperty].back
|
|
||||||
// minecraft engine shenanigans
|
|
||||||
return if (p_60559_[BlockStateProperties.POWERED] && p_60559_[rotationProperty].front == p_60562_) 15 else 0
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun isSignalSource(p_60571_: BlockState): Boolean {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun updateNeighbours(blockState: BlockState, blockPos: BlockPos, level: Level) {
|
|
||||||
level.updateNeighborsAt(blockPos, this)
|
|
||||||
level.updateNeighborsAt(blockPos + blockState[rotationProperty].back, this)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun useWithoutItem(
|
|
||||||
blockState: BlockState,
|
|
||||||
level: Level,
|
|
||||||
blockPos: BlockPos,
|
|
||||||
ply: Player,
|
|
||||||
blockHitResult: BlockHitResult
|
|
||||||
): InteractionResult {
|
|
||||||
if (blockState[BlockStateProperties.POWERED]) {
|
|
||||||
return InteractionResult.CONSUME
|
|
||||||
} else {
|
|
||||||
level.setBlock(blockPos, blockState.set(BlockStateProperties.POWERED, true), UPDATE_ALL)
|
|
||||||
updateNeighbours(blockState, blockPos, level)
|
|
||||||
level.scheduleTick(blockPos, this, 40)
|
|
||||||
level.playSound(ply, blockPos, SoundEvents.STONE_BUTTON_CLICK_ON, SoundSource.BLOCKS, 1f, 1f)
|
|
||||||
level.gameEvent(ply, GameEvent.BLOCK_ACTIVATE, blockPos)
|
|
||||||
return InteractionResult.sidedSuccess(level.isClientSide)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun tick(blockState: BlockState, level: ServerLevel, blockPos: BlockPos, random: RandomSource) {
|
|
||||||
super.tick(blockState, level, blockPos, random)
|
|
||||||
|
|
||||||
if (blockState[BlockStateProperties.POWERED]) {
|
|
||||||
level.setBlock(blockPos, blockState.set(BlockStateProperties.POWERED, false), UPDATE_ALL)
|
|
||||||
level.playSound(null, blockPos, SoundEvents.STONE_BUTTON_CLICK_OFF, SoundSource.BLOCKS, 1f, 1f)
|
|
||||||
level.gameEvent(null, GameEvent.BLOCK_DEACTIVATE, blockPos)
|
|
||||||
updateNeighbours(blockState, blockPos, level)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
init {
|
|
||||||
tooltips.add(TranslatableComponent("otm.decorative").withStyle(ChatFormatting.GRAY))
|
|
||||||
tooltips.add(TranslatableComponent("otm.computer_terminal_tooltip").withStyle(ChatFormatting.GRAY))
|
|
||||||
tooltips.painted(color)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getShape(
|
|
||||||
state: BlockState,
|
|
||||||
blockGetter: BlockGetter,
|
|
||||||
pos: BlockPos,
|
|
||||||
context: CollisionContext
|
|
||||||
): VoxelShape {
|
|
||||||
return shapes[state]!!
|
|
||||||
}
|
|
||||||
}
|
|
@ -248,7 +248,8 @@ operator fun StateHolder<*, *>.get(property: BlockRotationFreedom): BlockRotatio
|
|||||||
}
|
}
|
||||||
|
|
||||||
operator fun <S : StateHolder<*, *>, T : Comparable<T>> S.set(property: Property<T>, value: T): S {
|
operator fun <S : StateHolder<*, *>, T : Comparable<T>> S.set(property: Property<T>, value: T): S {
|
||||||
return setValue(property, value) as S
|
setValue(property, value)
|
||||||
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
fun <T> List<T>.toImmutableList(): List<T> {
|
fun <T> List<T>.toImmutableList(): List<T> {
|
||||||
|
@ -32,7 +32,6 @@ import ru.dbotthepony.mc.otm.android.AndroidFeatureType
|
|||||||
import ru.dbotthepony.mc.otm.android.feature.EnderTeleporterFeature
|
import ru.dbotthepony.mc.otm.android.feature.EnderTeleporterFeature
|
||||||
import ru.dbotthepony.mc.otm.android.feature.NanobotsArmorFeature
|
import ru.dbotthepony.mc.otm.android.feature.NanobotsArmorFeature
|
||||||
import ru.dbotthepony.mc.otm.block.decorative.CargoCrateBlock
|
import ru.dbotthepony.mc.otm.block.decorative.CargoCrateBlock
|
||||||
import ru.dbotthepony.mc.otm.block.decorative.ComputerTerminalBlock
|
|
||||||
import ru.dbotthepony.mc.otm.block.decorative.StarChairBlock
|
import ru.dbotthepony.mc.otm.block.decorative.StarChairBlock
|
||||||
import ru.dbotthepony.mc.otm.block.decorative.TritaniumPressurePlate
|
import ru.dbotthepony.mc.otm.block.decorative.TritaniumPressurePlate
|
||||||
import ru.dbotthepony.mc.otm.capability.matteryEnergy
|
import ru.dbotthepony.mc.otm.capability.matteryEnergy
|
||||||
@ -104,7 +103,14 @@ object MRegistry : IBlockItemRegistryAcceptor {
|
|||||||
.destroyTime(2.5f)
|
.destroyTime(2.5f)
|
||||||
}.also { decorativeBlocks.add(it) }
|
}.also { decorativeBlocks.add(it) }
|
||||||
|
|
||||||
val COMPUTER_TERMINAL = DecorativeBlock("computer_terminal", ::ComputerTerminalBlock).also { decorativeBlocks.add(it) }
|
val COMPUTER_TERMINAL = DecorativeBlock.rotatable("computer_terminal", BlockShapes.COMPUTER_TERMINAL, BlockRotationFreedom.HORIZONTAL) {
|
||||||
|
BlockBehaviour.Properties.of()
|
||||||
|
.mapColor(it?.mapColor ?: MapColor.COLOR_LIGHT_BLUE)
|
||||||
|
.sound(SoundType.METAL)
|
||||||
|
.explosionResistance(15f)
|
||||||
|
.destroyTime(1.5f)
|
||||||
|
}.also { decorativeBlocks.add(it) }
|
||||||
|
|
||||||
val STAR_CHAIR = DecorativeBlock("star_chair", ::StarChairBlock).also { decorativeBlocks.add(it) }
|
val STAR_CHAIR = DecorativeBlock("star_chair", ::StarChairBlock).also { decorativeBlocks.add(it) }
|
||||||
|
|
||||||
val TRITANIUM_STAIRS = DecorativeBlock(MNames.TRITANIUM_STAIRS) {
|
val TRITANIUM_STAIRS = DecorativeBlock(MNames.TRITANIUM_STAIRS) {
|
||||||
|
Loading…
Reference in New Issue
Block a user