package ru.dbotthepony.mc.otm.datagen.loot

import net.minecraft.world.level.block.state.properties.BlockStateProperties
import net.minecraft.world.level.block.state.properties.DoubleBlockHalf
import net.minecraft.world.level.storage.loot.predicates.ExplosionCondition
import ru.dbotthepony.mc.otm.registry.game.MBlocks

fun addMachineLoot(lootTables: LootTables) {
	lootTables.block(MBlocks.PHANTOM_ATTRACTOR) {
		item(MBlocks.PHANTOM_ATTRACTOR) {
			blockStateCondition(MBlocks.PHANTOM_ATTRACTOR) {
				this[BlockStateProperties.DOUBLE_BLOCK_HALF] = DoubleBlockHalf.LOWER
			}
		}

		condition(ExplosionCondition.survivesExplosion())
	}

	lootTables.dropsSelf(MBlocks.INFINITE_WATER_SOURCE) { condition(ExplosionCondition.survivesExplosion()) }

	lootTables.tile(MBlocks.COBBLESTONE_GENERATOR.values)
	lootTables.tile(MBlocks.ESSENCE_STORAGE.values)
	lootTables.tile(MBlocks.MATTER_RECONSTRUCTOR.values)
	lootTables.tile(MBlocks.FLUID_TANK)
	lootTables.tile(MBlocks.PAINTER)
	lootTables.tile(MBlocks.MATTER_ENTANGLER)
	lootTables.tile(MBlocks.GRILL.values)

	lootTables.tile(MBlocks.ENERGY_SERVO.values)
	lootTables.tile(MBlocks.ENERGY_COUNTER.values)
	lootTables.tile(MBlocks.CHEMICAL_GENERATOR.values)
	lootTables.tile(MBlocks.HOLO_SIGN, "isLocked")
	lootTables.tile(MBlocks.STORAGE_CABLE)
	lootTables.tile(MBlocks.ANDROID_STATION.values)
	lootTables.tile(MBlocks.ANDROID_CHARGER.values)
	lootTables.tile(MBlocks.BATTERY_BANK.values)
	lootTables.tile(MBlocks.DRIVE_VIEWER.values)

	lootTables.tile(MBlocks.STORAGE_BUS)
	lootTables.tile(MBlocks.STORAGE_IMPORTER)
	lootTables.tile(MBlocks.STORAGE_EXPORTER)
	lootTables.tile(MBlocks.STORAGE_POWER_SUPPLIER.values)
	lootTables.tile(MBlocks.DRIVE_RACK)

	lootTables.tile(MBlocks.MATTER_DECOMPOSER.values)
	lootTables.tile(MBlocks.MATTER_REPLICATOR.values)
	lootTables.tile(MBlocks.MATTER_RECYCLER.values)
	lootTables.tile(MBlocks.MATTER_SCANNER.values)
	lootTables.tile(MBlocks.PLATE_PRESS.values)
	lootTables.tile(MBlocks.TWIN_PLATE_PRESS.values)

	lootTables.tile(MBlocks.POWERED_FURNACE.values)
	lootTables.tile(MBlocks.POWERED_SMOKER.values)
	lootTables.tile(MBlocks.POWERED_BLAST_FURNACE.values)

	lootTables.tile(MBlocks.MATTER_PANEL.values)
	lootTables.tile(MBlocks.PATTERN_STORAGE)
	lootTables.tile(MBlocks.MATTER_CAPACITOR_BANK.values)
	lootTables.tile(MBlocks.MATTER_BOTTLER.values)

	lootTables.tile(MBlocks.BLACK_HOLE_GENERATOR)

	lootTables.tile(MBlocks.FLYWHEEL_BATTERY)

	lootTables.dropsSelf(listOf(
		MBlocks.MATTER_INJECTOR,
		MBlocks.ANTIMATTER_INJECTOR,
		MBlocks.HIGH_ENERGY_PARTICLE_COLLECTOR
	)) { condition(ExplosionCondition.survivesExplosion()) }

	lootTables.tile(MBlocks.ITEM_INPUT_HATCH)
	lootTables.tile(MBlocks.ITEM_OUTPUT_HATCH)

	lootTables.tile(MBlocks.ENERGY_INPUT_HATCH)
	lootTables.tile(MBlocks.ENERGY_OUTPUT_HATCH)

	lootTables.tile(MBlocks.MATTER_INPUT_HATCH)
	lootTables.tile(MBlocks.MATTER_OUTPUT_HATCH)

	lootTables.tile(MBlocks.ENERGY_INPUT_INTERFACE)
	lootTables.tile(MBlocks.ENERGY_OUTPUT_INTERFACE)
}
