Door ❓
This commit is contained in:
parent
dfb93f65f1
commit
54e19dc78d
@ -10,9 +10,11 @@ import net.minecraft.advancements.critereon.StatePropertiesPredicate
|
|||||||
import net.minecraft.data.DataGenerator
|
import net.minecraft.data.DataGenerator
|
||||||
import net.minecraft.data.loot.LootTableProvider
|
import net.minecraft.data.loot.LootTableProvider
|
||||||
import net.minecraft.resources.ResourceLocation
|
import net.minecraft.resources.ResourceLocation
|
||||||
|
import net.minecraft.util.StringRepresentable
|
||||||
import net.minecraft.world.level.ItemLike
|
import net.minecraft.world.level.ItemLike
|
||||||
import net.minecraft.world.level.block.Block
|
import net.minecraft.world.level.block.Block
|
||||||
import net.minecraft.world.level.block.SlabBlock
|
import net.minecraft.world.level.block.SlabBlock
|
||||||
|
import net.minecraft.world.level.block.state.properties.Property
|
||||||
import net.minecraft.world.level.block.state.properties.SlabType
|
import net.minecraft.world.level.block.state.properties.SlabType
|
||||||
import net.minecraft.world.level.storage.loot.LootPool
|
import net.minecraft.world.level.storage.loot.LootPool
|
||||||
import net.minecraft.world.level.storage.loot.LootTable
|
import net.minecraft.world.level.storage.loot.LootTable
|
||||||
@ -24,6 +26,7 @@ import net.minecraft.world.level.storage.loot.functions.SetItemCountFunction
|
|||||||
import net.minecraft.world.level.storage.loot.parameters.LootContextParamSet
|
import net.minecraft.world.level.storage.loot.parameters.LootContextParamSet
|
||||||
import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets
|
import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets
|
||||||
import net.minecraft.world.level.storage.loot.predicates.LootItemBlockStatePropertyCondition
|
import net.minecraft.world.level.storage.loot.predicates.LootItemBlockStatePropertyCondition
|
||||||
|
import net.minecraft.world.level.storage.loot.predicates.LootItemCondition
|
||||||
import net.minecraft.world.level.storage.loot.providers.nbt.ContextNbtProvider
|
import net.minecraft.world.level.storage.loot.providers.nbt.ContextNbtProvider
|
||||||
import net.minecraft.world.level.storage.loot.providers.number.ConstantValue
|
import net.minecraft.world.level.storage.loot.providers.number.ConstantValue
|
||||||
import net.minecraft.world.level.storage.loot.providers.number.UniformGenerator
|
import net.minecraft.world.level.storage.loot.providers.number.UniformGenerator
|
||||||
@ -33,6 +36,7 @@ import ru.dbotthepony.mc.otm.core.registryName
|
|||||||
import java.util.function.BiConsumer
|
import java.util.function.BiConsumer
|
||||||
import java.util.function.Consumer
|
import java.util.function.Consumer
|
||||||
import java.util.function.Supplier
|
import java.util.function.Supplier
|
||||||
|
import kotlin.reflect.full.isSubclassOf
|
||||||
|
|
||||||
private typealias LootTableSaver = BiConsumer<ResourceLocation, LootTable.Builder>
|
private typealias LootTableSaver = BiConsumer<ResourceLocation, LootTable.Builder>
|
||||||
private typealias LootTableCallback = Consumer<LootTableSaver>
|
private typealias LootTableCallback = Consumer<LootTableSaver>
|
||||||
@ -65,6 +69,27 @@ fun <T : LootPoolSingletonContainer.Builder<*>> T.setCount(minimal: Float, maxim
|
|||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun <T : LootPoolSingletonContainer.Builder<*>> T.condition(condition: LootItemCondition.Builder): T {
|
||||||
|
`when`(condition)
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
inline fun <T : LootPoolSingletonContainer.Builder<*>> T.blockStateCondition(block: Block, configurator: StatePropertiesPredicate.Builder.() -> Unit): T {
|
||||||
|
condition(LootItemBlockStatePropertyCondition.hasBlockStateProperties(block).setProperties(StatePropertiesPredicate.Builder.properties().also(configurator)))
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
operator fun StatePropertiesPredicate.Builder.set(property: Property<*>, value: String): StatePropertiesPredicate.Builder = hasProperty(property, value)
|
||||||
|
operator fun StatePropertiesPredicate.Builder.set(property: Property<Int>, value: Int): StatePropertiesPredicate.Builder = hasProperty(property, value)
|
||||||
|
operator fun StatePropertiesPredicate.Builder.set(property: Property<Boolean>, value: Boolean): StatePropertiesPredicate.Builder = hasProperty(property, value)
|
||||||
|
operator fun <T : Comparable<T>> StatePropertiesPredicate.Builder.set(property: Property<T>, value: T): StatePropertiesPredicate.Builder {
|
||||||
|
if (value !is StringRepresentable) {
|
||||||
|
throw ClassCastException("Provided type ${value::class.qualifiedName} is not a subtype of ${StringRepresentable::class.qualifiedName}")
|
||||||
|
}
|
||||||
|
|
||||||
|
return hasProperty(property, value.serializedName)
|
||||||
|
}
|
||||||
|
|
||||||
data class NbtCopy(val source: String, val destination: String, val strategy: CopyNbtFunction.MergeStrategy = CopyNbtFunction.MergeStrategy.REPLACE)
|
data class NbtCopy(val source: String, val destination: String, val strategy: CopyNbtFunction.MergeStrategy = CopyNbtFunction.MergeStrategy.REPLACE)
|
||||||
|
|
||||||
fun TileNbtCopy(source: String, strategy: CopyNbtFunction.MergeStrategy = CopyNbtFunction.MergeStrategy.REPLACE): NbtCopy {
|
fun TileNbtCopy(source: String, strategy: CopyNbtFunction.MergeStrategy = CopyNbtFunction.MergeStrategy.REPLACE): NbtCopy {
|
||||||
|
@ -7,7 +7,6 @@ import net.minecraft.world.level.block.state.properties.BlockStateProperties
|
|||||||
import net.minecraft.world.level.block.state.properties.DoubleBlockHalf
|
import net.minecraft.world.level.block.state.properties.DoubleBlockHalf
|
||||||
import net.minecraft.world.level.storage.loot.entries.LootItem
|
import net.minecraft.world.level.storage.loot.entries.LootItem
|
||||||
import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets
|
import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets
|
||||||
import net.minecraft.world.level.storage.loot.predicates.LootItemBlockStatePropertyCondition
|
|
||||||
import ru.dbotthepony.mc.otm.block.entity.ChemicalGeneratorBlockEntity
|
import ru.dbotthepony.mc.otm.block.entity.ChemicalGeneratorBlockEntity
|
||||||
import ru.dbotthepony.mc.otm.block.entity.EnergyCounterBlockEntity
|
import ru.dbotthepony.mc.otm.block.entity.EnergyCounterBlockEntity
|
||||||
import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity.Companion.ENERGY_KEY
|
import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity.Companion.ENERGY_KEY
|
||||||
@ -64,11 +63,19 @@ fun addLootTables(lootTables: LootTables) {
|
|||||||
lootTables.dropsSelf(MRegistry.TRITANIUM_PRESSURE_PLATE.allBlocks.values)
|
lootTables.dropsSelf(MRegistry.TRITANIUM_PRESSURE_PLATE.allBlocks.values)
|
||||||
|
|
||||||
lootTables.block(MBlocks.PHANTOM_ATTRACTOR) {
|
lootTables.block(MBlocks.PHANTOM_ATTRACTOR) {
|
||||||
add(LootItem.lootTableItem(MBlocks.PHANTOM_ATTRACTOR)
|
item(MBlocks.PHANTOM_ATTRACTOR) {
|
||||||
.`when`(LootItemBlockStatePropertyCondition
|
blockStateCondition(MBlocks.PHANTOM_ATTRACTOR) {
|
||||||
.hasBlockStateProperties(MBlocks.PHANTOM_ATTRACTOR)
|
this[BlockStateProperties.DOUBLE_BLOCK_HALF] = DoubleBlockHalf.LOWER
|
||||||
.setProperties(StatePropertiesPredicate.Builder.properties()
|
}
|
||||||
.hasProperty(BlockStateProperties.DOUBLE_BLOCK_HALF, DoubleBlockHalf.LOWER))))
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
lootTables.block(MBlocks.TRITANIUM_DOOR) {
|
||||||
|
item(MBlocks.TRITANIUM_DOOR) {
|
||||||
|
blockStateCondition(MBlocks.TRITANIUM_DOOR) {
|
||||||
|
this[BlockStateProperties.DOUBLE_BLOCK_HALF] = DoubleBlockHalf.LOWER
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
lootTables.builder(LootContextParamSets.ADVANCEMENT_ENTITY, modLocation("research_all_android")) {
|
lootTables.builder(LootContextParamSets.ADVANCEMENT_ENTITY, modLocation("research_all_android")) {
|
||||||
@ -151,8 +158,4 @@ fun addLootTables(lootTables: LootTables) {
|
|||||||
lootTables.basicTile(MBlocks.MATTER_CAPACITOR_BANK)
|
lootTables.basicTile(MBlocks.MATTER_CAPACITOR_BANK)
|
||||||
lootTables.poweredTile(MBlocks.MATTER_BOTTLER,
|
lootTables.poweredTile(MBlocks.MATTER_BOTTLER,
|
||||||
TileNbtCopy(MATTER_STORAGE_KEY), TileNbtCopy(MatterBottlerBlockEntity.IS_BOTTLING_KEY))
|
TileNbtCopy(MATTER_STORAGE_KEY), TileNbtCopy(MatterBottlerBlockEntity.IS_BOTTLING_KEY))
|
||||||
|
|
||||||
lootTables.blockProvider(MBlocks.TRITANIUM_DOOR) {
|
|
||||||
BlockLoot.createDoorTable(MBlocks.TRITANIUM_DOOR)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user