Allow computer terminal tick timer to be changed
This commit is contained in:
parent
0298968042
commit
b52b49a468
@ -62,6 +62,7 @@ private fun decoratives(provider: MatteryLanguageProvider) {
|
||||
|
||||
with(provider.english) {
|
||||
misc("computer_terminal_tooltip", "Can be used as Redstone button, except it sends signal to block behind it, not under")
|
||||
misc("computer_terminal_tooltip1", "To setup how long it sends redstone signal, interact with it while sneaking")
|
||||
misc("decorative", "Decorative")
|
||||
|
||||
add(MItems.CARGO_CRATE_MINECARTS[null]!!, "Minecart with Cargo Crate")
|
||||
@ -860,6 +861,8 @@ private fun androidFeatures(provider: MatteryLanguageProvider) {
|
||||
|
||||
private fun gui(provider: MatteryLanguageProvider) {
|
||||
with(provider.english) {
|
||||
gui("tick_timer_set", "Timer set to %s ticks")
|
||||
|
||||
gui("black_hole_generator.help0", "Generates energy using angular momentum of Singularities")
|
||||
gui("black_hole_generator.help1", "The stronger gravity Singularity has, the more power is generated!")
|
||||
gui("black_hole_generator.help2", "Using Spacetime Normalizers will reduce gravitation strength of Singularity, which will reduce power output.")
|
||||
|
@ -65,6 +65,7 @@ private fun decoratives(provider: MatteryLanguageProvider) {
|
||||
add(MRegistry.TRITANIUM_PRESSURE_PLATE.block, "description1", HIGH_BLAST_RESISTANCE)
|
||||
|
||||
misc("computer_terminal_tooltip", "Может быть использован как кнопка, с оговоркой что он посылает сигнал блоку сзади, а не под ним")
|
||||
misc("computer_terminal_tooltip1", "Для настройки таймера взаимодействуйте будучи крадясь")
|
||||
misc("decorative", "Элемент декора")
|
||||
|
||||
add(MBlocks.GRILL[null]!!, "Мангал-дипломат")
|
||||
@ -861,6 +862,8 @@ private fun androidFeatures(provider: MatteryLanguageProvider) {
|
||||
|
||||
private fun gui(provider: MatteryLanguageProvider) {
|
||||
with(provider.russian) {
|
||||
gui("tick_timer_set", "Таймер установлен на %s тиков")
|
||||
|
||||
gui("black_hole_generator.help0", "Генерирует электричество используя угловое ускорение сингулярностей")
|
||||
gui("black_hole_generator.help1", "Чем сильнее гравитационное поле сингулярности, тем больше генерация!")
|
||||
gui("black_hole_generator.help2", "Использование стабилизаторов пространства-времени ослабляет гравитационное поле, снижая генерацию")
|
||||
|
@ -8,6 +8,7 @@ import net.minecraft.sounds.SoundEvent
|
||||
import net.minecraft.sounds.SoundEvents
|
||||
import net.minecraft.sounds.SoundSource
|
||||
import net.minecraft.util.RandomSource
|
||||
import net.minecraft.util.StringRepresentable
|
||||
import net.minecraft.world.InteractionResult
|
||||
import net.minecraft.world.entity.player.Player
|
||||
import net.minecraft.world.item.DyeColor
|
||||
@ -19,6 +20,7 @@ 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.block.state.properties.EnumProperty
|
||||
import net.minecraft.world.level.gameevent.GameEvent
|
||||
import net.minecraft.world.level.material.MapColor
|
||||
import net.minecraft.world.phys.BlockHitResult
|
||||
@ -42,12 +44,13 @@ class ComputerTerminalBlock(val color: DyeColor?) : RotatableMatteryBlock(
|
||||
private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.COMPUTER_TERMINAL.rotateFromNorth(it[rotationProperty]).computeShape() }
|
||||
|
||||
init {
|
||||
registerDefaultState(defaultBlockState().set(BlockStateProperties.POWERED, false))
|
||||
registerDefaultState(defaultBlockState().set(BlockStateProperties.POWERED, false).set(TICKS, TickTimer.TICK_20))
|
||||
}
|
||||
|
||||
override fun createBlockStateDefinition(builder: StateDefinition.Builder<Block, BlockState>) {
|
||||
super.createBlockStateDefinition(builder)
|
||||
builder.add(BlockStateProperties.POWERED)
|
||||
builder.add(TICKS)
|
||||
}
|
||||
|
||||
override fun getSignal(p_60483_: BlockState, p_60484_: BlockGetter, p_60485_: BlockPos, p_60486_: Direction): Int {
|
||||
@ -81,12 +84,30 @@ class ComputerTerminalBlock(val color: DyeColor?) : RotatableMatteryBlock(
|
||||
ply: Player,
|
||||
blockHitResult: BlockHitResult
|
||||
): InteractionResult {
|
||||
if (ply.isShiftKeyDown) {
|
||||
val current = blockState[TICKS]
|
||||
val next = TickTimer.entries.getOrElse(current.ordinal + 1) { TickTimer.TICK_2 }
|
||||
|
||||
level.playSound(ply, blockPos, SoundEvents.DISPENSER_FAIL, SoundSource.BLOCKS, 1f, 1f)
|
||||
level.gameEvent(ply, GameEvent.BLOCK_ACTIVATE, blockPos)
|
||||
|
||||
if (!level.isClientSide) {
|
||||
ply.sendSystemMessage(TranslatableComponent("otm.gui.tick_timer_set", next.ticks.toString()))
|
||||
level.setBlock(blockPos, blockState.set(TICKS, next), UPDATE_ALL)
|
||||
}
|
||||
|
||||
return InteractionResult.sidedSuccess(level.isClientSide)
|
||||
}
|
||||
|
||||
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)
|
||||
if (!level.isClientSide) {
|
||||
level.setBlock(blockPos, blockState.set(BlockStateProperties.POWERED, true), UPDATE_ALL)
|
||||
updateNeighbours(blockState, blockPos, level)
|
||||
level.scheduleTick(blockPos, this, blockState[TICKS].ticks)
|
||||
}
|
||||
|
||||
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)
|
||||
@ -107,6 +128,7 @@ class ComputerTerminalBlock(val color: DyeColor?) : RotatableMatteryBlock(
|
||||
init {
|
||||
tooltips.add(TranslatableComponent("otm.decorative").withStyle(ChatFormatting.GRAY))
|
||||
tooltips.add(TranslatableComponent("otm.computer_terminal_tooltip").withStyle(ChatFormatting.GRAY))
|
||||
tooltips.add(TranslatableComponent("otm.computer_terminal_tooltip1").withStyle(ChatFormatting.GRAY))
|
||||
tooltips.painted(color)
|
||||
}
|
||||
|
||||
@ -118,4 +140,22 @@ class ComputerTerminalBlock(val color: DyeColor?) : RotatableMatteryBlock(
|
||||
): VoxelShape {
|
||||
return shapes[state]!!
|
||||
}
|
||||
|
||||
enum class TickTimer(val ticks: Int) : StringRepresentable {
|
||||
TICK_2(2),
|
||||
TICK_10(10),
|
||||
TICK_20(20),
|
||||
TICK_30(30),
|
||||
TICK_40(40);
|
||||
|
||||
private val str = ticks.toString()
|
||||
|
||||
override fun getSerializedName(): String {
|
||||
return str
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
val TICKS: EnumProperty<TickTimer> = EnumProperty.create("ticks", TickTimer::class.java)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user