From 8c7c3de01cb5fbdd1253595280ce23dc59713f4c Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 9 Sep 2022 11:50:00 +0700 Subject: [PATCH] Inverted redstone signal laboratory lamp --- .../dbotthepony/mc/otm/datagen/DecorativeData.kt | 9 +++++++++ .../dbotthepony/mc/otm/datagen/lang/English.kt | 1 + .../mc/otm/datagen/loot/LootTablesData.kt | 1 + .../mc/otm/datagen/recipes/DecorativesRecipes.kt | 11 +++++++++++ .../ru/dbotthepony/mc/otm/datagen/tags/Tags.kt | 1 + .../dbotthepony/mc/otm/block/LaboratoryLamp.kt | 16 +++++++++++----- .../ru/dbotthepony/mc/otm/registry/MBlocks.kt | 3 ++- .../ru/dbotthepony/mc/otm/registry/MItems.kt | 1 + .../ru/dbotthepony/mc/otm/registry/MNames.kt | 1 + 9 files changed, 38 insertions(+), 6 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DecorativeData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DecorativeData.kt index aea07bb2b..26af33d14 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DecorativeData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DecorativeData.kt @@ -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 { diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt index 58815441f..a7cdfc508 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt @@ -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") } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt index 0e065fe97..52f1a1b4f 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt @@ -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) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/DecorativesRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/DecorativesRecipes.kt index 7b16a0e66..62a39cb3d 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/DecorativesRecipes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/DecorativesRecipes.kt @@ -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) { @@ -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)) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt index d5552d669..3242d41f4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt @@ -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()) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt index 2ffa34490..77f983277 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt @@ -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) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt index 966c7e53a..dd353eeb9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt @@ -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"