mirror of
https://github.com/chylex/Hardcore-Ender-Expansion-2.git
synced 2025-04-08 03:15:50 +02:00
Add custom block/item interfaces for automatic property registrations and datagen (block drops)
This commit is contained in:
parent
322b6ba900
commit
bb13594c4f
data
gen
src/main/java/chylex/hee/datagen/server
modules/system/src/main/java/chylex/hee/game/block
src/main/java/chylex/hee/game/block
BlockAbstractCauldron.ktBlockAbstractGoo.ktBlockAncientCobweb.ktBlockBrewingStandCustom.ktBlockDarkChest.ktBlockDeathFlowerDecaying.ktBlockDryVines.ktBlockDustyStoneUnstable.ktBlockEndPowderOre.ktBlockEndersol.ktBlockEternalFire.ktBlockFallingObsidian.ktBlockFlowerPotCustom.ktBlockFlowerPotDeathFlowerDecaying.ktBlockGraveDirt.ktBlockHumus.ktBlockIgneousRockOre.ktBlockInfusedGlass.ktBlockInfusedTNT.ktBlockJarODust.ktBlockLootChest.ktBlockPuzzleLogic.ktBlockSkullCustom.ktBlockSpawnerObsidianTowers.ktBlockStardustOre.ktBlockWhitebarkLeaves.kt
properties
@ -515,6 +515,7 @@ d9abd1ed1cc52d7f8c1b48896da855b2e8bded23 data/hee/loot_tables/blocks/dusty_stone
|
||||
ef63046d109846e09f43eaa0fbd322889d31d3c3 data/hee/loot_tables/blocks/dusty_stone_brick_stairs.json
|
||||
fd7e4cb74c69e176813fd0cddef9c4c98847eacc data/hee/loot_tables/blocks/dusty_stone_bricks.json
|
||||
e891c4099dec492133fc58662765c326b00f1e09 data/hee/loot_tables/blocks/dusty_stone_cracked_bricks.json
|
||||
de6d8d0b775f590077634afc913165c831192070 data/hee/loot_tables/blocks/dusty_stone_decoration.json
|
||||
5ca27ed38494044939def58dae0354d0cb09baad data/hee/loot_tables/blocks/end_stone_burned.json
|
||||
c50fb5765d11b9f46dd81f2d9c33d4d0b6bb1402 data/hee/loot_tables/blocks/end_stone_enchanted.json
|
||||
7d720082305ddef2d864263bf58c55a67549cbeb data/hee/loot_tables/blocks/end_stone_infested.json
|
||||
|
@ -0,0 +1,19 @@
|
||||
{
|
||||
"type": "minecraft:block",
|
||||
"pools": [
|
||||
{
|
||||
"rolls": 1,
|
||||
"entries": [
|
||||
{
|
||||
"type": "minecraft:item",
|
||||
"name": "hee:dusty_stone_decoration"
|
||||
}
|
||||
],
|
||||
"conditions": [
|
||||
{
|
||||
"condition": "minecraft:survives_explosion"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
@ -1,99 +1,43 @@
|
||||
package chylex.hee.datagen.server
|
||||
|
||||
import chylex.hee.HEE
|
||||
import chylex.hee.datagen.server.util.BlockLootTableProvider
|
||||
import chylex.hee.game.block.IHeeBlock
|
||||
import chylex.hee.game.block.properties.BlockDrop
|
||||
import chylex.hee.game.block.properties.BlockDrop.FlowerPot
|
||||
import chylex.hee.game.block.properties.BlockDrop.Manual
|
||||
import chylex.hee.game.block.properties.BlockDrop.NamedTile
|
||||
import chylex.hee.game.block.properties.BlockDrop.Nothing
|
||||
import chylex.hee.game.block.properties.BlockDrop.OneOf
|
||||
import chylex.hee.game.block.properties.BlockDrop.Self
|
||||
import chylex.hee.init.ModBlocks
|
||||
import chylex.hee.init.ModItems
|
||||
import net.minecraft.block.Blocks
|
||||
import chylex.hee.system.getRegistryEntries
|
||||
import net.minecraft.block.Block
|
||||
import net.minecraft.block.FlowerPotBlock
|
||||
import net.minecraft.data.DataGenerator
|
||||
import net.minecraft.loot.LootTables
|
||||
|
||||
class BlockLootTables(generator: DataGenerator) : BlockLootTableProvider(generator) {
|
||||
override val consumer = object : RegistrationConsumer() {
|
||||
override fun addTables() {
|
||||
dropSelf(ModBlocks.ACCUMULATION_TABLE_TIER_1)
|
||||
dropSelf(ModBlocks.ACCUMULATION_TABLE_TIER_2)
|
||||
dropSelf(ModBlocks.ACCUMULATION_TABLE_TIER_3)
|
||||
dropSelf(ModBlocks.DARK_LOAM)
|
||||
dropSelf(ModBlocks.DARK_LOAM_SLAB)
|
||||
dropSelf(ModBlocks.DEATH_FLOWER_HEALED)
|
||||
dropSelf(ModBlocks.DEATH_FLOWER_WITHERED)
|
||||
dropSelf(ModBlocks.DUSTY_STONE_BRICKS)
|
||||
dropSelf(ModBlocks.DUSTY_STONE_BRICK_SLAB)
|
||||
dropSelf(ModBlocks.DUSTY_STONE_BRICK_STAIRS)
|
||||
dropSelf(ModBlocks.DUSTY_STONE_CRACKED_BRICKS)
|
||||
dropSelf(ModBlocks.ENDIUM_BLOCK)
|
||||
dropSelf(ModBlocks.ENDIUM_ORE)
|
||||
dropSelf(ModBlocks.END_STONE_BURNED)
|
||||
dropSelf(ModBlocks.END_STONE_ENCHANTED)
|
||||
dropSelf(ModBlocks.END_STONE_INFESTED)
|
||||
dropSelf(ModBlocks.ETHEREAL_LANTERN)
|
||||
dropSelf(ModBlocks.EXPERIENCE_TABLE_TIER_1)
|
||||
dropSelf(ModBlocks.EXPERIENCE_TABLE_TIER_2)
|
||||
dropSelf(ModBlocks.EXPERIENCE_TABLE_TIER_3)
|
||||
dropSelf(ModBlocks.GLOOMROCK)
|
||||
dropSelf(ModBlocks.GLOOMROCK_BRICKS)
|
||||
dropSelf(ModBlocks.GLOOMROCK_BRICK_SLAB)
|
||||
dropSelf(ModBlocks.GLOOMROCK_BRICK_STAIRS)
|
||||
dropSelf(ModBlocks.GLOOMROCK_SMOOTH)
|
||||
dropSelf(ModBlocks.GLOOMROCK_SMOOTH_BLUE)
|
||||
dropSelf(ModBlocks.GLOOMROCK_SMOOTH_CYAN)
|
||||
dropSelf(ModBlocks.GLOOMROCK_SMOOTH_GREEN)
|
||||
dropSelf(ModBlocks.GLOOMROCK_SMOOTH_MAGENTA)
|
||||
dropSelf(ModBlocks.GLOOMROCK_SMOOTH_ORANGE)
|
||||
dropSelf(ModBlocks.GLOOMROCK_SMOOTH_PURPLE)
|
||||
dropSelf(ModBlocks.GLOOMROCK_SMOOTH_RED)
|
||||
dropSelf(ModBlocks.GLOOMROCK_SMOOTH_SLAB)
|
||||
dropSelf(ModBlocks.GLOOMROCK_SMOOTH_STAIRS)
|
||||
dropSelf(ModBlocks.GLOOMROCK_SMOOTH_WHITE)
|
||||
dropSelf(ModBlocks.GLOOMROCK_SMOOTH_YELLOW)
|
||||
dropSelf(ModBlocks.GLOOMTORCH)
|
||||
dropSelf(ModBlocks.IGNEOUS_PLATE)
|
||||
dropSelf(ModBlocks.INFUSION_TABLE_TIER_1)
|
||||
dropSelf(ModBlocks.INFUSION_TABLE_TIER_2)
|
||||
dropSelf(ModBlocks.INFUSION_TABLE_TIER_3)
|
||||
dropSelf(ModBlocks.MINERS_BURIAL_BLOCK_CHISELED)
|
||||
dropSelf(ModBlocks.MINERS_BURIAL_BLOCK_PILLAR)
|
||||
dropSelf(ModBlocks.MINERS_BURIAL_BLOCK_PLAIN)
|
||||
dropSelf(ModBlocks.OBSIDIAN_CHISELED)
|
||||
dropSelf(ModBlocks.OBSIDIAN_CHISELED_LIT)
|
||||
dropSelf(ModBlocks.OBSIDIAN_PILLAR)
|
||||
dropSelf(ModBlocks.OBSIDIAN_PILLAR_LIT)
|
||||
dropSelf(ModBlocks.OBSIDIAN_SMOOTH)
|
||||
dropSelf(ModBlocks.OBSIDIAN_SMOOTH_LIT)
|
||||
dropSelf(ModBlocks.OBSIDIAN_STAIRS)
|
||||
dropSelf(ModBlocks.STONE_BRICK_WALL)
|
||||
dropSelf(ModBlocks.TABLE_BASE_TIER_1)
|
||||
dropSelf(ModBlocks.TABLE_BASE_TIER_2)
|
||||
dropSelf(ModBlocks.TABLE_BASE_TIER_3)
|
||||
dropSelf(ModBlocks.TABLE_PEDESTAL)
|
||||
dropSelf(ModBlocks.VANTABLOCK)
|
||||
dropSelf(ModBlocks.VOID_PORTAL_FRAME_CRAFTED)
|
||||
dropSelf(ModBlocks.VOID_PORTAL_STORAGE_CRAFTED)
|
||||
dropSelf(ModBlocks.WHITEBARK)
|
||||
dropSelf(ModBlocks.WHITEBARK_LOG)
|
||||
dropSelf(ModBlocks.WHITEBARK_PLANKS)
|
||||
dropSelf(ModBlocks.WHITEBARK_SAPLING_AUTUMN_BROWN)
|
||||
dropSelf(ModBlocks.WHITEBARK_SAPLING_AUTUMN_ORANGE)
|
||||
dropSelf(ModBlocks.WHITEBARK_SAPLING_AUTUMN_RED)
|
||||
dropSelf(ModBlocks.WHITEBARK_SAPLING_AUTUMN_YELLOWGREEN)
|
||||
dropSelf(ModBlocks.WHITEBARK_SLAB)
|
||||
dropSelf(ModBlocks.WHITEBARK_STAIRS)
|
||||
for (block in getRegistryEntries<Block>(ModBlocks)) {
|
||||
(block as? IHeeBlock)?.let { registerDrop(block, it.drop) }
|
||||
}
|
||||
}
|
||||
|
||||
private fun registerDrop(block: Block, drop: BlockDrop) {
|
||||
if (block.lootTable == LootTables.EMPTY && drop != Nothing) {
|
||||
HEE.log.error("[BlockLootTables] block has empty loot table but declares drops: " + block.registryName)
|
||||
return
|
||||
}
|
||||
|
||||
dropFunc(ModBlocks.DARK_CHEST, withName)
|
||||
dropFunc(ModBlocks.ENHANCED_BREWING_STAND, withName)
|
||||
|
||||
dropOther(ModBlocks.CAULDRON_DRAGONS_BREATH, Blocks.CAULDRON)
|
||||
dropOther(ModBlocks.CAULDRON_ENDER_GOO, Blocks.CAULDRON)
|
||||
dropOther(ModBlocks.CAULDRON_PURIFIED_ENDER_GOO, Blocks.CAULDRON)
|
||||
dropOther(ModBlocks.ENDERMAN_HEAD, ModItems.ENDERMAN_HEAD)
|
||||
dropOther(ModBlocks.ENDERMAN_WALL_HEAD, ModItems.ENDERMAN_HEAD)
|
||||
dropOther(ModBlocks.OBSIDIAN_FALLING, Blocks.OBSIDIAN)
|
||||
|
||||
dropFlowerPot(ModBlocks.POTTED_DEATH_FLOWER_HEALED)
|
||||
dropFlowerPot(ModBlocks.POTTED_DEATH_FLOWER_WITHERED)
|
||||
dropFlowerPot(ModBlocks.POTTED_WHITEBARK_SAPLING_AUTUMN_BROWN)
|
||||
dropFlowerPot(ModBlocks.POTTED_WHITEBARK_SAPLING_AUTUMN_ORANGE)
|
||||
dropFlowerPot(ModBlocks.POTTED_WHITEBARK_SAPLING_AUTUMN_YELLOWGREEN)
|
||||
dropFlowerPot(ModBlocks.POTTED_WHITEBARK_SAPLING_AUTUMN_RED)
|
||||
when (drop) {
|
||||
Nothing, Manual -> return
|
||||
Self -> registerDropSelfLootTable(block)
|
||||
NamedTile -> registerLootTable(block, withName)
|
||||
FlowerPot -> registerFlowerPot(block as FlowerPotBlock)
|
||||
is OneOf -> registerDropping(block, drop.item)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package chylex.hee.datagen.server.util
|
||||
|
||||
import com.mojang.datafixers.util.Pair
|
||||
import net.minecraft.block.Block
|
||||
import net.minecraft.block.FlowerPotBlock
|
||||
import net.minecraft.data.DataGenerator
|
||||
import net.minecraft.data.LootTableProvider
|
||||
import net.minecraft.data.loot.BlockLootTables
|
||||
@ -11,7 +10,6 @@ import net.minecraft.loot.LootParameterSets
|
||||
import net.minecraft.loot.LootTable
|
||||
import net.minecraft.loot.LootTable.Builder
|
||||
import net.minecraft.loot.ValidationTracker
|
||||
import net.minecraft.util.IItemProvider
|
||||
import net.minecraft.util.ResourceLocation
|
||||
import java.util.function.BiConsumer
|
||||
import java.util.function.Consumer
|
||||
@ -33,7 +31,7 @@ abstract class BlockLootTableProvider(generator: DataGenerator) : LootTableProvi
|
||||
protected abstract class RegistrationConsumer : BlockLootTables() {
|
||||
private val lootTables = mutableMapOf<ResourceLocation, Builder>()
|
||||
|
||||
override fun addTables() {}
|
||||
abstract override fun addTables()
|
||||
|
||||
final override fun accept(consumer: BiConsumer<ResourceLocation?, Builder?>) {
|
||||
addTables()
|
||||
@ -49,22 +47,6 @@ abstract class BlockLootTableProvider(generator: DataGenerator) : LootTableProvi
|
||||
check(lootTables.put(block.lootTable, table) == null)
|
||||
}
|
||||
|
||||
protected fun dropSelf(block: Block) {
|
||||
registerDropSelfLootTable(block)
|
||||
}
|
||||
|
||||
protected fun dropOther(block: Block, drop: IItemProvider) {
|
||||
registerDropping(block, drop)
|
||||
}
|
||||
|
||||
protected fun dropFunc(block: Block, func: (Block) -> Builder) {
|
||||
registerLootTable(block, func)
|
||||
}
|
||||
|
||||
protected fun dropFlowerPot(block: FlowerPotBlock) {
|
||||
registerFlowerPot(block)
|
||||
}
|
||||
|
||||
protected companion object {
|
||||
val withName = BlockLootTables::droppingWithName
|
||||
}
|
||||
|
@ -1,6 +1,11 @@
|
||||
package chylex.hee.game.block
|
||||
|
||||
import chylex.hee.game.block.properties.BlockBuilder
|
||||
import chylex.hee.game.block.properties.BlockDrop
|
||||
import net.minecraft.block.Block
|
||||
import net.minecraft.loot.LootTables
|
||||
|
||||
open class HeeBlock(builder: BlockBuilder) : Block(builder.p), IHeeBlock
|
||||
open class HeeBlock(builder: BlockBuilder) : Block(builder.p), IHeeBlock {
|
||||
override val drop
|
||||
get() = if (lootTable == LootTables.EMPTY) BlockDrop.Nothing else BlockDrop.Self
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package chylex.hee.game.block
|
||||
|
||||
import chylex.hee.game.block.properties.BlockDrop
|
||||
import chylex.hee.game.block.properties.BlockModel
|
||||
import chylex.hee.game.block.properties.BlockRenderLayer
|
||||
import chylex.hee.game.block.properties.BlockRenderLayer.SOLID
|
||||
@ -15,4 +16,7 @@ interface IHeeBlock {
|
||||
|
||||
val tint: BlockTint?
|
||||
get() = null
|
||||
|
||||
val drop: BlockDrop
|
||||
get() = BlockDrop.Self
|
||||
}
|
||||
|
@ -0,0 +1,12 @@
|
||||
package chylex.hee.game.block.properties
|
||||
|
||||
import net.minecraft.util.IItemProvider
|
||||
|
||||
sealed class BlockDrop {
|
||||
object Nothing : BlockDrop()
|
||||
object Self : BlockDrop()
|
||||
object Manual : BlockDrop()
|
||||
object NamedTile : BlockDrop()
|
||||
object FlowerPot : BlockDrop()
|
||||
class OneOf(val item: IItemProvider) : BlockDrop()
|
||||
}
|
@ -2,6 +2,7 @@ package chylex.hee.game.block
|
||||
|
||||
import chylex.hee.HEE
|
||||
import chylex.hee.game.block.properties.BlockBuilder
|
||||
import chylex.hee.game.block.properties.BlockDrop
|
||||
import chylex.hee.game.fx.util.playUniversal
|
||||
import chylex.hee.game.item.util.nullIfEmpty
|
||||
import chylex.hee.game.world.util.getBlock
|
||||
@ -43,6 +44,9 @@ abstract class BlockAbstractCauldron(builder: BlockBuilder) : CauldronBlock(buil
|
||||
}
|
||||
}
|
||||
|
||||
final override val drop
|
||||
get() = BlockDrop.OneOf(Blocks.CAULDRON)
|
||||
|
||||
protected abstract fun createFilledBucket(): ItemStack?
|
||||
protected abstract fun createFilledBottle(): ItemStack?
|
||||
|
||||
|
@ -2,6 +2,7 @@ package chylex.hee.game.block
|
||||
|
||||
import chylex.hee.game.block.fluid.FlowingFluid5
|
||||
import chylex.hee.game.block.fluid.FluidBase
|
||||
import chylex.hee.game.block.properties.BlockDrop
|
||||
import chylex.hee.game.block.properties.BlockStateModels
|
||||
import chylex.hee.game.block.util.BlockCollisionLimiter
|
||||
import chylex.hee.game.world.util.allInBoxMutable
|
||||
@ -32,9 +33,12 @@ abstract class BlockAbstractGoo(
|
||||
private const val TOTAL_TICKS_TAG = "Ticks"
|
||||
}
|
||||
|
||||
override val model
|
||||
final override val model
|
||||
get() = BlockStateModels.Fluid
|
||||
|
||||
final override val drop
|
||||
get() = BlockDrop.Nothing
|
||||
|
||||
// Initialization
|
||||
|
||||
private var collisionLimiter = BlockCollisionLimiter()
|
||||
|
@ -1,6 +1,7 @@
|
||||
package chylex.hee.game.block
|
||||
|
||||
import chylex.hee.game.block.properties.BlockBuilder
|
||||
import chylex.hee.game.block.properties.BlockDrop
|
||||
import chylex.hee.game.block.properties.BlockRenderLayer.CUTOUT
|
||||
import chylex.hee.game.block.properties.BlockStateModels
|
||||
import chylex.hee.game.world.util.breakBlock
|
||||
@ -35,6 +36,9 @@ class BlockAncientCobweb(builder: BlockBuilder) : WebBlock(builder.p), IHeeBlock
|
||||
override val renderLayer
|
||||
get() = CUTOUT
|
||||
|
||||
override val drop
|
||||
get() = BlockDrop.Manual
|
||||
|
||||
init {
|
||||
MinecraftForge.EVENT_BUS.register(this)
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package chylex.hee.game.block
|
||||
import chylex.hee.game.Resource.location
|
||||
import chylex.hee.game.block.entity.TileEntityBrewingStandCustom
|
||||
import chylex.hee.game.block.properties.BlockBuilder
|
||||
import chylex.hee.game.block.properties.BlockDrop
|
||||
import chylex.hee.game.block.properties.BlockItemModel
|
||||
import chylex.hee.game.block.properties.BlockModel
|
||||
import chylex.hee.game.block.properties.BlockRenderLayer.CUTOUT
|
||||
@ -42,6 +43,9 @@ open class BlockBrewingStandCustom(builder: BlockBuilder) : BrewingStandBlock(bu
|
||||
final override val renderLayer
|
||||
get() = CUTOUT
|
||||
|
||||
final override val drop
|
||||
get() = BlockDrop.NamedTile
|
||||
|
||||
override fun createTileEntity(state: BlockState, world: IBlockReader): TileEntity {
|
||||
return TileEntityBrewingStandCustom()
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package chylex.hee.game.block
|
||||
import chylex.hee.game.Resource.location
|
||||
import chylex.hee.game.block.entity.TileEntityDarkChest
|
||||
import chylex.hee.game.block.properties.BlockBuilder
|
||||
import chylex.hee.game.block.properties.BlockDrop
|
||||
import chylex.hee.game.block.properties.BlockStateModels
|
||||
import chylex.hee.game.entity.living.ai.AIOcelotSitOverride.IOcelotCanSitOn
|
||||
import chylex.hee.init.ModBlocks
|
||||
@ -21,6 +22,9 @@ class BlockDarkChest(builder: BlockBuilder) : ChestBlock(builder.p, Supplier<Til
|
||||
override val model
|
||||
get() = BlockStateModels.Chest(ModBlocks.GLOOMROCK_SMOOTH.location)
|
||||
|
||||
override val drop
|
||||
get() = BlockDrop.NamedTile
|
||||
|
||||
override fun createTileEntity(state: BlockState, world: IBlockReader): TileEntity {
|
||||
return TileEntityDarkChest()
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package chylex.hee.game.block
|
||||
import chylex.hee.game.Resource.location
|
||||
import chylex.hee.game.block.IBlockDeathFlowerDecaying.Companion.LEVEL
|
||||
import chylex.hee.game.block.properties.BlockBuilder
|
||||
import chylex.hee.game.block.properties.BlockDrop
|
||||
import chylex.hee.game.block.properties.BlockModel
|
||||
import chylex.hee.game.block.properties.BlockStateModel
|
||||
import chylex.hee.game.block.properties.BlockStatePreset
|
||||
@ -42,6 +43,9 @@ class BlockDeathFlowerDecaying(builder: BlockBuilder) : BlockEndPlant(builder),
|
||||
))
|
||||
)
|
||||
|
||||
override val drop
|
||||
get() = BlockDrop.Manual
|
||||
|
||||
override fun fillStateContainer(container: Builder<Block, BlockState>) {
|
||||
container.add(LEVEL)
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package chylex.hee.game.block
|
||||
|
||||
import chylex.hee.client.util.MC
|
||||
import chylex.hee.game.block.properties.BlockBuilder
|
||||
import chylex.hee.game.block.properties.BlockDrop
|
||||
import chylex.hee.game.block.properties.BlockRenderLayer.CUTOUT
|
||||
import chylex.hee.game.block.properties.BlockStateModels
|
||||
import chylex.hee.game.block.properties.BlockTint
|
||||
@ -33,6 +34,9 @@ class BlockDryVines(builder: BlockBuilder) : VineBlock(builder.p), IHeeBlock {
|
||||
override val renderLayer
|
||||
get() = CUTOUT
|
||||
|
||||
override val drop
|
||||
get() = BlockDrop.Manual
|
||||
|
||||
// Custom behavior
|
||||
|
||||
override fun tick(state: BlockState, world: ServerWorld, pos: BlockPos, rand: Random) {}
|
||||
|
@ -2,6 +2,7 @@ package chylex.hee.game.block
|
||||
|
||||
import chylex.hee.game.block.logic.IFullBlockCollisionHandler
|
||||
import chylex.hee.game.block.properties.BlockBuilder
|
||||
import chylex.hee.game.block.properties.BlockDrop
|
||||
import chylex.hee.game.entity.living.EntityMobUndread
|
||||
import chylex.hee.game.world.util.Facing4
|
||||
import chylex.hee.game.world.util.allInBox
|
||||
@ -58,6 +59,9 @@ class BlockDustyStoneUnstable(builder: BlockBuilder) : BlockDustyStone(builder),
|
||||
}
|
||||
}
|
||||
|
||||
override val drop
|
||||
get() = BlockDrop.Manual
|
||||
|
||||
override fun canHarvestBlock(state: BlockState, world: IBlockReader, pos: BlockPos, player: PlayerEntity): Boolean {
|
||||
return player.getHeldItem(MAIN_HAND).let { EnchantmentHelper.getEnchantmentLevel(Enchantments.SILK_TOUCH, it) == 0 || isPickaxeOrShovel(player, it) }
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package chylex.hee.game.block
|
||||
|
||||
import chylex.hee.game.block.properties.BlockBuilder
|
||||
import chylex.hee.game.block.properties.BlockDrop
|
||||
import chylex.hee.system.random.nextInt
|
||||
import net.minecraft.block.BlockState
|
||||
import net.minecraft.util.math.BlockPos
|
||||
@ -8,6 +9,9 @@ import net.minecraft.world.IWorldReader
|
||||
import net.minecraft.world.World
|
||||
|
||||
class BlockEndPowderOre(builder: BlockBuilder) : HeeBlock(builder) {
|
||||
override val drop
|
||||
get() = BlockDrop.Manual
|
||||
|
||||
override fun getExpDrop(state: BlockState, world: IWorldReader, pos: BlockPos, fortune: Int, silktouch: Int): Int {
|
||||
return ((world as? World)?.rand ?: RANDOM).nextInt(1, 2)
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package chylex.hee.game.block
|
||||
|
||||
import chylex.hee.game.Resource.location
|
||||
import chylex.hee.game.block.properties.BlockBuilder
|
||||
import chylex.hee.game.block.properties.BlockDrop
|
||||
import chylex.hee.game.block.properties.BlockModel
|
||||
import chylex.hee.game.block.properties.BlockStateModel
|
||||
import chylex.hee.game.block.properties.BlockStatePreset
|
||||
@ -20,4 +21,7 @@ class BlockEndersol(builder: BlockBuilder, mergeBottom: Block) : BlockSimpleMerg
|
||||
),
|
||||
ItemModel.AsBlock
|
||||
)
|
||||
|
||||
override val drop
|
||||
get() = BlockDrop.Manual
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package chylex.hee.game.block
|
||||
|
||||
import chylex.hee.game.Resource.location
|
||||
import chylex.hee.game.block.properties.BlockBuilder
|
||||
import chylex.hee.game.block.properties.BlockDrop
|
||||
import chylex.hee.game.block.properties.BlockModel
|
||||
import chylex.hee.game.block.properties.BlockRenderLayer.CUTOUT
|
||||
import chylex.hee.game.block.properties.BlockStateModel
|
||||
@ -75,6 +76,9 @@ class BlockEternalFire(builder: BlockBuilder) : FireBlock(builder.p), IHeeBlock
|
||||
override val renderLayer
|
||||
get() = CUTOUT
|
||||
|
||||
override val drop
|
||||
get() = BlockDrop.Nothing
|
||||
|
||||
init {
|
||||
MinecraftForge.EVENT_BUS.register(this)
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package chylex.hee.game.block
|
||||
|
||||
import chylex.hee.game.block.properties.BlockBuilder
|
||||
import chylex.hee.game.block.properties.BlockDrop
|
||||
import chylex.hee.game.block.properties.BlockStateModels
|
||||
import chylex.hee.game.entity.item.EntityFallingBlockHeavy
|
||||
import chylex.hee.game.entity.item.EntityFallingObsidian
|
||||
@ -17,6 +18,9 @@ class BlockFallingObsidian(builder: BlockBuilder) : HeeBlock(builder) {
|
||||
override val model
|
||||
get() = BlockStateModels.Cube(Blocks.OBSIDIAN)
|
||||
|
||||
override val drop
|
||||
get() = BlockDrop.OneOf(Blocks.OBSIDIAN)
|
||||
|
||||
override fun onBlockAdded(state: BlockState, world: World, pos: BlockPos, oldState: BlockState, isMoving: Boolean) {
|
||||
world.pendingBlockTicks.scheduleTick(pos, this, 2)
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package chylex.hee.game.block
|
||||
|
||||
import chylex.hee.game.block.properties.BlockBuilder
|
||||
import chylex.hee.game.block.properties.BlockDrop
|
||||
import chylex.hee.game.block.properties.BlockRenderLayer.CUTOUT
|
||||
import chylex.hee.game.block.properties.BlockStateModels
|
||||
import chylex.hee.util.forge.supply
|
||||
@ -15,6 +16,9 @@ open class BlockFlowerPotCustom(builder: BlockBuilder, flower: Block) : FlowerPo
|
||||
final override val renderLayer
|
||||
get() = CUTOUT
|
||||
|
||||
final override val drop
|
||||
get() = BlockDrop.FlowerPot
|
||||
|
||||
init {
|
||||
@Suppress("LeakingThis")
|
||||
(Blocks.FLOWER_POT as FlowerPotBlock).addPlant(flower.registryName!!, supply(this))
|
||||
|
@ -3,6 +3,7 @@ package chylex.hee.game.block
|
||||
import chylex.hee.game.Resource.location
|
||||
import chylex.hee.game.block.IBlockDeathFlowerDecaying.Companion.LEVEL
|
||||
import chylex.hee.game.block.properties.BlockBuilder
|
||||
import chylex.hee.game.block.properties.BlockDrop
|
||||
import chylex.hee.game.block.properties.BlockModel
|
||||
import chylex.hee.game.block.properties.BlockRenderLayer.CUTOUT
|
||||
import chylex.hee.game.block.properties.BlockStateModel
|
||||
@ -47,6 +48,9 @@ class BlockFlowerPotDeathFlowerDecaying(
|
||||
override val renderLayer
|
||||
get() = CUTOUT
|
||||
|
||||
override val drop
|
||||
get() = BlockDrop.Manual
|
||||
|
||||
override fun fillStateContainer(container: Builder<Block, BlockState>) {
|
||||
container.add(LEVEL)
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import chylex.hee.game.Environment
|
||||
import chylex.hee.game.Resource
|
||||
import chylex.hee.game.Resource.location
|
||||
import chylex.hee.game.block.properties.BlockBuilder
|
||||
import chylex.hee.game.block.properties.BlockDrop
|
||||
import chylex.hee.game.block.properties.BlockModel
|
||||
import chylex.hee.game.block.properties.BlockStateModel
|
||||
import chylex.hee.game.block.properties.BlockStateModels
|
||||
@ -77,6 +78,9 @@ sealed class BlockGraveDirt(builder: BlockBuilder) : BlockSimpleShaped(builder,
|
||||
override val model: IBlockStateModel
|
||||
get() = BlockStateModels.ItemOnly(ItemModel.FromParent(Resource.Custom("block/grave_dirt_low")))
|
||||
|
||||
final override val drop
|
||||
get() = BlockDrop.Manual
|
||||
|
||||
val soundType: SoundType
|
||||
get() = soundType
|
||||
|
||||
|
@ -2,6 +2,7 @@ package chylex.hee.game.block
|
||||
|
||||
import chylex.hee.game.Resource.location
|
||||
import chylex.hee.game.block.properties.BlockBuilder
|
||||
import chylex.hee.game.block.properties.BlockDrop
|
||||
import chylex.hee.game.block.properties.BlockModel
|
||||
import chylex.hee.game.block.properties.BlockStateModel
|
||||
import chylex.hee.game.block.properties.BlockStatePreset
|
||||
@ -47,6 +48,9 @@ class BlockHumus(builder: BlockBuilder, mergeBottom: Block) : BlockSimpleMerging
|
||||
ItemModel.AsBlock
|
||||
)
|
||||
|
||||
override val drop
|
||||
get() = BlockDrop.Manual
|
||||
|
||||
override fun randomTick(state: BlockState, world: ServerWorld, pos: BlockPos, rand: Random) {
|
||||
@Suppress("DEPRECATION")
|
||||
super.randomTick(state, world, pos, rand)
|
||||
|
@ -1,6 +1,7 @@
|
||||
package chylex.hee.game.block
|
||||
|
||||
import chylex.hee.game.block.properties.BlockBuilder
|
||||
import chylex.hee.game.block.properties.BlockDrop
|
||||
import chylex.hee.game.entity.damage.Damage
|
||||
import chylex.hee.game.entity.damage.IDamageDealer.Companion.TITLE_IN_FIRE
|
||||
import chylex.hee.game.entity.damage.IDamageProcessor.Companion.FIRE_TYPE
|
||||
@ -44,6 +45,9 @@ class BlockIgneousRockOre(builder: BlockBuilder) : HeeBlock(builder) {
|
||||
}
|
||||
}
|
||||
|
||||
override val drop
|
||||
get() = BlockDrop.Manual
|
||||
|
||||
init {
|
||||
MinecraftForge.EVENT_BUS.register(this)
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package chylex.hee.game.block
|
||||
|
||||
import chylex.hee.game.Resource
|
||||
import chylex.hee.game.block.properties.BlockBuilder
|
||||
import chylex.hee.game.block.properties.BlockDrop
|
||||
import chylex.hee.game.block.properties.BlockRenderLayer.TRANSLUCENT
|
||||
import chylex.hee.game.block.properties.BlockStateModels
|
||||
import chylex.hee.game.block.util.Property
|
||||
@ -48,6 +49,9 @@ class BlockInfusedGlass(builder: BlockBuilder) : AbstractGlassBlock(builder.p),
|
||||
override val renderLayer
|
||||
get() = TRANSLUCENT
|
||||
|
||||
override val drop
|
||||
get() = BlockDrop.Manual
|
||||
|
||||
init {
|
||||
defaultState = Facing6.fold(stateContainer.baseState) { acc, facing -> acc.with(CONNECT_MAPPINGS.getValue(facing), false) }
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package chylex.hee.game.block
|
||||
import chylex.hee.game.Resource.location
|
||||
import chylex.hee.game.block.entity.TileEntityInfusedTNT
|
||||
import chylex.hee.game.block.logic.IBlockFireCatchOverride
|
||||
import chylex.hee.game.block.properties.BlockDrop
|
||||
import chylex.hee.game.block.properties.BlockModel
|
||||
import chylex.hee.game.block.util.Property
|
||||
import chylex.hee.game.entity.item.EntityInfusedTNT
|
||||
@ -50,6 +51,9 @@ class BlockInfusedTNT : TNTBlock(Properties.from(Blocks.TNT)), IHeeBlock, IBlock
|
||||
top = Blocks.TNT.location("_top"),
|
||||
)
|
||||
|
||||
override val drop
|
||||
get() = BlockDrop.Manual
|
||||
|
||||
init {
|
||||
defaultState = defaultState.with(INFERNIUM, false)
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package chylex.hee.game.block
|
||||
|
||||
import chylex.hee.game.block.entity.TileEntityJarODust
|
||||
import chylex.hee.game.block.properties.BlockBuilder
|
||||
import chylex.hee.game.block.properties.BlockDrop
|
||||
import chylex.hee.game.block.properties.BlockModel
|
||||
import chylex.hee.game.block.properties.BlockRenderLayer.TRANSLUCENT
|
||||
import chylex.hee.game.block.properties.BlockStateModel
|
||||
@ -61,6 +62,9 @@ class BlockJarODust(builder: BlockBuilder) : BlockSimpleShaped(builder, AABB) {
|
||||
override val renderLayer
|
||||
get() = TRANSLUCENT
|
||||
|
||||
override val drop
|
||||
get() = BlockDrop.Manual
|
||||
|
||||
override fun hasTileEntity(state: BlockState): Boolean {
|
||||
return true
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package chylex.hee.game.block
|
||||
import chylex.hee.game.Resource.location
|
||||
import chylex.hee.game.block.entity.TileEntityLootChest
|
||||
import chylex.hee.game.block.properties.BlockBuilder
|
||||
import chylex.hee.game.block.properties.BlockDrop
|
||||
import chylex.hee.game.block.properties.BlockStateModels
|
||||
import chylex.hee.game.world.util.getTile
|
||||
import chylex.hee.util.forge.Side
|
||||
@ -21,6 +22,9 @@ class BlockLootChest(builder: BlockBuilder) : BlockAbstractChest<TileEntityLootC
|
||||
override val model
|
||||
get() = BlockStateModels.Chest(this.location("_particle"))
|
||||
|
||||
override val drop
|
||||
get() = BlockDrop.Nothing
|
||||
|
||||
override fun createTileEntity() = TileEntityLootChest()
|
||||
|
||||
override fun openChest(world: World, pos: BlockPos, player: PlayerEntity) {
|
||||
|
@ -224,7 +224,7 @@ sealed class BlockPuzzleLogic(builder: BlockBuilder) : HeeBlock(builder) {
|
||||
|
||||
abstract override val model: IBlockStateModel
|
||||
|
||||
override val renderLayer
|
||||
final override val renderLayer
|
||||
get() = CUTOUT
|
||||
|
||||
init {
|
||||
|
@ -1,20 +1,28 @@
|
||||
package chylex.hee.game.block
|
||||
|
||||
import chylex.hee.game.block.properties.BlockBuilder
|
||||
import chylex.hee.game.block.properties.BlockDrop
|
||||
import chylex.hee.game.block.properties.BlockModel
|
||||
import chylex.hee.game.block.properties.BlockStateModel
|
||||
import chylex.hee.game.block.properties.BlockStatePreset
|
||||
import chylex.hee.game.block.properties.CustomSkull.ICustomSkull
|
||||
import chylex.hee.game.item.properties.ItemModel
|
||||
import net.minecraft.block.Blocks
|
||||
import net.minecraft.block.SkullBlock
|
||||
import net.minecraft.block.WallSkullBlock
|
||||
|
||||
class BlockSkullCustom(type: ISkullType, builder: BlockBuilder) : SkullBlock(type, builder.p), IHeeBlock {
|
||||
class BlockSkullCustom(private val type: ICustomSkull, builder: BlockBuilder) : SkullBlock(type, builder.p), IHeeBlock {
|
||||
override val model
|
||||
get() = BlockStateModel(BlockStatePreset.SimpleFrom(Blocks.SOUL_SAND), BlockModel.Manual, ItemModel.Skull)
|
||||
|
||||
class Wall(type: ISkullType, builder: BlockBuilder) : WallSkullBlock(type, builder.p), IHeeBlock {
|
||||
override val drop
|
||||
get() = BlockDrop.OneOf(type.asItem())
|
||||
|
||||
class Wall(private val type: ICustomSkull, builder: BlockBuilder) : WallSkullBlock(type, builder.p), IHeeBlock {
|
||||
override val model
|
||||
get() = BlockStateModel(BlockStatePreset.SimpleFrom(Blocks.SOUL_SAND), BlockModel.Manual)
|
||||
|
||||
override val drop
|
||||
get() = BlockDrop.OneOf(type.asItem())
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package chylex.hee.game.block
|
||||
|
||||
import chylex.hee.game.block.entity.TileEntitySpawnerObsidianTower
|
||||
import chylex.hee.game.block.properties.BlockBuilder
|
||||
import chylex.hee.game.block.properties.BlockDrop
|
||||
import chylex.hee.game.block.properties.BlockModel
|
||||
import chylex.hee.game.block.properties.BlockRenderLayer.CUTOUT
|
||||
import chylex.hee.game.block.properties.BlockStateModel
|
||||
@ -21,6 +22,9 @@ class BlockSpawnerObsidianTowers(builder: BlockBuilder) : SpawnerBlock(builder.p
|
||||
override val renderLayer
|
||||
get() = CUTOUT
|
||||
|
||||
override val drop
|
||||
get() = BlockDrop.Nothing
|
||||
|
||||
override fun createTileEntity(state: BlockState, world: IBlockReader): TileEntity {
|
||||
return TileEntitySpawnerObsidianTower()
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package chylex.hee.game.block
|
||||
import chylex.hee.game.Resource
|
||||
import chylex.hee.game.Resource.location
|
||||
import chylex.hee.game.block.properties.BlockBuilder
|
||||
import chylex.hee.game.block.properties.BlockDrop
|
||||
import chylex.hee.game.block.properties.BlockModel
|
||||
import chylex.hee.game.block.properties.BlockRenderLayer.CUTOUT
|
||||
import chylex.hee.game.block.properties.BlockStateModel
|
||||
@ -29,6 +30,9 @@ class BlockStardustOre(builder: BlockBuilder) : HeeBlock(builder) {
|
||||
override val renderLayer
|
||||
get() = CUTOUT
|
||||
|
||||
override val drop
|
||||
get() = BlockDrop.Manual
|
||||
|
||||
override fun getExpDrop(state: BlockState, world: IWorldReader, pos: BlockPos, fortune: Int, silktouch: Int): Int {
|
||||
return (((world as? World)?.rand ?: RANDOM).nextBiasedFloat(4F) * 6F).ceilToInt()
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package chylex.hee.game.block
|
||||
|
||||
import chylex.hee.game.block.properties.BlockBuilder
|
||||
import chylex.hee.game.block.properties.BlockDrop
|
||||
import chylex.hee.game.block.properties.BlockModel
|
||||
import chylex.hee.game.block.properties.BlockRenderLayer.CUTOUT
|
||||
import net.minecraft.block.BlockState
|
||||
@ -24,6 +25,9 @@ class BlockWhitebarkLeaves(builder: BlockBuilder) : LeavesBlock(builder.p), IHee
|
||||
override val renderLayer
|
||||
get() = CUTOUT
|
||||
|
||||
override val drop
|
||||
get() = BlockDrop.Manual
|
||||
|
||||
override fun harvestBlock(world: World, player: PlayerEntity, pos: BlockPos, state: BlockState, tile: TileEntity?, stack: ItemStack) {
|
||||
if (!world.isRemote && stack.item === Items.SHEARS) {
|
||||
player.addStat(Stats.BLOCK_MINED[this])
|
||||
|
@ -1,7 +1,13 @@
|
||||
package chylex.hee.game.block.properties
|
||||
|
||||
import chylex.hee.init.ModItems
|
||||
import net.minecraft.block.SkullBlock.ISkullType
|
||||
import net.minecraft.util.IItemProvider
|
||||
|
||||
object CustomSkull {
|
||||
object Enderman : ISkullType
|
||||
interface ICustomSkull : ISkullType, IItemProvider
|
||||
|
||||
object Enderman : ICustomSkull {
|
||||
override fun asItem() = ModItems.ENDERMAN_HEAD
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user