Inverted redstone signal laboratory lamp

This commit is contained in:
DBotThePony 2022-09-09 11:50:00 +07:00
parent b68ef58d0c
commit 8c7c3de01c
Signed by: DBot
GPG Key ID: DCC23B5715498507
9 changed files with 38 additions and 6 deletions

View File

@ -75,6 +75,7 @@ fun addDecorativeData(blockStateProvider: MatteryBlockStateProvider, itemModelPr
}
itemModelProvider.block(MItems.LABORATORY_LAMP)
itemModelProvider.block(MItems.LABORATORY_LAMP_INVERTED, MItems.LABORATORY_LAMP.registryName!!.path + "_unlit")
itemModelProvider.block(MItems.DANGER_STRIPE_BLOCK)
itemModelProvider.block(MItems.METAL_BEAM)
@ -86,6 +87,14 @@ fun addDecorativeData(blockStateProvider: MatteryBlockStateProvider, itemModelPr
.rotationY(it[RotatableMatteryBlock.FACING_FULL].toYRotBlockstate())
.build()
}
blockStateProvider.getVariantBuilder(MBlocks.LABORATORY_LAMP_INVERTED).forAllStates {
return@forAllStates ConfiguredModel.builder()
.modelFile(if (it[BlockStateProperties.LIT]) labLampOn!! else labLampOff!!)
.rotationX(it[RotatableMatteryBlock.FACING_FULL].toXRotBlockstate())
.rotationY(it[RotatableMatteryBlock.FACING_FULL].toYRotBlockstate())
.build()
}
}
blockModelProvider.exec {

View File

@ -315,6 +315,7 @@ private fun blocks(provider: MatteryLanguageProvider) {
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.LABORATORY_LAMP_INVERTED, "Laboratory Lamp (Inverted Signal)")
add(MBlocks.DANGER_STRIPE_BLOCK, "Danger Stripes")
add(MBlocks.METAL_BEAM, "Metal Beam")
}

View File

@ -33,6 +33,7 @@ fun addLootTables(lootTables: LootTables) {
lootTables.dropsOther(MBlocks.GRAVITATION_STABILIZER_LENS, MBlocks.GRAVITATION_STABILIZER)
lootTables.dropsSelf(MBlocks.LABORATORY_LAMP)
lootTables.dropsSelf(MBlocks.LABORATORY_LAMP_INVERTED)
lootTables.dropsSelf(MBlocks.DANGER_STRIPE_BLOCK)
lootTables.dropsSelf(MBlocks.METAL_BEAM)

View File

@ -13,6 +13,7 @@ import ru.dbotthepony.mc.otm.OverdriveThatMatters
import ru.dbotthepony.mc.otm.core.registryName
import ru.dbotthepony.mc.otm.datagen.DataGen
import ru.dbotthepony.mc.otm.registry.MItemTags
import ru.dbotthepony.mc.otm.registry.MItems
import ru.dbotthepony.mc.otm.registry.MRegistry
import java.util.function.Consumer
@ -163,4 +164,14 @@ fun addDecorativesRecipes(provider: MatteryRecipeProvider, consumer: Consumer<Fi
.unlockedBy("has_colored_tritanium_glass", has(paneItem))
.save(consumer, ResourceLocation(DataGen.MOD_ID, "${paneItem.registryName!!.path}_alt"))
}
ShapelessRecipeBuilder(MItems.LABORATORY_LAMP, 1)
.requires(MItems.LABORATORY_LAMP_INVERTED)
.unlockedBy(MItems.LABORATORY_LAMP_INVERTED)
.save(consumer, MItems.LABORATORY_LAMP.registryName!!.toString() + "_inv")
ShapelessRecipeBuilder(MItems.LABORATORY_LAMP_INVERTED, 1)
.requires(MItems.LABORATORY_LAMP)
.unlockedBy(MItems.LABORATORY_LAMP)
.save(consumer, MItems.LABORATORY_LAMP_INVERTED.registryName!!.toString() + "_inv")
}

View File

@ -75,6 +75,7 @@ fun addTags(tagsProvider: TagsProvider) {
tagsProvider.requiresPickaxe(MRegistry.DECORATIVE_CRATE.allBlocks.values, Tiers.STONE)
tagsProvider.requiresPickaxe(MBlocks.LABORATORY_LAMP, Tiers.IRON)
tagsProvider.requiresPickaxe(MBlocks.LABORATORY_LAMP_INVERTED, Tiers.IRON)
tagsProvider.requiresPickaxe(MBlocks.METAL_BEAM, Tiers.IRON)
tagsProvider.requiresPickaxe(MBlocks.DANGER_STRIPE_BLOCK)

View File

@ -76,7 +76,7 @@ class LaboratoryLampLight : Block(Properties.of(Material.AIR).strength(-1.0F, 36
val target = pos + facing * i
val targetState = level.getBlockState(target)
if (targetState.block == MBlocks.LABORATORY_LAMP && targetState[BlockStateProperties.LIT]) {
if (targetState.block is LaboratoryLamp && targetState[BlockStateProperties.LIT]) {
hit = true
(targetState.block as LaboratoryLamp).doTick(targetState, level, target)
break
@ -92,9 +92,9 @@ class LaboratoryLampLight : Block(Properties.of(Material.AIR).strength(-1.0F, 36
}
}
class LaboratoryLamp : Block(Properties.of(Material.METAL).explosionResistance(12f).destroyTime(2f).requiresCorrectToolForDrops()) {
class LaboratoryLamp(val invertRedstone: Boolean) : Block(Properties.of(Material.METAL).explosionResistance(12f).destroyTime(2f).requiresCorrectToolForDrops()) {
init {
registerDefaultState(stateDefinition.any().setValue(BlockStateProperties.LIT, true))
registerDefaultState(stateDefinition.any().setValue(BlockStateProperties.LIT, !invertRedstone))
}
override fun createBlockStateDefinition(builder: StateDefinition.Builder<Block, BlockState>) {
@ -104,7 +104,7 @@ class LaboratoryLamp : Block(Properties.of(Material.METAL).explosionResistance(1
}
override fun getStateForPlacement(context: BlockPlaceContext): BlockState {
return super.getStateForPlacement(context)!!.setValue(BlockStateProperties.LIT, true).setValue(RotatableMatteryBlock.FACING_FULL, context.nearestLookingDirection)
return super.getStateForPlacement(context)!!.setValue(BlockStateProperties.LIT, !invertRedstone).setValue(RotatableMatteryBlock.FACING_FULL, context.nearestLookingDirection)
}
@Suppress("OVERRIDE_DEPRECATION")
@ -130,7 +130,13 @@ class LaboratoryLamp : Block(Properties.of(Material.METAL).explosionResistance(1
return@once
val lit = state[BlockStateProperties.LIT]
val shouldBeLit = !level.hasNeighborSignal(pos)
val shouldBeLit: Boolean
if (invertRedstone) {
shouldBeLit = level.hasNeighborSignal(pos)
} else {
shouldBeLit = !level.hasNeighborSignal(pos)
}
if (lit != shouldBeLit) {
level.setBlockAndUpdate(pos, state.setValue(BlockStateProperties.LIT, shouldBeLit))

View File

@ -76,7 +76,8 @@ object MBlocks {
.requiresCorrectToolForDrops()
) }
val LABORATORY_LAMP: Block by registry.register(MNames.LABORATORY_LAMP) { LaboratoryLamp() }
val LABORATORY_LAMP: Block by registry.register(MNames.LABORATORY_LAMP) { LaboratoryLamp(false) }
val LABORATORY_LAMP_INVERTED: Block by registry.register(MNames.LABORATORY_LAMP_INVERTED) { LaboratoryLamp(true) }
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()) }

View File

@ -261,6 +261,7 @@ object MItems {
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 LABORATORY_LAMP_INVERTED: Item by registry.register(MNames.LABORATORY_LAMP_INVERTED) { BlockItem(MBlocks.LABORATORY_LAMP_INVERTED, 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) }

View File

@ -5,6 +5,7 @@ import ru.dbotthepony.mc.otm.OverdriveThatMatters
object MNames {
const val LABORATORY_LAMP = "laboratory_lamp"
const val LABORATORY_LAMP_INVERTED = "laboratory_lamp_inverted"
const val LABORATORY_LAMP_LIGHT = "laboratory_lamp_light"
const val DANGER_STRIPE_BLOCK = "danger_stripe_block"
const val METAL_BEAM = "metal_beam"