Colored Tritanium Pressure Plates

This commit is contained in:
DBotThePony 2022-10-05 18:43:42 +07:00
parent 6e41f338d3
commit c4c36fa55b
Signed by: DBot
GPG Key ID: DCC23B5715498507
10 changed files with 85 additions and 51 deletions

View File

@ -55,6 +55,7 @@ import ru.dbotthepony.mc.otm.datagen.tags.TagsProvider
import ru.dbotthepony.mc.otm.datagen.tags.addTags
import ru.dbotthepony.mc.otm.registry.objects.ColoredDecorativeBlock
import ru.dbotthepony.mc.otm.registry.objects.DecorativeBlock
import kotlin.properties.Delegates
fun modLocation(string: String) = ResourceLocation(DataGen.MOD_ID, string)
@ -146,9 +147,9 @@ object DataGen {
fun wall(block: WallBlock, sideTexture: String, topTexture: String) {
val name = block.registryName?.path ?: throw IllegalStateException("Invalid state of wall block $block")
var post: ModelFile? = null
var side: ModelFile? = null
var sideTall: ModelFile? = null
var post by Delegates.notNull<ModelFile>()
var side by Delegates.notNull<ModelFile>()
var sideTall by Delegates.notNull<ModelFile>()
blockModelProvider.exec {
post = blockModelProvider
@ -170,9 +171,9 @@ object DataGen {
blockStateProvider.exec {
blockStateProvider.wallBlock(
block,
checkNotNull(post) { "post model is null" },
checkNotNull(side) { "side model is null" },
checkNotNull(sideTall) { "sideTall model is null" },
post,
side,
sideTall,
)
}
}
@ -186,11 +187,11 @@ object DataGen {
val noside = "${name}_noside_ne"
val noside_alt = "${name}_noside_sw"
var mdl_post: ModelFile? = null
var mdl_side: ModelFile? = null
var mdl_side_alt: ModelFile? = null
var mdl_noside: ModelFile? = null
var mdl_noside_alt: ModelFile? = null
var mdl_post by Delegates.notNull<ModelFile>()
var mdl_side by Delegates.notNull<ModelFile>()
var mdl_side_alt by Delegates.notNull<ModelFile>()
var mdl_noside by Delegates.notNull<ModelFile>()
var mdl_noside_alt by Delegates.notNull<ModelFile>()
with(blockModelProvider) {
exec {
@ -204,12 +205,6 @@ object DataGen {
@Suppress("name_shadowing")
blockStateProvider.exec {
val mdl_post = checkNotNull(mdl_post) { "mdl_post is null" }
val mdl_side = checkNotNull(mdl_side) { "mdl_side is null" }
val mdl_side_alt = checkNotNull(mdl_side_alt) { "mdl_side_alt is null" }
val mdl_noside = checkNotNull(mdl_noside) { "mdl_noside is null" }
val mdl_noside_alt = checkNotNull(mdl_noside_alt) { "mdl_noside_alt is null" }
with(blockStateProvider.getMultipartBuilder(block)) {
part().modelFile(mdl_post).addModel()
part().modelFile(mdl_side).addModel().condition(IronBarsBlock.NORTH, true)
@ -225,14 +220,14 @@ object DataGen {
}
fun door(block: Block, textureTop: ResourceLocation, textureBottom: ResourceLocation) {
var doorBottomLeft: ModelFile? = null
var doorBottomLeftOpen: ModelFile? = null
var doorBottomRight: ModelFile? = null
var doorBottomRightOpen: ModelFile? = null
var doorTopLeft: ModelFile? = null
var doorTopLeftOpen: ModelFile? = null
var doorTopRight: ModelFile? = null
var doorTopRightOpen: ModelFile? = null
var doorBottomLeft by Delegates.notNull<ModelFile>()
var doorBottomLeftOpen by Delegates.notNull<ModelFile>()
var doorBottomRight by Delegates.notNull<ModelFile>()
var doorBottomRightOpen by Delegates.notNull<ModelFile>()
var doorTopLeft by Delegates.notNull<ModelFile>()
var doorTopLeftOpen by Delegates.notNull<ModelFile>()
var doorTopRight by Delegates.notNull<ModelFile>()
var doorTopRightOpen by Delegates.notNull<ModelFile>()
val doorBottomLeftName = "${block.registryName!!.path}_bl"
val doorBottomLeftOpenName = "${block.registryName!!.path}_blo"
@ -256,15 +251,6 @@ object DataGen {
@Suppress("name_shadowing")
blockStateProvider.exec {
val doorBottomLeft = checkNotNull(doorBottomLeft) { "doorBottomLeft is null" }
val doorBottomLeftOpen = checkNotNull(doorBottomLeftOpen) { "doorBottomLeftOpen is null" }
val doorBottomRight = checkNotNull(doorBottomRight) { "doorBottomRight is null" }
val doorBottomRightOpen = checkNotNull(doorBottomRightOpen) { "doorBottomRightOpen is null" }
val doorTopLeft = checkNotNull(doorTopLeft) { "doorTopLeft is null" }
val doorTopLeftOpen = checkNotNull(doorTopLeftOpen) { "doorTopLeftOpen is null" }
val doorTopRight = checkNotNull(doorTopRight) { "doorTopRight is null" }
val doorTopRightOpen = checkNotNull(doorTopRightOpen) { "doorTopRightOpen is null" }
with(blockStateProvider.getMultipartBuilder(block)) {
for (facing in DoorBlock.FACING.possibleValues) {
for (hinge in DoorBlock.HINGE.possibleValues) {
@ -307,9 +293,9 @@ object DataGen {
}
fun trapdoor(block: Block, texture: ResourceLocation) {
var trapdoorBottom: ModelFile? = null
var trapdoorTop: ModelFile? = null
var trapdoorOpen: ModelFile? = null
var trapdoorBottom by Delegates.notNull<ModelFile>()
var trapdoorTop by Delegates.notNull<ModelFile>()
var trapdoorOpen by Delegates.notNull<ModelFile>()
val trapdoorBottomName = "${block.registryName!!.path}_bottom"
val trapdoorTopName = "${block.registryName!!.path}_top"

View File

@ -1,11 +1,13 @@
package ru.dbotthepony.mc.otm.datagen
import net.minecraft.resources.ResourceLocation
import net.minecraft.world.level.block.PressurePlateBlock
import net.minecraft.world.level.block.SlabBlock
import net.minecraft.world.level.block.StairBlock
import net.minecraft.world.level.block.WallBlock
import net.minecraft.world.level.block.state.properties.BlockStateProperties
import net.minecraftforge.client.model.generators.ConfiguredModel
import net.minecraftforge.client.model.generators.ModelFile
import ru.dbotthepony.mc.otm.OverdriveThatMatters
import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock
import ru.dbotthepony.mc.otm.core.get
@ -18,6 +20,7 @@ import ru.dbotthepony.mc.otm.registry.MBlocks
import ru.dbotthepony.mc.otm.registry.MItems
import ru.dbotthepony.mc.otm.registry.MNames
import ru.dbotthepony.mc.otm.registry.MRegistry
import kotlin.properties.Delegates
fun addDecorativeData(blockStateProvider: MatteryBlockStateProvider, itemModelProvider: MatteryItemModelProvider, blockModelProvider: MatteryBlockModelProvider) {
for ((color, block) in MRegistry.DECORATIVE_CRATE.allBlocks) {
@ -38,6 +41,28 @@ fun addDecorativeData(blockStateProvider: MatteryBlockStateProvider, itemModelPr
DataGen.decorativeStairs(block as StairBlock, MRegistry.TRITANIUM_BLOCK.allBlocks[color]!!.registryName!!.path, MRegistry.TRITANIUM_BLOCK.allBlocks[color]!!.registryName!!.path)
}
for ((color, block) in MRegistry.TRITANIUM_PRESSURE_PLATE.allBlocks) {
val texture = modLocation(DataGen.DECORATIVE_BLOCK_LOCATION + "/" + MRegistry.TRITANIUM_BLOCK.allBlocks[color]!!.registryName!!.path)
var depressed by Delegates.notNull<ModelFile>()
var pressed by Delegates.notNull<ModelFile>()
blockModelProvider.exec {
depressed = blockModelProvider.pressurePlate(block.registryName!!.path, texture)
pressed = blockModelProvider.pressurePlateDown(block.registryName!!.path + "_pressed", texture)
}
blockStateProvider.exec {
blockStateProvider.getVariantBuilder(block)
.partialState().with(BlockStateProperties.POWERED, false).addModels(ConfiguredModel(depressed))
.partialState().with(BlockStateProperties.POWERED, true).addModels(ConfiguredModel(pressed))
}
}
for (item in MRegistry.TRITANIUM_PRESSURE_PLATE.allItems.values) {
itemModelProvider.block(item)
}
for ((color, block) in MRegistry.TRITANIUM_SLAB.allBlocks) {
blockStateProvider.exec {
blockStateProvider.slabBlock(

View File

@ -19,9 +19,19 @@ private fun decoratives(provider: MatteryLanguageProvider) {
provider.englishColors.add(MRegistry.CARGO_CRATES, "%s Cargo Crate")
provider.englishColors.add(MRegistry.DECORATIVE_CRATE, "%s Container Block")
for ((color, name) in provider.englishColors.dyeClassMapped) {
provider.english.add(MItems.CARGO_CRATE_MINECARTS[color]!!, "Minecart with $name Cargo Crate")
provider.english.add(MEntityTypes.CARGO_CRATE_MINECARTS[color]!!, "Minecart with $name Cargo Crate")
with (provider.english) {
for ((color, name) in provider.englishColors.dyeClassMapped) {
add(MItems.CARGO_CRATE_MINECARTS[color]!!, "Minecart with $name Cargo Crate")
add(MEntityTypes.CARGO_CRATE_MINECARTS[color]!!, "Minecart with $name Cargo Crate")
add(MRegistry.TRITANIUM_PRESSURE_PLATE.getBlock(color), "$name Tritanium Pressure Plate")
add(MRegistry.TRITANIUM_PRESSURE_PLATE.getBlock(color), "description0", "Activates only if player steps on it")
add(MRegistry.TRITANIUM_PRESSURE_PLATE.getBlock(color), "description1", "High blast resistance")
}
add(MRegistry.TRITANIUM_PRESSURE_PLATE.block, "Tritanium Pressure Plate")
add(MRegistry.TRITANIUM_PRESSURE_PLATE.block, "description0", "Activates only if player steps on it")
add(MRegistry.TRITANIUM_PRESSURE_PLATE.block, "description1", "High blast resistance")
}
provider.english.add(MItems.CARGO_CRATE_MINECARTS[null]!!, "Minecart with Cargo Crate")
@ -397,10 +407,6 @@ private fun blocks(provider: MatteryLanguageProvider) {
add(MBlocks.TRITANIUM_TRAPDOOR, "Tritanium Trapdoor")
add(MBlocks.TRITANIUM_TRAPDOOR, "description0", "High blast resistance door with redstone latch...")
add(MBlocks.TRITANIUM_TRAPDOOR, "description1", "...feeling safe now?")
add(MBlocks.TRITANIUM_PRESSURE_PLATE, "Tritanium Pressure Plate")
add(MBlocks.TRITANIUM_PRESSURE_PLATE, "description0", "Activates only if player steps on it")
add(MBlocks.TRITANIUM_PRESSURE_PLATE, "description1", "High blast resistance")
}
}

View File

@ -61,7 +61,7 @@ fun addLootTables(lootTables: LootTables) {
lootTables.dropsSelf(MBlocks.METAL_BEAM)
lootTables.dropsSelf(MBlocks.TRITANIUM_TRAPDOOR)
lootTables.dropsSelf(MBlocks.TRITANIUM_PRESSURE_PLATE)
lootTables.dropsSelf(MRegistry.TRITANIUM_PRESSURE_PLATE.allBlocks.values)
lootTables.blockSimple(MBlocks.PHANTOM_ATTRACTOR) {
it.add(LootItem.lootTableItem(MBlocks.PHANTOM_ATTRACTOR)

View File

@ -4,6 +4,7 @@ import net.minecraft.data.recipes.FinishedRecipe
import net.minecraft.data.recipes.ShapedRecipeBuilder
import net.minecraft.data.recipes.ShapelessRecipeBuilder
import net.minecraft.tags.ItemTags
import net.minecraft.world.item.DyeColor
import net.minecraft.world.item.ItemStack
import net.minecraft.world.item.Items
import net.minecraft.world.item.crafting.Ingredient
@ -67,11 +68,19 @@ fun addCraftingTableRecipes(consumer: Consumer<FinishedRecipe>) {
.unlockedBy(MItemTags.TRITANIUM_PLATES)
.build(consumer)
MatteryRecipe(MBlocks.TRITANIUM_PRESSURE_PLATE)
MatteryRecipe(MRegistry.TRITANIUM_PRESSURE_PLATE.item)
.row(MItemTags.TRITANIUM_PLATES, MItemTags.BASIC_CIRCUIT, MItemTags.TRITANIUM_PLATES)
.unlockedBy(MItemTags.TRITANIUM_PLATES)
.build(consumer)
for (dye in DyeColor.values()) {
ShapelessRecipeBuilder(MRegistry.TRITANIUM_PRESSURE_PLATE.getItem(dye), 1)
.requires(Ingredient.of(MRegistry.TRITANIUM_PRESSURE_PLATE.allItems.entries.stream().filter { it.key != dye }.map { ItemStack(it.value) }))
.requires(dye.tag)
.unlockedBy(MItemTags.TRITANIUM_PLATES)
.save(consumer)
}
MatteryRecipe(MBlocks.PLATE_PRESS)
.row(MItems.ELECTRIC_PARTS, MItems.ENERGY_BUS, MItems.ELECTRIC_PARTS)
.row(MItemTags.TRITANIUM_INGOTS, Items.BLAST_FURNACE, MItemTags.TRITANIUM_INGOTS)

View File

@ -72,6 +72,8 @@ fun addTags(tagsProvider: TagsProvider) {
tagsProvider.items.appender(ItemTags.TRAPDOORS).add(MItems.TRITANIUM_TRAPDOOR)
tagsProvider.blocks.appender(BlockTags.TRAPDOORS).add(MBlocks.TRITANIUM_TRAPDOOR)
tagsProvider.blocks.appender(BlockTags.PRESSURE_PLATES).add(MRegistry.TRITANIUM_PRESSURE_PLATE.allBlocks.values)
tagsProvider.items.appender(MItemTags.MACHINES).add(MItems.MACHINES)
tagsProvider.blocks.appender(MBlockTags.MACHINES).add(MItems.MACHINES.stream().map { it as? BlockItem }.filter { it != null }.map { it!!.block })
@ -124,7 +126,6 @@ fun addTags(tagsProvider: TagsProvider) {
MBlocks.TRITANIUM_DOOR,
MBlocks.TRITANIUM_TRAPDOOR,
MBlocks.TRITANIUM_PRESSURE_PLATE,
MBlocks.TRITANIUM_INGOT_BLOCK,
), Tiers.IRON)
@ -145,6 +146,7 @@ fun addTags(tagsProvider: TagsProvider) {
tagsProvider.requiresPickaxe(MRegistry.TRITANIUM_BLOCK.allBlocks.values, Tiers.IRON)
tagsProvider.requiresPickaxe(MRegistry.TRITANIUM_SLAB.allBlocks.values, Tiers.IRON)
tagsProvider.requiresPickaxe(MRegistry.TRITANIUM_WALL.allBlocks.values, Tiers.IRON)
tagsProvider.requiresPickaxe(MRegistry.TRITANIUM_PRESSURE_PLATE.allBlocks.values, Tiers.IRON)
tagsProvider.requiresPickaxe(MRegistry.TRITANIUM_STAIRS.allBlocks.values, Tiers.IRON)
tagsProvider.requiresPickaxe(MRegistry.TRITANIUM_STRIPED_BLOCK.flatBlocks, Tiers.IRON)
tagsProvider.requiresPickaxe(MRegistry.TRITANIUM_STRIPED_STAIRS.flatBlocks, Tiers.IRON)

View File

@ -21,7 +21,7 @@ import net.minecraft.world.level.material.Material
import ru.dbotthepony.mc.otm.core.TranslatableComponent
import ru.dbotthepony.mc.otm.core.get
class TritaniumPressurePlate : BasePressurePlateBlock(Properties.of(Material.METAL, DyeColor.LIGHT_BLUE).explosionResistance(80f).noOcclusion().destroyTime(3f).requiresCorrectToolForDrops()) {
class TritaniumPressurePlate(color: DyeColor?) : BasePressurePlateBlock(Properties.of(Material.METAL, color ?: DyeColor.LIGHT_BLUE).explosionResistance(80f).noOcclusion().destroyTime(3f).requiresCorrectToolForDrops()) {
override fun appendHoverText(
p_49816_: ItemStack,
p_49817_: BlockGetter?,

View File

@ -156,9 +156,9 @@ object MBlocks {
}
} }
val TRITANIUM_PRESSURE_PLATE: Block by registry.register(MNames.TRITANIUM_PRESSURE_PLATE) { TritaniumPressurePlate() }
init {
MRegistry.TRITANIUM_PRESSURE_PLATE.registerBlocks(registry)
MRegistry.CARGO_CRATES.registerBlocks(registry)
MRegistry.TRITANIUM_BLOCK.registerBlocks(registry)
MRegistry.TRITANIUM_STAIRS.registerBlocks(registry)

View File

@ -236,7 +236,10 @@ object MItems {
val TRITANIUM_DOOR: Item by registry.register(MNames.TRITANIUM_DOOR) { DoubleHighBlockItem(MBlocks.TRITANIUM_DOOR, DEFAULT_PROPERTIES_DECORATIVE) }
val TRITANIUM_TRAPDOOR: Item by registry.register(MNames.TRITANIUM_TRAPDOOR) { BlockItem(MBlocks.TRITANIUM_TRAPDOOR, DEFAULT_PROPERTIES_DECORATIVE) }
val TRITANIUM_PRESSURE_PLATE: Item by registry.register(MNames.TRITANIUM_PRESSURE_PLATE) { BlockItem(MBlocks.TRITANIUM_PRESSURE_PLATE, DEFAULT_PROPERTIES_DECORATIVE) }
init {
MRegistry.TRITANIUM_PRESSURE_PLATE.registerItems(registry)
}
// components
val MATTER_IO_PORT: Item by registry.register(MNames.MATTER_IO_PORT) { Item(DEFAULT_PROPERTIES) }

View File

@ -33,6 +33,7 @@ import ru.dbotthepony.mc.otm.android.feature.JumpBoostFeature
import ru.dbotthepony.mc.otm.android.feature.NanobotsArmorFeature
import ru.dbotthepony.mc.otm.android.feature.ShockwaveFeature
import ru.dbotthepony.mc.otm.block.CargoCrateBlock
import ru.dbotthepony.mc.otm.block.TritaniumPressurePlate
import ru.dbotthepony.mc.otm.capability.matteryEnergy
import ru.dbotthepony.mc.otm.core.ImpreciseFraction
import ru.dbotthepony.mc.otm.item.EnergySwordItem
@ -150,6 +151,8 @@ object MRegistry {
WallBlock(BlockBehaviour.Properties.copy(TRITANIUM_BLOCK.allBlocks[it]!!))
})
val TRITANIUM_PRESSURE_PLATE = DecorativeBlock(MNames.TRITANIUM_PRESSURE_PLATE, ::TritaniumPressurePlate)
val VENT = DecorativeBlock.simple(MNames.VENT, {
BlockBehaviour.Properties.of(Material.METAL, it?.materialColor ?: MaterialColor.COLOR_LIGHT_BLUE)
.sound(SoundType.BASALT)