parent
d91232b537
commit
70255794a8
@ -76,8 +76,8 @@ object DataGen {
|
|||||||
blockStateProvider.simpleBlockM(*blocks)
|
blockStateProvider.simpleBlockM(*blocks)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun decorativeColumn(block: Block, side: String, end: String) {
|
private fun decorativeColumn(block: Block, side: String, top: String) {
|
||||||
blockModelProvider.decorativeColumn(block, side, end)
|
blockModelProvider.decorativeColumn(block, side, top)
|
||||||
blockStateProvider.simpleBlockM(block)
|
blockStateProvider.simpleBlockM(block)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,11 +134,11 @@ object DataGen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun decoratives(list: DecorativeBlock) {
|
private fun decoratives(list: DecorativeBlock) {
|
||||||
for (block in list.blocks.values) {
|
for (block in list.allBlocks.values) {
|
||||||
decorativeCubeAll(block)
|
decorativeCubeAll(block)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (item in list.items.values) {
|
for (item in list.allItems.values) {
|
||||||
itemModelProvider.block(item)
|
itemModelProvider.block(item)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -154,11 +154,11 @@ object DataGen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun decoratives(subdir: String, list: DecorativeBlock) {
|
private fun decoratives(subdir: String, list: DecorativeBlock) {
|
||||||
for (block in list.blocks.values) {
|
for (block in list.allBlocks.values) {
|
||||||
decorativeCubeAll(subdir, block)
|
decorativeCubeAll(subdir, block)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (item in list.items.values) {
|
for (item in list.allItems.values) {
|
||||||
itemModelProvider.block(item)
|
itemModelProvider.block(item)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -174,11 +174,11 @@ object DataGen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun decoratives(subdir: String, suffix: String, list: DecorativeBlock) {
|
private fun decoratives(subdir: String, suffix: String, list: DecorativeBlock) {
|
||||||
for (block in list.blocks.values) {
|
for (block in list.allBlocks.values) {
|
||||||
decorativeCubeAll(subdir, suffix, block)
|
decorativeCubeAll(subdir, suffix, block)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (item in list.items.values) {
|
for (item in list.allItems.values) {
|
||||||
itemModelProvider.block(item)
|
itemModelProvider.block(item)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -246,6 +246,27 @@ object DataGen {
|
|||||||
blockModelProvider.resourceCubeAll(MBlocks.TRITANIUM_RAW_BLOCK)
|
blockModelProvider.resourceCubeAll(MBlocks.TRITANIUM_RAW_BLOCK)
|
||||||
blockModelProvider.resourceCubeAll(MBlocks.DEEPSLATE_TRITANIUM_ORE)
|
blockModelProvider.resourceCubeAll(MBlocks.DEEPSLATE_TRITANIUM_ORE)
|
||||||
|
|
||||||
|
decorativeCubeAll(MBlocks.DANGER_STRIPE_BLOCK)
|
||||||
|
decorativeColumn(MBlocks.METAL_BEAM, "metal_beam_side", "metal_beam_top")
|
||||||
|
|
||||||
|
blockModelProvider.exec {
|
||||||
|
it.cube(
|
||||||
|
MBlocks.LABORATORY_LAMP.registryName!!.path,
|
||||||
|
ResourceLocation(MOD_ID, "block/decorative/metal_beam_top"),
|
||||||
|
ResourceLocation(MOD_ID, "block/decorative/metal_beam_top"),
|
||||||
|
ResourceLocation(MOD_ID, "block/decorative/laboratory_lamp_front"),
|
||||||
|
ResourceLocation(MOD_ID, "block/decorative/metal_beam_top"),
|
||||||
|
ResourceLocation(MOD_ID, "block/decorative/metal_beam_top"),
|
||||||
|
ResourceLocation(MOD_ID, "block/decorative/metal_beam_top"),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
itemModelProvider.block(MItems.LABORATORY_LAMP)
|
||||||
|
itemModelProvider.block(MItems.DANGER_STRIPE_BLOCK)
|
||||||
|
itemModelProvider.block(MItems.METAL_BEAM)
|
||||||
|
|
||||||
|
blockStateProvider.block(MBlocks.LABORATORY_LAMP)
|
||||||
|
|
||||||
blockModelProvider.exec {
|
blockModelProvider.exec {
|
||||||
for (crate in MRegistry.CARGO_CRATES.blocks.values) {
|
for (crate in MRegistry.CARGO_CRATES.blocks.values) {
|
||||||
it.withExistingParent("${crate.registryName!!.path}_closed", ResourceLocation(OverdriveThatMatters.MOD_ID, "${MNames.CARGO_CRATE}_closed"))
|
it.withExistingParent("${crate.registryName!!.path}_closed", ResourceLocation(OverdriveThatMatters.MOD_ID, "${MNames.CARGO_CRATE}_closed"))
|
||||||
|
@ -313,6 +313,10 @@ private fun blocks(provider: MatteryLanguageProvider) {
|
|||||||
add(MBlocks.GRAVITATION_STABILIZER, "desc2", "Requires no power to operate")
|
add(MBlocks.GRAVITATION_STABILIZER, "desc2", "Requires no power to operate")
|
||||||
add(MBlocks.GRAVITATION_STABILIZER, "desc3", "Keep in mind the effect of multiple stabilizers produce exponentially increasing result")
|
add(MBlocks.GRAVITATION_STABILIZER, "desc3", "Keep in mind the effect of multiple stabilizers produce exponentially increasing result")
|
||||||
add(MBlocks.GRAVITATION_STABILIZER, "desc4", "Too weak gravitation field will cause singularity to melt and evaporate away very fast")
|
add(MBlocks.GRAVITATION_STABILIZER, "desc4", "Too weak gravitation field will cause singularity to melt and evaporate away very fast")
|
||||||
|
|
||||||
|
add(MBlocks.LABORATORY_LAMP, "Laboratory Lamp")
|
||||||
|
add(MBlocks.DANGER_STRIPE_BLOCK, "Danger Stripes")
|
||||||
|
add(MBlocks.METAL_BEAM, "Metal Beam")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,6 +32,10 @@ fun addLootTables(lootTables: LootTables) {
|
|||||||
lootTables.dropsSelf(MBlocks.GRAVITATION_STABILIZER)
|
lootTables.dropsSelf(MBlocks.GRAVITATION_STABILIZER)
|
||||||
lootTables.dropsOther(MBlocks.GRAVITATION_STABILIZER_LENS, MBlocks.GRAVITATION_STABILIZER)
|
lootTables.dropsOther(MBlocks.GRAVITATION_STABILIZER_LENS, MBlocks.GRAVITATION_STABILIZER)
|
||||||
|
|
||||||
|
lootTables.dropsSelf(MBlocks.LABORATORY_LAMP)
|
||||||
|
lootTables.dropsSelf(MBlocks.DANGER_STRIPE_BLOCK)
|
||||||
|
lootTables.dropsSelf(MBlocks.METAL_BEAM)
|
||||||
|
|
||||||
lootTables.tile(MBlocks.ENERGY_COUNTER,
|
lootTables.tile(MBlocks.ENERGY_COUNTER,
|
||||||
EnergyCounterBlockEntity.IO_LIMIT_KEY, EnergyCounterBlockEntity.PASSED_ENERGY_KEY,
|
EnergyCounterBlockEntity.IO_LIMIT_KEY, EnergyCounterBlockEntity.PASSED_ENERGY_KEY,
|
||||||
EnergyCounterBlockEntity.POWER_HISTORY_KEY, EnergyCounterBlockEntity.POWER_HISTORY_POINTER_KEY)
|
EnergyCounterBlockEntity.POWER_HISTORY_KEY, EnergyCounterBlockEntity.POWER_HISTORY_POINTER_KEY)
|
||||||
|
@ -74,6 +74,10 @@ fun addTags(tagsProvider: TagsProvider) {
|
|||||||
tagsProvider.requiresPickaxe(MRegistry.INDUSTRIAL_GLASS_PANE.allBlocks.values, Tiers.STONE)
|
tagsProvider.requiresPickaxe(MRegistry.INDUSTRIAL_GLASS_PANE.allBlocks.values, Tiers.STONE)
|
||||||
tagsProvider.requiresPickaxe(MRegistry.DECORATIVE_CRATE.allBlocks.values, Tiers.STONE)
|
tagsProvider.requiresPickaxe(MRegistry.DECORATIVE_CRATE.allBlocks.values, Tiers.STONE)
|
||||||
|
|
||||||
|
tagsProvider.requiresPickaxe(MBlocks.LABORATORY_LAMP, Tiers.IRON)
|
||||||
|
tagsProvider.requiresPickaxe(MBlocks.METAL_BEAM, Tiers.IRON)
|
||||||
|
tagsProvider.requiresPickaxe(MBlocks.DANGER_STRIPE_BLOCK)
|
||||||
|
|
||||||
tagsProvider.requiresPickaxe(listOf(
|
tagsProvider.requiresPickaxe(listOf(
|
||||||
MBlocks.GRAVITATION_STABILIZER,
|
MBlocks.GRAVITATION_STABILIZER,
|
||||||
MBlocks.GRAVITATION_STABILIZER_LENS,
|
MBlocks.GRAVITATION_STABILIZER_LENS,
|
||||||
|
@ -260,6 +260,36 @@ fun addPostWorldTickerOnce(level: Level, ticker: ITickable) {
|
|||||||
postWorldTick.computeIfAbsent(level) { TickList() }.add(ticker)
|
postWorldTick.computeIfAbsent(level) { TickList() }.add(ticker)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun Level.until(ticker: () -> Boolean) {
|
||||||
|
addPostWorldTicker(this, object : IConditionalTickable {
|
||||||
|
override var canTick: Boolean = true
|
||||||
|
private set
|
||||||
|
|
||||||
|
override fun tick() {
|
||||||
|
canTick = !ticker.invoke()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Level.untilPre(ticker: () -> Boolean) {
|
||||||
|
addPreWorldTicker(this, object : IConditionalTickable {
|
||||||
|
override var canTick: Boolean = true
|
||||||
|
private set
|
||||||
|
|
||||||
|
override fun tick() {
|
||||||
|
canTick = !ticker.invoke()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Level.once(ticker: ITickable) {
|
||||||
|
addPostWorldTickerOnce(this, ticker)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Level.oncePre(ticker: ITickable) {
|
||||||
|
addPreWorldTickerOnce(this, ticker)
|
||||||
|
}
|
||||||
|
|
||||||
private fun clear() {
|
private fun clear() {
|
||||||
preServerTickTimers.clear()
|
preServerTickTimers.clear()
|
||||||
postServerTickTimers.clear()
|
postServerTickTimers.clear()
|
||||||
|
@ -71,11 +71,11 @@ class BatteryBankBlock : RotatableMatteryBlock(), EntityBlock {
|
|||||||
state: BlockState,
|
state: BlockState,
|
||||||
level: Level,
|
level: Level,
|
||||||
pos: BlockPos,
|
pos: BlockPos,
|
||||||
sender: Block,
|
neighbour: Block,
|
||||||
sender_pos: BlockPos,
|
neighbourPos: BlockPos,
|
||||||
flag: Boolean
|
movedByPiston: Boolean
|
||||||
) {
|
) {
|
||||||
super.neighborChanged(state, level, pos, sender, sender_pos, flag)
|
super.neighborChanged(state, level, pos, neighbour, neighbourPos, movedByPiston)
|
||||||
|
|
||||||
val blockEntity = level.getBlockEntity(pos) as? BatteryBankBlockEntity ?: return
|
val blockEntity = level.getBlockEntity(pos) as? BatteryBankBlockEntity ?: return
|
||||||
|
|
||||||
|
@ -44,11 +44,11 @@ class ChemicalGeneratorBlock : RotatableMatteryBlock(), EntityBlock {
|
|||||||
state: BlockState,
|
state: BlockState,
|
||||||
level: Level,
|
level: Level,
|
||||||
pos: BlockPos,
|
pos: BlockPos,
|
||||||
sender: Block,
|
neighbour: Block,
|
||||||
sender_pos: BlockPos,
|
neighbourPos: BlockPos,
|
||||||
flag: Boolean
|
movedByPiston: Boolean
|
||||||
) {
|
) {
|
||||||
super.neighborChanged(state, level, pos, sender, sender_pos, flag)
|
super.neighborChanged(state, level, pos, neighbour, neighbourPos, movedByPiston)
|
||||||
|
|
||||||
if (!level.isClientSide) {
|
if (!level.isClientSide) {
|
||||||
val tile = level.getBlockEntity(pos)
|
val tile = level.getBlockEntity(pos)
|
||||||
|
@ -65,11 +65,11 @@ class EnergyCounterBlock : MatteryBlock(), EntityBlock {
|
|||||||
state: BlockState,
|
state: BlockState,
|
||||||
level: Level,
|
level: Level,
|
||||||
pos: BlockPos,
|
pos: BlockPos,
|
||||||
sender: Block,
|
neighbour: Block,
|
||||||
sender_pos: BlockPos,
|
neighbourPos: BlockPos,
|
||||||
flag: Boolean
|
movedByPiston: Boolean
|
||||||
) {
|
) {
|
||||||
super.neighborChanged(state, level, pos, sender, sender_pos, flag)
|
super.neighborChanged(state, level, pos, neighbour, neighbourPos, movedByPiston)
|
||||||
|
|
||||||
if (!level.isClientSide && !SERVER_IS_DYING) {
|
if (!level.isClientSide && !SERVER_IS_DYING) {
|
||||||
(level.getBlockEntity(pos) as? EnergyCounterBlockEntity)?.checkSurroundings()
|
(level.getBlockEntity(pos) as? EnergyCounterBlockEntity)?.checkSurroundings()
|
||||||
|
@ -114,11 +114,11 @@ class BlockGravitationStabilizer : RotatableMatteryBlock(props), EntityBlock {
|
|||||||
state: BlockState,
|
state: BlockState,
|
||||||
level: Level,
|
level: Level,
|
||||||
pos: BlockPos,
|
pos: BlockPos,
|
||||||
sender: Block,
|
neighbour: Block,
|
||||||
sender_pos: BlockPos,
|
neighbourPos: BlockPos,
|
||||||
flag: Boolean
|
movedByPiston: Boolean
|
||||||
) {
|
) {
|
||||||
super.neighborChanged(state, level, pos, sender, sender_pos, flag)
|
super.neighborChanged(state, level, pos, neighbour, neighbourPos, movedByPiston)
|
||||||
|
|
||||||
addPreWorldTickerOnce(level) {
|
addPreWorldTickerOnce(level) {
|
||||||
if (level.getBlockState(pos).block !is BlockGravitationStabilizer) return@addPreWorldTickerOnce
|
if (level.getBlockState(pos).block !is BlockGravitationStabilizer) return@addPreWorldTickerOnce
|
||||||
@ -175,11 +175,11 @@ class BlockGravitationStabilizerLens : RotatableMatteryBlock(props) {
|
|||||||
state: BlockState,
|
state: BlockState,
|
||||||
level: Level,
|
level: Level,
|
||||||
pos: BlockPos,
|
pos: BlockPos,
|
||||||
sender: Block,
|
neighbour: Block,
|
||||||
sender_pos: BlockPos,
|
neighbourPos: BlockPos,
|
||||||
flag: Boolean
|
movedByPiston: Boolean
|
||||||
) {
|
) {
|
||||||
super.neighborChanged(state, level, pos, sender, sender_pos, flag)
|
super.neighborChanged(state, level, pos, neighbour, neighbourPos, movedByPiston)
|
||||||
|
|
||||||
addPreWorldTickerOnce(level) {
|
addPreWorldTickerOnce(level) {
|
||||||
if (level.getBlockState(pos).block !is BlockGravitationStabilizerLens) return@addPreWorldTickerOnce
|
if (level.getBlockState(pos).block !is BlockGravitationStabilizerLens) return@addPreWorldTickerOnce
|
||||||
|
174
src/main/kotlin/ru/dbotthepony/mc/otm/block/LaboratoryLamp.kt
Normal file
174
src/main/kotlin/ru/dbotthepony/mc/otm/block/LaboratoryLamp.kt
Normal file
@ -0,0 +1,174 @@
|
|||||||
|
package ru.dbotthepony.mc.otm.block
|
||||||
|
|
||||||
|
import net.minecraft.core.BlockPos
|
||||||
|
import net.minecraft.world.item.Items
|
||||||
|
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.Blocks
|
||||||
|
import net.minecraft.world.level.block.RenderShape
|
||||||
|
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.material.Material
|
||||||
|
import net.minecraft.world.phys.shapes.CollisionContext
|
||||||
|
import net.minecraft.world.phys.shapes.Shapes
|
||||||
|
import net.minecraft.world.phys.shapes.VoxelShape
|
||||||
|
import ru.dbotthepony.mc.otm.core.get
|
||||||
|
import ru.dbotthepony.mc.otm.core.plus
|
||||||
|
import ru.dbotthepony.mc.otm.core.times
|
||||||
|
import ru.dbotthepony.mc.otm.core.unaryMinus
|
||||||
|
import ru.dbotthepony.mc.otm.once
|
||||||
|
import ru.dbotthepony.mc.otm.registry.MBlocks
|
||||||
|
|
||||||
|
const val LIGHT_LENGTH = 6
|
||||||
|
|
||||||
|
class LaboratoryLampLight : Block(Properties.of(Material.AIR).strength(-1.0F, 3600000.8F).noLootTable().noOcclusion().lightLevel { 15 }) {
|
||||||
|
override fun createBlockStateDefinition(builder: StateDefinition.Builder<Block, BlockState>) {
|
||||||
|
super.createBlockStateDefinition(builder)
|
||||||
|
builder.add(RotatableMatteryBlock.FACING_FULL)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun hasDynamicShape(): Boolean {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
@Suppress("OVERRIDE_DEPRECATION")
|
||||||
|
override fun getShape(
|
||||||
|
p_60555_: BlockState,
|
||||||
|
p_60556_: BlockGetter,
|
||||||
|
p_60557_: BlockPos,
|
||||||
|
p_60558_: CollisionContext
|
||||||
|
): VoxelShape {
|
||||||
|
return if (p_60558_.isHoldingItem(Items.LIGHT)) Shapes.block() else Shapes.empty()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Suppress("OVERRIDE_DEPRECATION")
|
||||||
|
override fun getRenderShape(p_60550_: BlockState): RenderShape {
|
||||||
|
return RenderShape.INVISIBLE
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun propagatesSkylightDown(p_49928_: BlockState, p_49929_: BlockGetter, p_49930_: BlockPos): Boolean {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
@Suppress("OVERRIDE_DEPRECATION")
|
||||||
|
override fun neighborChanged(
|
||||||
|
state: BlockState,
|
||||||
|
level: Level,
|
||||||
|
pos: BlockPos,
|
||||||
|
neighbour: Block,
|
||||||
|
neighbourPos: BlockPos,
|
||||||
|
movedByPiston: Boolean
|
||||||
|
) {
|
||||||
|
super.neighborChanged(state, level, pos, neighbour, neighbourPos, movedByPiston)
|
||||||
|
|
||||||
|
level.once {
|
||||||
|
if (level.getBlockState(pos) != state)
|
||||||
|
return@once
|
||||||
|
|
||||||
|
val facing = state[RotatableMatteryBlock.FACING_FULL]
|
||||||
|
|
||||||
|
var hit = false
|
||||||
|
|
||||||
|
for (i in 1 .. LIGHT_LENGTH) {
|
||||||
|
val target = pos + facing * i
|
||||||
|
val targetState = level.getBlockState(target)
|
||||||
|
|
||||||
|
if (targetState.block == MBlocks.LABORATORY_LAMP && targetState[BlockStateProperties.LIT]) {
|
||||||
|
hit = true
|
||||||
|
(targetState.block as LaboratoryLamp).doTick(targetState, level, target)
|
||||||
|
break
|
||||||
|
} else if (targetState.block != MBlocks.LABORATORY_LAMP_LIGHT && !targetState.isAir) {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!hit) {
|
||||||
|
level.setBlockAndUpdate(pos, Blocks.AIR.defaultBlockState())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class LaboratoryLamp : Block(Properties.of(Material.METAL).explosionResistance(12f).destroyTime(2f).requiresCorrectToolForDrops()) {
|
||||||
|
init {
|
||||||
|
registerDefaultState(stateDefinition.any().setValue(BlockStateProperties.LIT, true))
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun createBlockStateDefinition(builder: StateDefinition.Builder<Block, BlockState>) {
|
||||||
|
super.createBlockStateDefinition(builder)
|
||||||
|
builder.add(RotatableMatteryBlock.FACING_FULL)
|
||||||
|
builder.add(BlockStateProperties.LIT)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getStateForPlacement(context: BlockPlaceContext): BlockState {
|
||||||
|
return super.getStateForPlacement(context)!!.setValue(BlockStateProperties.LIT, true).setValue(RotatableMatteryBlock.FACING_FULL, context.nearestLookingDirection)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Suppress("OVERRIDE_DEPRECATION")
|
||||||
|
override fun onPlace(
|
||||||
|
state: BlockState,
|
||||||
|
level: Level,
|
||||||
|
pos: BlockPos,
|
||||||
|
oldState: BlockState,
|
||||||
|
movedByPiston: Boolean
|
||||||
|
) {
|
||||||
|
super.onPlace(state, level, pos, oldState, movedByPiston)
|
||||||
|
|
||||||
|
doTick(state, level, pos)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun doTick(
|
||||||
|
state: BlockState,
|
||||||
|
level: Level,
|
||||||
|
pos: BlockPos,
|
||||||
|
) {
|
||||||
|
level.once {
|
||||||
|
if (level.getBlockState(pos) != state)
|
||||||
|
return@once
|
||||||
|
|
||||||
|
val lit = state[BlockStateProperties.LIT]
|
||||||
|
val shouldBeLit = !level.hasNeighborSignal(pos)
|
||||||
|
|
||||||
|
if (lit != shouldBeLit) {
|
||||||
|
level.setBlockAndUpdate(pos, state.setValue(BlockStateProperties.LIT, shouldBeLit))
|
||||||
|
}
|
||||||
|
|
||||||
|
val facing = state[RotatableMatteryBlock.FACING_FULL]
|
||||||
|
|
||||||
|
for (i in 1 .. LIGHT_LENGTH) {
|
||||||
|
val target = pos + facing * i
|
||||||
|
val targetState = level.getBlockState(target)
|
||||||
|
|
||||||
|
if (!targetState.isAir && targetState.block != MBlocks.LABORATORY_LAMP_LIGHT) {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
if (shouldBeLit) {
|
||||||
|
if (targetState.isAir && targetState.block != MBlocks.LABORATORY_LAMP_LIGHT) {
|
||||||
|
level.setBlockAndUpdate(target, MBlocks.LABORATORY_LAMP_LIGHT.defaultBlockState().setValue(RotatableMatteryBlock.FACING_FULL, -facing))
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (targetState.block == MBlocks.LABORATORY_LAMP_LIGHT) {
|
||||||
|
level.setBlockAndUpdate(target, Blocks.AIR.defaultBlockState())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Suppress("OVERRIDE_DEPRECATION")
|
||||||
|
override fun neighborChanged(
|
||||||
|
state: BlockState,
|
||||||
|
level: Level,
|
||||||
|
pos: BlockPos,
|
||||||
|
neighbour: Block,
|
||||||
|
neighbourPos: BlockPos,
|
||||||
|
movedByPiston: Boolean
|
||||||
|
) {
|
||||||
|
super.neighborChanged(state, level, pos, neighbour, neighbourPos, movedByPiston)
|
||||||
|
doTick(state, level, pos)
|
||||||
|
}
|
||||||
|
}
|
@ -46,6 +46,7 @@ abstract class MatteryBlock @JvmOverloads constructor(
|
|||||||
super.setPlacedBy(level, blockPos, blockState, entity, itemStack)
|
super.setPlacedBy(level, blockPos, blockState, entity, itemStack)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Suppress("OVERRIDE_DEPRECATION")
|
||||||
override fun use(
|
override fun use(
|
||||||
blockState: BlockState,
|
blockState: BlockState,
|
||||||
level: Level,
|
level: Level,
|
||||||
@ -74,11 +75,11 @@ abstract class MatteryBlock @JvmOverloads constructor(
|
|||||||
state: BlockState,
|
state: BlockState,
|
||||||
level: Level,
|
level: Level,
|
||||||
pos: BlockPos,
|
pos: BlockPos,
|
||||||
sender: Block,
|
neighbour: Block,
|
||||||
sender_pos: BlockPos,
|
neighbourPos: BlockPos,
|
||||||
flag: Boolean
|
movedByPiston: Boolean
|
||||||
) {
|
) {
|
||||||
super.neighborChanged(state, level, pos, sender, sender_pos, flag)
|
super.neighborChanged(state, level, pos, neighbour, neighbourPos, movedByPiston)
|
||||||
|
|
||||||
if (this is EntityBlock && !level.isClientSide) {
|
if (this is EntityBlock && !level.isClientSide) {
|
||||||
val tile = level.getBlockEntity(pos)
|
val tile = level.getBlockEntity(pos)
|
||||||
|
@ -97,11 +97,11 @@ class StorageBusBlock : RotatableMatteryBlock(), EntityBlock {
|
|||||||
state: BlockState,
|
state: BlockState,
|
||||||
level: Level,
|
level: Level,
|
||||||
pos: BlockPos,
|
pos: BlockPos,
|
||||||
sender: Block,
|
neighbour: Block,
|
||||||
sender_pos: BlockPos,
|
neighbourPos: BlockPos,
|
||||||
flag: Boolean
|
movedByPiston: Boolean
|
||||||
) {
|
) {
|
||||||
super.neighborChanged(state, level, pos, sender, sender_pos, flag)
|
super.neighborChanged(state, level, pos, neighbour, neighbourPos, movedByPiston)
|
||||||
|
|
||||||
if (!level.isClientSide) {
|
if (!level.isClientSide) {
|
||||||
val tile = level.getBlockEntity(pos)
|
val tile = level.getBlockEntity(pos)
|
||||||
|
@ -98,11 +98,11 @@ class StorageImporterBlock : RotatableMatteryBlock(), EntityBlock {
|
|||||||
state: BlockState,
|
state: BlockState,
|
||||||
level: Level,
|
level: Level,
|
||||||
pos: BlockPos,
|
pos: BlockPos,
|
||||||
sender: Block,
|
neighbour: Block,
|
||||||
sender_pos: BlockPos,
|
neighbourPos: BlockPos,
|
||||||
flag: Boolean
|
movedByPiston: Boolean
|
||||||
) {
|
) {
|
||||||
super.neighborChanged(state, level, pos, sender, sender_pos, flag)
|
super.neighborChanged(state, level, pos, neighbour, neighbourPos, movedByPiston)
|
||||||
|
|
||||||
if (!level.isClientSide) {
|
if (!level.isClientSide) {
|
||||||
val tile = level.getBlockEntity(pos)
|
val tile = level.getBlockEntity(pos)
|
||||||
@ -189,11 +189,11 @@ class StorageExporterBlock : RotatableMatteryBlock(), EntityBlock {
|
|||||||
state: BlockState,
|
state: BlockState,
|
||||||
level: Level,
|
level: Level,
|
||||||
pos: BlockPos,
|
pos: BlockPos,
|
||||||
sender: Block,
|
neighbour: Block,
|
||||||
sender_pos: BlockPos,
|
neighbourPos: BlockPos,
|
||||||
flag: Boolean
|
movedByPiston: Boolean
|
||||||
) {
|
) {
|
||||||
super.neighborChanged(state, level, pos, sender, sender_pos, flag)
|
super.neighborChanged(state, level, pos, neighbour, neighbourPos, movedByPiston)
|
||||||
|
|
||||||
if (!level.isClientSide) {
|
if (!level.isClientSide) {
|
||||||
val tile = level.getBlockEntity(pos)
|
val tile = level.getBlockEntity(pos)
|
||||||
|
@ -373,6 +373,7 @@ operator fun Vec3i.plus(direction: Direction): Vec3i = this.offset(direction.nor
|
|||||||
operator fun Vec3i.minus(direction: Vec3i): Vec3i = this.subtract(direction)
|
operator fun Vec3i.minus(direction: Vec3i): Vec3i = this.subtract(direction)
|
||||||
operator fun Vec3i.minus(direction: Direction): Vec3i = this.subtract(direction.normal)
|
operator fun Vec3i.minus(direction: Direction): Vec3i = this.subtract(direction.normal)
|
||||||
operator fun Vec3i.times(int: Int): Vec3i = this.multiply(int)
|
operator fun Vec3i.times(int: Int): Vec3i = this.multiply(int)
|
||||||
|
operator fun Direction.times(int: Int): Vec3i = this.normal.multiply(int)
|
||||||
operator fun Vec3i.times(double: Double): Vector = Vector(x * double, y * double, z * double)
|
operator fun Vec3i.times(double: Double): Vector = Vector(x * double, y * double, z * double)
|
||||||
|
|
||||||
fun BlockPos.asVector(): Vector {
|
fun BlockPos.asVector(): Vector {
|
||||||
|
@ -14,6 +14,8 @@ import net.minecraft.resources.ResourceLocation
|
|||||||
import net.minecraft.world.entity.Entity
|
import net.minecraft.world.entity.Entity
|
||||||
import net.minecraft.world.item.Item
|
import net.minecraft.world.item.Item
|
||||||
import net.minecraft.world.item.ItemStack
|
import net.minecraft.world.item.ItemStack
|
||||||
|
import net.minecraft.world.level.block.state.StateHolder
|
||||||
|
import net.minecraft.world.level.block.state.properties.Property
|
||||||
import net.minecraft.world.phys.Vec3
|
import net.minecraft.world.phys.Vec3
|
||||||
import net.minecraftforge.common.util.LazyOptional
|
import net.minecraftforge.common.util.LazyOptional
|
||||||
import net.minecraftforge.items.IItemHandler
|
import net.minecraftforge.items.IItemHandler
|
||||||
@ -325,3 +327,7 @@ fun FriendlyByteBuf.writeItemType(value: Item) {
|
|||||||
fun FriendlyByteBuf.readItemType(): Item? {
|
fun FriendlyByteBuf.readItemType(): Item? {
|
||||||
return ForgeRegistries.ITEMS.getValue(readInt())
|
return ForgeRegistries.ITEMS.getValue(readInt())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
operator fun <T : Comparable<T>> StateHolder<*, *>.get(value: Property<T>): T {
|
||||||
|
return getValue(value)
|
||||||
|
}
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
package ru.dbotthepony.mc.otm.registry
|
package ru.dbotthepony.mc.otm.registry
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList
|
|
||||||
import net.minecraft.client.renderer.ItemBlockRenderTypes
|
|
||||||
import net.minecraft.client.renderer.RenderType
|
|
||||||
import net.minecraft.util.valueproviders.UniformInt
|
import net.minecraft.util.valueproviders.UniformInt
|
||||||
import net.minecraft.world.item.DyeColor
|
import net.minecraft.world.item.DyeColor
|
||||||
import net.minecraft.world.level.block.Block
|
import net.minecraft.world.level.block.Block
|
||||||
@ -12,8 +9,6 @@ import net.minecraft.world.level.block.state.BlockBehaviour
|
|||||||
import net.minecraft.world.level.material.Material
|
import net.minecraft.world.level.material.Material
|
||||||
import net.minecraft.world.level.material.MaterialColor
|
import net.minecraft.world.level.material.MaterialColor
|
||||||
import net.minecraftforge.eventbus.api.IEventBus
|
import net.minecraftforge.eventbus.api.IEventBus
|
||||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent
|
|
||||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext
|
|
||||||
import net.minecraftforge.registries.DeferredRegister
|
import net.minecraftforge.registries.DeferredRegister
|
||||||
import net.minecraftforge.registries.ForgeRegistries
|
import net.minecraftforge.registries.ForgeRegistries
|
||||||
import ru.dbotthepony.mc.otm.OverdriveThatMatters
|
import ru.dbotthepony.mc.otm.OverdriveThatMatters
|
||||||
@ -81,6 +76,11 @@ object MBlocks {
|
|||||||
.requiresCorrectToolForDrops()
|
.requiresCorrectToolForDrops()
|
||||||
) }
|
) }
|
||||||
|
|
||||||
|
val LABORATORY_LAMP: Block by registry.register(MNames.LABORATORY_LAMP) { LaboratoryLamp() }
|
||||||
|
val LABORATORY_LAMP_LIGHT: Block by registry.register(MNames.LABORATORY_LAMP_LIGHT) { LaboratoryLampLight() }
|
||||||
|
val DANGER_STRIPE_BLOCK: Block by registry.register(MNames.DANGER_STRIPE_BLOCK) { Block(BlockBehaviour.Properties.of(Material.METAL, DyeColor.GRAY).explosionResistance(6f).destroyTime(1.5f).requiresCorrectToolForDrops()) }
|
||||||
|
val METAL_BEAM: Block by registry.register(MNames.METAL_BEAM) { Block(BlockBehaviour.Properties.of(Material.METAL, DyeColor.GRAY).explosionResistance(14f).destroyTime(2.5f).requiresCorrectToolForDrops()) }
|
||||||
|
|
||||||
init {
|
init {
|
||||||
MRegistry.CARGO_CRATES.registerBlocks(registry)
|
MRegistry.CARGO_CRATES.registerBlocks(registry)
|
||||||
MRegistry.TRITANIUM_BLOCK.registerBlocks(registry)
|
MRegistry.TRITANIUM_BLOCK.registerBlocks(registry)
|
||||||
|
@ -260,6 +260,10 @@ object MItems {
|
|||||||
val NUTRIENT_PASTE: Item by registry.register(MNames.NUTRIENT_PASTE) { Item(Item.Properties().stacksTo(64).food(
|
val NUTRIENT_PASTE: Item by registry.register(MNames.NUTRIENT_PASTE) { Item(Item.Properties().stacksTo(64).food(
|
||||||
FoodProperties.Builder().meat().nutrition(8).saturationMod(0.9F).build()).tab(OverdriveThatMatters.INSTANCE.CREATIVE_TAB)) }
|
FoodProperties.Builder().meat().nutrition(8).saturationMod(0.9F).build()).tab(OverdriveThatMatters.INSTANCE.CREATIVE_TAB)) }
|
||||||
|
|
||||||
|
val LABORATORY_LAMP: Item by registry.register(MNames.LABORATORY_LAMP) { BlockItem(MBlocks.LABORATORY_LAMP, DEFAULT_PROPERTIES_DECORATIVE) }
|
||||||
|
val DANGER_STRIPE_BLOCK: Item by registry.register(MNames.DANGER_STRIPE_BLOCK) { BlockItem(MBlocks.DANGER_STRIPE_BLOCK, DEFAULT_PROPERTIES_DECORATIVE) }
|
||||||
|
val METAL_BEAM: Item by registry.register(MNames.METAL_BEAM) { BlockItem(MBlocks.METAL_BEAM, DEFAULT_PROPERTIES_DECORATIVE) }
|
||||||
|
|
||||||
init {
|
init {
|
||||||
MRegistry.CARGO_CRATES.registerItems(registry)
|
MRegistry.CARGO_CRATES.registerItems(registry)
|
||||||
MRegistry.TRITANIUM_BLOCK.registerItems(registry)
|
MRegistry.TRITANIUM_BLOCK.registerItems(registry)
|
||||||
|
@ -4,6 +4,11 @@ import net.minecraft.resources.ResourceLocation
|
|||||||
import ru.dbotthepony.mc.otm.OverdriveThatMatters
|
import ru.dbotthepony.mc.otm.OverdriveThatMatters
|
||||||
|
|
||||||
object MNames {
|
object MNames {
|
||||||
|
const val LABORATORY_LAMP = "laboratory_lamp"
|
||||||
|
const val LABORATORY_LAMP_LIGHT = "laboratory_lamp_light"
|
||||||
|
const val DANGER_STRIPE_BLOCK = "danger_stripe_block"
|
||||||
|
const val METAL_BEAM = "metal_beam"
|
||||||
|
|
||||||
// blocks
|
// blocks
|
||||||
const val ANDROID_STATION = "android_station" // без рецепта
|
const val ANDROID_STATION = "android_station" // без рецепта
|
||||||
const val BATTERY_BANK = "battery_bank" // нужен рецепт
|
const val BATTERY_BANK = "battery_bank" // нужен рецепт
|
||||||
|
@ -106,7 +106,7 @@ object MRegistry {
|
|||||||
.sound(SoundType.METAL)
|
.sound(SoundType.METAL)
|
||||||
.requiresCorrectToolForDrops()
|
.requiresCorrectToolForDrops()
|
||||||
.explosionResistance(10f)
|
.explosionResistance(10f)
|
||||||
.strength(1f)
|
.destroyTime(1f)
|
||||||
})
|
})
|
||||||
|
|
||||||
val TRITANIUM_BLOCK = DecorativeBlock.simple(MNames.TRITANIUM_BLOCK, {
|
val TRITANIUM_BLOCK = DecorativeBlock.simple(MNames.TRITANIUM_BLOCK, {
|
||||||
@ -114,7 +114,7 @@ object MRegistry {
|
|||||||
.sound(SoundType.BASALT)
|
.sound(SoundType.BASALT)
|
||||||
.requiresCorrectToolForDrops()
|
.requiresCorrectToolForDrops()
|
||||||
.explosionResistance(80f)
|
.explosionResistance(80f)
|
||||||
.strength(2.5f)
|
.destroyTime(2.5f)
|
||||||
})
|
})
|
||||||
|
|
||||||
val VENT = DecorativeBlock.simple(MNames.VENT, {
|
val VENT = DecorativeBlock.simple(MNames.VENT, {
|
||||||
@ -122,7 +122,7 @@ object MRegistry {
|
|||||||
.sound(SoundType.BASALT)
|
.sound(SoundType.BASALT)
|
||||||
.requiresCorrectToolForDrops()
|
.requiresCorrectToolForDrops()
|
||||||
.explosionResistance(20f)
|
.explosionResistance(20f)
|
||||||
.strength(1.5f)
|
.destroyTime(1.5f)
|
||||||
})
|
})
|
||||||
|
|
||||||
val VENT_ALTERNATIVE = DecorativeBlock.simple(MNames.VENT_ALTERNATIVE, {
|
val VENT_ALTERNATIVE = DecorativeBlock.simple(MNames.VENT_ALTERNATIVE, {
|
||||||
@ -130,7 +130,7 @@ object MRegistry {
|
|||||||
.sound(SoundType.BASALT)
|
.sound(SoundType.BASALT)
|
||||||
.requiresCorrectToolForDrops()
|
.requiresCorrectToolForDrops()
|
||||||
.explosionResistance(20f)
|
.explosionResistance(20f)
|
||||||
.strength(1.5f)
|
.destroyTime(1.5f)
|
||||||
})
|
})
|
||||||
|
|
||||||
val FLOOR_TILES = ColoredDecorativeBlock.simple(MNames.FLOOR_TILES, {
|
val FLOOR_TILES = ColoredDecorativeBlock.simple(MNames.FLOOR_TILES, {
|
||||||
|
Binary file not shown.
After Width: | Height: | Size: 2.4 KiB |
Binary file not shown.
After Width: | Height: | Size: 2.4 KiB |
Binary file not shown.
After Width: | Height: | Size: 2.4 KiB |
Binary file not shown.
After Width: | Height: | Size: 2.4 KiB |
Loading…
Reference in New Issue
Block a user