1
0
mirror of https://github.com/chylex/Hardcore-Ender-Expansion-2.git synced 2025-09-15 14:32:09 +02:00

1 Commits

Author SHA1 Message Date
f18f798afb Port to 1.16.5 2021-07-06 18:58:00 +02:00
1152 changed files with 17082 additions and 21411 deletions

4
.idea/gradle.xml generated
View File

@@ -12,9 +12,7 @@
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/data" />
<option value="$PROJECT_DIR$/modules/debug" />
<option value="$PROJECT_DIR$/modules/system" />
<option value="$PROJECT_DIR$/modules/util" />
<option value="$PROJECT_DIR$/src/system" />
</set>
</option>
</GradleProjectSettings>

View File

@@ -2,20 +2,12 @@ ext {
mc_version = "1.16.5"
forge_version = "36.1.32"
mixin_version = "0.8.2"
kotlin_mod_version = "1.13.0"
mapping_version = "20210309-1.16.5"
access_transformers = [
new File(rootProject.projectDir, "src/main/resources/META-INF/accesstransformer_main.cfg"),
new File(project(":system").projectDir, "src/main/resources/META-INF/accesstransformer_system.cfg"),
new File(project(":util").projectDir, "src/main/resources/META-INF/accesstransformer_util.cfg"),
]
kotlin_mod_version = "1.13.0"
}
buildscript {
ext {
forge_gradle_version = "4.1.+"
mixin_gradle_version = "0.7-SNAPSHOT"
kotlin_version = "1.5.20"
}
@@ -26,8 +18,8 @@ buildscript {
}
dependencies {
classpath group: "net.minecraftforge.gradle", name: "ForgeGradle", version: forge_gradle_version, changing: true
classpath group: "org.spongepowered", name: "mixingradle", version: mixin_gradle_version
classpath group: "net.minecraftforge.gradle", name: "ForgeGradle", version: "4.1.+", changing: true
classpath group: "org.spongepowered", name: "mixingradle", version: "0.7-SNAPSHOT"
classpath group: "org.jetbrains.kotlin", name: "kotlin-gradle-plugin", version: kotlin_version
}
}
@@ -37,7 +29,7 @@ apply plugin: "org.spongepowered.mixin"
apply plugin: "eclipse"
apply plugin: "idea"
if (file("run/mods_deobf.gradle").exists()) {
if (file("run/mods_deobf.gradle").exists()){
apply from: "run/mods_deobf.gradle"
}
@@ -54,15 +46,12 @@ archivesBaseName = metaName.replaceAll("\\s", "")
idea {
module {
[".idea", ".settings", ".gradle", "build", "gradle", "run"].each {
[".idea", ".settings", ".gradle", "build", "gradle", "out", "run", "src/main/kotlin", "src/test/kotlin"].each {
excludeDirs += file(it)
}
["out", "src/main/kotlin", "src/test/kotlin"].each {
excludeDirs += file(it)
excludeDirs += file("modules/debug/" + it)
excludeDirs += file("modules/system/" + it)
excludeDirs += file("modules/util/" + it)
excludeDirs += file("src/system/" + it)
}
["src/main/kotlin", "src/test/kotlin"].each {
@@ -98,9 +87,10 @@ allprojects {
}
repositories {
mavenCentral()
maven { url = "https://files.minecraftforge.net/maven" }
maven { url = "https://thedarkcolour.github.io/KotlinForForge" }
maven {
name = "kotlinforforge"
url = "https://thedarkcolour.github.io/KotlinForForge"
}
}
dependencies {
@@ -109,7 +99,7 @@ allprojects {
implementation "org.jetbrains.kotlin:kotlin-reflect"
}
if (file("$buildDir/classes").exists()) {
if (file("$buildDir/classes").exists()){
file("$buildDir/classes/java/main").mkdirs() // Forge complains when the java folder is missing
}
}
@@ -125,10 +115,12 @@ sourceSets {
minecraft {
mappings channel: "snapshot", version: rootProject.mapping_version
setAccessTransformers(rootProject.access_transformers)
accessTransformer = file("src/main/resources/META-INF/accesstransformer.cfg")
runs {
client {
property "hee.debug", ""
property "mixin.env.remapRefMap", "true"
property "mixin.env.refMapRemappingFile", "${projectDir}/build/createSrgToMcp/output.srg"
arg "-mixin.config=hee.mixins.json"
@@ -138,14 +130,13 @@ minecraft {
mods {
hee {
source sourceSets.main
source project(":debug").sourceSets.main
source project(":system").sourceSets.main
source project(":util").sourceSets.main
}
}
}
server {
property "hee.debug", ""
property "mixin.env.remapRefMap", "true"
property "mixin.env.refMapRemappingFile", "${projectDir}/build/createSrgToMcp/output.srg"
arg "-mixin.config=hee.mixins.json"
@@ -155,9 +146,7 @@ minecraft {
mods {
hee {
source sourceSets.main
source project(":debug").sourceSets.main
source project(":system").sourceSets.main
source project(":util").sourceSets.main
}
}
}
@@ -174,9 +163,7 @@ minecraft {
mods {
hee {
source sourceSets.main
source project(":debug").sourceSets.main
source project(":system").sourceSets.main
source project(":util").sourceSets.main
source project(":datagen").sourceSets.main
}
}
@@ -191,11 +178,9 @@ mixin {
dependencies {
minecraft "net.minecraftforge:forge:" + mc_version + "-" + forge_version
implementation project(":util")
implementation project(":system")
implementation "thedarkcolour:kotlinforforge:" + kotlin_mod_version
testImplementation project(":util")
testImplementation project(":system")
testImplementation "org.junit.jupiter:junit-jupiter-api:5.3.0-RC1"
@@ -212,11 +197,9 @@ test {
jar {
archiveName = archivesBaseName + "-" + mc_version + "-v" + version + ".jar"
["system", "util"].each {
from(project(":" + it).sourceSets.main.output) {
exclude "pack.mcmeta"
exclude "META-INF/*.kotlin_module"
}
from(project(":system").sourceSets.main.output) {
exclude "META-INF"
exclude "pack.mcmeta"
}
from("./data/gen") {

View File

@@ -5,23 +5,28 @@ buildscript {
}
dependencies {
classpath group: "net.minecraftforge.gradle", name: "ForgeGradle", version: forge_gradle_version, changing: true
classpath group: "net.minecraftforge.gradle", name: "ForgeGradle", version: "4.1.+", changing: true
classpath group: "org.jetbrains.kotlin", name: "kotlin-gradle-plugin", version: kotlin_version
}
}
repositories {
mavenCentral()
maven { url = "https://files.minecraftforge.net/maven" }
}
apply plugin: "net.minecraftforge.gradle"
apply plugin: "eclipse"
minecraft {
mappings channel: "snapshot", version: rootProject.mapping_version
setAccessTransformers(rootProject.access_transformers)
accessTransformer = file("../src/main/resources/META-INF/accesstransformer.cfg")
}
dependencies {
minecraft "net.minecraftforge:forge:" + mc_version + "-" + forge_version
implementation rootProject
implementation project(":system")
implementation project(":util")
}
jar {

View File

@@ -10,9 +10,6 @@ e53a79fa8e5222e4287e2e5d410890b1f8df78ba assets/hee/blockstates/autumn_leaves_ye
1ce8f488560f32fddbd2532961df123665625c75 assets/hee/blockstates/autumn_sapling_orange.json
303070f9945ee2e6716e0fcd67bfa3275b93fde6 assets/hee/blockstates/autumn_sapling_red.json
694318e51ca78111cd91a507a99ab852825cdf0c assets/hee/blockstates/autumn_sapling_yellowgreen.json
6af0fcab50e591ffad19be1909b4e2baba4bc084 assets/hee/blockstates/cauldron_dragons_breath.json
06141839f09e97f639771c67108b9b2e2f437403 assets/hee/blockstates/cauldron_ender_goo.json
802edf094f47f5ce129eec4b2be018ab8a9a62e6 assets/hee/blockstates/cauldron_purified_ender_goo.json
e926f62a373640c427ba9ac962d7b2dcbe0ae376 assets/hee/blockstates/corrupted_energy.json
7bce0e85ae6f21ceede602f140f40c7678480790 assets/hee/blockstates/dark_chest.json
97ac658307fc07611fe9328ab95d692ab16bb92d assets/hee/blockstates/dark_loam.json
@@ -75,7 +72,7 @@ c16b5933b9af8fb1033c6d6d11e19628d7c56f4f assets/hee/blockstates/miners_burial_bl
b58fb5ca5bdaf639f725135a2a6682adc4c712ff assets/hee/blockstates/miners_burial_block_plain.json
4c56ed06867c9ef95b287b57e31ddb123e56020e assets/hee/blockstates/obsidian_chiseled.json
4c56ed06867c9ef95b287b57e31ddb123e56020e assets/hee/blockstates/obsidian_chiseled_lit.json
27365e71c0a9f8cfab0340d70a65b7f341363e0d assets/hee/blockstates/obsidian_falling.json
58196b68181ce4554fe7accaa29d3f1f2596b3c2 assets/hee/blockstates/obsidian_falling.json
d4bc138bf24df55f5df0df391cced6c587e6fec3 assets/hee/blockstates/obsidian_pillar.json
d666add54a950dd814fc08a7e612ac5a57070c15 assets/hee/blockstates/obsidian_pillar_lit.json
3c6eb037eb8731410f06b17815e9b9d3705c6b7f assets/hee/blockstates/obsidian_smooth.json
@@ -92,7 +89,6 @@ b70f529af4a5d86e6313d278bed22000f5aa5239 assets/hee/blockstates/purified_ender_g
7b9473e5987ea2cf6fde1a7b530895bba6891a24 assets/hee/blockstates/puzzle_block_wall.json
ce9b1e3bb4760063c69b9c671c8a567520125dd2 assets/hee/blockstates/scaffolding.json
070df87fc3b7dd9029a0bf0d59745cb0e4430181 assets/hee/blockstates/spawner_obsidian_towers.json
eb08886b7e7241361d5c7ee280e024610990847e assets/hee/blockstates/stone_brick_wall.json
947fcca21b602927ed0ead585ea1d2213372f074 assets/hee/blockstates/table_base_tier_1.json
404f8c1b45214db75959f02706dc10c66b278970 assets/hee/blockstates/table_base_tier_2.json
805a8e554ff95cea28405e6de97da053986bd9df assets/hee/blockstates/table_base_tier_3.json
@@ -107,7 +103,6 @@ c53b83ef3e8152ed65147117c10122e4906ea61b assets/hee/blockstates/whitebark_log.js
281264d279f075947ee2f8afdb78190364782921 assets/hee/blockstates/whitebark_planks.json
976d2b47d52e04eb9944e3c4c8aee9a91f315ade assets/hee/blockstates/whitebark_slab.json
776dd79a096f999f2606047486af73aca71a6cf0 assets/hee/blockstates/whitebark_stairs.json
9c87b9db95b144daa448ab95b11338423a7b5394 assets/hee/lang/en_us.json
a3127926cde114f660a9748f9d2ff6c378778d6a assets/hee/models/block/accumulation_table_tier_1.json
c87320b92ede3bf18f7497cf59689d15ef18969b assets/hee/models/block/accumulation_table_tier_2.json
0adc1ddee430fc2aacd2b6a32fbc1fea048345c2 assets/hee/models/block/accumulation_table_tier_3.json
@@ -164,16 +159,6 @@ f2e86d976bcd985021fbe00d34b1e1b44a64a557 assets/hee/models/block/endersol_merge_
488e5dec7542396ca80e3bcb02b7313a412aa97f assets/hee/models/block/endium_block.json
aa8fcca7cb3898e5e7658bbdae0a555209b3f8e2 assets/hee/models/block/endium_ore.json
01c6bfe57748c7a87ce304024d905c7715f1fe3c assets/hee/models/block/enhanced_brewing_stand.json
1926175e552d2b810d01b8a89fc45a5bb4dd39ed assets/hee/models/block/eternal_fire_floor0.json
1eab166292d4a4fcb44a9f5d9a33ca0dcf535ba5 assets/hee/models/block/eternal_fire_floor1.json
82316da36e8f8f4ee6fd9ae5fd119e4692b99d2d assets/hee/models/block/eternal_fire_side0.json
61ef10a01e1377e36af67d5ae379218924626595 assets/hee/models/block/eternal_fire_side1.json
ad645653a99dc42535fdfb855b4dc8622c6f826d assets/hee/models/block/eternal_fire_side_alt0.json
e233d09cb8537c735b2af104c0637bab2ca85d59 assets/hee/models/block/eternal_fire_side_alt1.json
5726b3ca9700fbca7ac3ade22ad5cc0634cfe652 assets/hee/models/block/eternal_fire_up0.json
4f913fac7c9deac303f95251a82018e4e3fb0183 assets/hee/models/block/eternal_fire_up1.json
fa5d1de1603cdea3f8886c053a48c9ce145ec173 assets/hee/models/block/eternal_fire_up_alt0.json
9b39ca3af11554cc5f7b49fa6b7d495d4026395e assets/hee/models/block/eternal_fire_up_alt1.json
78688919cd3be6d8e511a9e72227c8c1ed3eaf07 assets/hee/models/block/ethereal_lantern.json
2978d091e8cbd221ee969bb3f2e078c06ef4e3e1 assets/hee/models/block/experience_gate.json
7f01aebf3576d63fb8f254aa0d6ffd28f11245a4 assets/hee/models/block/experience_gate_controller.json
@@ -220,13 +205,14 @@ e715a206318b020b1e3119db56f8e807ab4c11dd assets/hee/models/block/infused_tnt.jso
63f514ba3c4648bbe843ab4bc5ddf1df70025f0c assets/hee/models/block/infusion_table_tier_1.json
71efff4640a6fe83ac449de2204e2d2bd0e3f97e assets/hee/models/block/infusion_table_tier_2.json
18c56872e21de3d66f642f1d6a3c4bccafc461c8 assets/hee/models/block/infusion_table_tier_3.json
fd787c41eb1e5875ff3b22b7a5c5d989d097ad40 assets/hee/models/block/loot_chest.json
a5f3f2cbbe8628a426817953c087585f65fc2254 assets/hee/models/block/loot_chest.json
7b4ae46a1f8d7d285d31565ce7cba02a5784d93f assets/hee/models/block/miners_burial_block_chiseled.json
f86f536da296ac2e2081fe038757e565f7ac6952 assets/hee/models/block/miners_burial_block_jail.json
7b3afe0784c92fb8e0d8112427e7f2ee1799e5e5 assets/hee/models/block/miners_burial_block_pillar.json
7e60044fcb9a5806d815a94b49304ff6ca992496 assets/hee/models/block/miners_burial_block_pillar_horizontal.json
1af20bb8055eb36f6e0b0db1eac13ad7a63ff106 assets/hee/models/block/miners_burial_block_plain.json
0ed91de9858f63ae21ace09f60cf734bbd27daa6 assets/hee/models/block/obsidian_chiseled.json
b1c121d633d189b0cb6fbc8b675b5acf0b19a0d4 assets/hee/models/block/obsidian_falling.json
66637af0fb0dc1f048ce46c7291d6fe3e443e69f assets/hee/models/block/obsidian_pillar.json
f5677922b8a5a69b2fd2a34cf081fb4dcbd9bd23 assets/hee/models/block/obsidian_pillar_horizontal.json
66637af0fb0dc1f048ce46c7291d6fe3e443e69f assets/hee/models/block/obsidian_pillar_lit.json
@@ -309,6 +295,7 @@ ffbc19b2aeeb81c1acf03dfc6f4ab101b5602f7a assets/hee/models/item/autumn_sapling_b
2ef2d9dd8a04a7a2bb0d0a75570565ff4921cf67 assets/hee/models/item/blank_token.json
98167609bf3898587f7565736a6fc24a7966cacd assets/hee/models/item/blobby_spawn_egg.json
fda3face7f4a5bb8debff8958d1d4920860cd1c3 assets/hee/models/item/compost.json
bd805b17a4641f39e85e70aa5e10f45b0f0d32ce assets/hee/models/item/corrupted_energy.json
5305057f6e86d0fb549f22e6d49a2ca6e9723c54 assets/hee/models/item/dark_chest.json
45959256d2d1b4548f4f528d2d690816697955d2 assets/hee/models/item/dark_loam.json
d6669437273af857f67460b9ffc674f07cc07630 assets/hee/models/item/dark_loam_slab.json
@@ -410,7 +397,7 @@ b0ccc08c142525e3d82a6643d34dfb0d82385571 assets/hee/models/item/miners_burial_bl
8e0fc42a6a28596571ec0877ab3a9af7901adeaa assets/hee/models/item/miners_burial_block_plain.json
7a8592c4a45ccdea4ca36898b3371364f6aab2ca assets/hee/models/item/obsidian_chiseled.json
7a8592c4a45ccdea4ca36898b3371364f6aab2ca assets/hee/models/item/obsidian_chiseled_lit.json
561f15cf196c891a108a723c24894fa524b7d2e2 assets/hee/models/item/obsidian_falling.json
6ec06a3d2286e954a180a021f8e2fa0847bc62a9 assets/hee/models/item/obsidian_falling.json
3c4e981d4d1945965dfbdc0e4c5ce4c2325646ca assets/hee/models/item/obsidian_fragment.json
28e22c71e0b66c4f05a034efed3fdc1c53ed3446 assets/hee/models/item/obsidian_pillar.json
28e22c71e0b66c4f05a034efed3fdc1c53ed3446 assets/hee/models/item/obsidian_pillar_lit.json
@@ -482,7 +469,7 @@ aa8696fc83d73951a890f55cd7c2b9c9abb3f611 assets/hee/models/item/whitebark_log.js
2903a69c4cd7c37db3891af9c0736568ccc3acff data/forge/tags/blocks/chests.json
3260d80138f7c357d2efbda403e8d0e6a957d75b data/forge/tags/blocks/end_stones.json
424e2e03cf62f23f4496468a97b9f0df060df9fe data/forge/tags/blocks/glass.json
763fefed687a3383a23e481415837b08a931661f data/forge/tags/blocks/obsidian.json
f87bf8e15aea2ca3068935be41828e61a22e6ef8 data/forge/tags/blocks/obsidian.json
83ea3831e8edbb4cab7f4a997b6e78b74d273493 data/forge/tags/blocks/ores.json
9a1109a26cfd5f396d8e080f77d8277f130f299d data/forge/tags/blocks/storage_blocks.json
2903a69c4cd7c37db3891af9c0736568ccc3acff data/forge/tags/items/chests.json
@@ -493,7 +480,7 @@ d3fbc7a0a7d1a6cd5b4a2d6604a4625c57b57a9a data/forge/tags/items/ender_pearls.json
ff2ba2285b4163d5d08376c6d99477f96273310c data/forge/tags/items/heads.json
144c342bc93a719b95e99b4d9493ed29885bf71b data/forge/tags/items/ingots.json
b187118e591990e8c0397058318592c587c3dcff data/forge/tags/items/nuggets.json
763fefed687a3383a23e481415837b08a931661f data/forge/tags/items/obsidian.json
f87bf8e15aea2ca3068935be41828e61a22e6ef8 data/forge/tags/items/obsidian.json
83ea3831e8edbb4cab7f4a997b6e78b74d273493 data/forge/tags/items/ores.json
ebdc7d4617021fcc8582e3a17b42d4a815d9e021 data/forge/tags/items/rods.json
9a1109a26cfd5f396d8e080f77d8277f130f299d data/forge/tags/items/storage_blocks.json
@@ -516,7 +503,6 @@ 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
@@ -580,29 +566,25 @@ e66091a13a6e7593eb5bd971978d24a5a0e375b3 data/hee/loot_tables/blocks/whitebark.j
9bd3a9e24162d2c81047b834f8f79d6cabec86be data/hee/loot_tables/blocks/whitebark_planks.json
7d84dc443a052e349593b71d2c0a523e75396cdf data/hee/loot_tables/blocks/whitebark_slab.json
83e0b81adb3f9dd488397e8459b95f7b0ce19927 data/hee/loot_tables/blocks/whitebark_stairs.json
37f3c55266db3db8dc6d22fdbaf3d53243016b77 data/hee/tags/blocks/gloomrock_particles.json
1a70c674d979a59cea18d92f2227ab8a5ed2ccc7 data/hee/tags/blocks/void_portal_frame_crafted.json
f5996244831ab38fe1fae2f304bbd7825d6ad98b data/minecraft/tags/blocks/bamboo_plantable_on.json
479189f9b35a3c8f795539daf6a1809130242c5b data/minecraft/tags/blocks/flower_pots.json
74700d556ca80c7a1db5fd4efb09c3ddb26cad66 data/minecraft/tags/blocks/flower_pots.json
424e2e03cf62f23f4496468a97b9f0df060df9fe data/minecraft/tags/blocks/impermeable.json
4557912145f8c53493f249ef3961d02e156891e4 data/minecraft/tags/blocks/leaves.json
74700d556ca80c7a1db5fd4efb09c3ddb26cad66 data/minecraft/tags/blocks/leaves.json
4ea74ec750ba7360a7843a0d4a604ac7b35dfa96 data/minecraft/tags/blocks/logs.json
4ea74ec750ba7360a7843a0d4a604ac7b35dfa96 data/minecraft/tags/blocks/logs_that_burn.json
697395021049c8cccfac2486c52eb6664cc5bad6 data/minecraft/tags/blocks/planks.json
10fff7e5092ddc68cc1611ad4605dc4d6608e227 data/minecraft/tags/blocks/portals.json
6f73d4c0d7c0f2650b498f35a60e8fe9c280c765 data/minecraft/tags/blocks/saplings.json
eb69de8447077a713baaab7e10184ec283c25516 data/minecraft/tags/blocks/slabs.json
07e3d7d270309424e1ab60a1b89ab2da85f800c7 data/minecraft/tags/blocks/stairs.json
5318f9d9be9209139567f7f58d77d1b27d9d1327 data/minecraft/tags/blocks/walls.json
74700d556ca80c7a1db5fd4efb09c3ddb26cad66 data/minecraft/tags/blocks/saplings.json
74700d556ca80c7a1db5fd4efb09c3ddb26cad66 data/minecraft/tags/blocks/slabs.json
74700d556ca80c7a1db5fd4efb09c3ddb26cad66 data/minecraft/tags/blocks/stairs.json
74700d556ca80c7a1db5fd4efb09c3ddb26cad66 data/minecraft/tags/blocks/walls.json
8a04ae43dc7062677394df7bf7276dbc92a5f1ca data/minecraft/tags/blocks/wooden_slabs.json
3bf587d2f806c14a76a10db8f43386552382c381 data/minecraft/tags/blocks/wooden_stairs.json
4557912145f8c53493f249ef3961d02e156891e4 data/minecraft/tags/items/leaves.json
74700d556ca80c7a1db5fd4efb09c3ddb26cad66 data/minecraft/tags/items/leaves.json
4ea74ec750ba7360a7843a0d4a604ac7b35dfa96 data/minecraft/tags/items/logs.json
4ea74ec750ba7360a7843a0d4a604ac7b35dfa96 data/minecraft/tags/items/logs_that_burn.json
697395021049c8cccfac2486c52eb6664cc5bad6 data/minecraft/tags/items/planks.json
6f73d4c0d7c0f2650b498f35a60e8fe9c280c765 data/minecraft/tags/items/saplings.json
eb69de8447077a713baaab7e10184ec283c25516 data/minecraft/tags/items/slabs.json
07e3d7d270309424e1ab60a1b89ab2da85f800c7 data/minecraft/tags/items/stairs.json
5318f9d9be9209139567f7f58d77d1b27d9d1327 data/minecraft/tags/items/walls.json
74700d556ca80c7a1db5fd4efb09c3ddb26cad66 data/minecraft/tags/items/saplings.json
74700d556ca80c7a1db5fd4efb09c3ddb26cad66 data/minecraft/tags/items/slabs.json
74700d556ca80c7a1db5fd4efb09c3ddb26cad66 data/minecraft/tags/items/stairs.json
74700d556ca80c7a1db5fd4efb09c3ddb26cad66 data/minecraft/tags/items/walls.json
8a04ae43dc7062677394df7bf7276dbc92a5f1ca data/minecraft/tags/items/wooden_slabs.json
3bf587d2f806c14a76a10db8f43386552382c381 data/minecraft/tags/items/wooden_stairs.json

View File

@@ -1,16 +0,0 @@
{
"variants": {
"level=0": {
"model": "minecraft:block/cauldron"
},
"level=1": {
"model": "hee:block/cauldron_dragons_breath_level1"
},
"level=2": {
"model": "hee:block/cauldron_dragons_breath_level2"
},
"level=3": {
"model": "hee:block/cauldron_dragons_breath_level3"
}
}
}

View File

@@ -1,16 +0,0 @@
{
"variants": {
"level=0": {
"model": "minecraft:block/cauldron"
},
"level=1": {
"model": "hee:block/cauldron_ender_goo_level1"
},
"level=2": {
"model": "hee:block/cauldron_ender_goo_level2"
},
"level=3": {
"model": "hee:block/cauldron_ender_goo_level3"
}
}
}

View File

@@ -1,16 +0,0 @@
{
"variants": {
"level=0": {
"model": "minecraft:block/cauldron"
},
"level=1": {
"model": "hee:block/cauldron_purified_ender_goo_level1"
},
"level=2": {
"model": "hee:block/cauldron_purified_ender_goo_level2"
},
"level=3": {
"model": "hee:block/cauldron_purified_ender_goo_level3"
}
}
}

View File

@@ -1,7 +1,7 @@
{
"variants": {
"": {
"model": "minecraft:block/obsidian"
"model": "hee:block/obsidian_falling"
}
}
}

View File

@@ -1,90 +0,0 @@
{
"multipart": [
{
"when": {
"up": "true"
},
"apply": {
"model": "hee:block/stone_brick_wall_post"
}
},
{
"when": {
"east": "low"
},
"apply": {
"model": "hee:block/stone_brick_wall_side",
"y": 90,
"uvlock": true
}
},
{
"when": {
"east": "tall"
},
"apply": {
"model": "hee:block/stone_brick_wall_side_tall",
"y": 90,
"uvlock": true
}
},
{
"when": {
"north": "low"
},
"apply": {
"model": "hee:block/stone_brick_wall_side",
"uvlock": true
}
},
{
"when": {
"north": "tall"
},
"apply": {
"model": "hee:block/stone_brick_wall_side_tall",
"uvlock": true
}
},
{
"when": {
"south": "low"
},
"apply": {
"model": "hee:block/stone_brick_wall_side",
"y": 180,
"uvlock": true
}
},
{
"when": {
"south": "tall"
},
"apply": {
"model": "hee:block/stone_brick_wall_side_tall",
"y": 180,
"uvlock": true
}
},
{
"when": {
"west": "low"
},
"apply": {
"model": "hee:block/stone_brick_wall_side",
"y": 270,
"uvlock": true
}
},
{
"when": {
"west": "tall"
},
"apply": {
"model": "hee:block/stone_brick_wall_side_tall",
"y": 270,
"uvlock": true
}
}
]
}

View File

@@ -1,7 +0,0 @@
{
"parent": "minecraft:block/fire_floor0",
"textures": {
"particle": "hee:block/eternal_fire_0",
"fire": "hee:block/eternal_fire_0"
}
}

View File

@@ -1,7 +0,0 @@
{
"parent": "minecraft:block/fire_floor1",
"textures": {
"particle": "hee:block/eternal_fire_1",
"fire": "hee:block/eternal_fire_1"
}
}

View File

@@ -1,7 +0,0 @@
{
"parent": "minecraft:block/fire_side0",
"textures": {
"particle": "hee:block/eternal_fire_0",
"fire": "hee:block/eternal_fire_0"
}
}

View File

@@ -1,7 +0,0 @@
{
"parent": "minecraft:block/fire_side1",
"textures": {
"particle": "hee:block/eternal_fire_1",
"fire": "hee:block/eternal_fire_1"
}
}

View File

@@ -1,7 +0,0 @@
{
"parent": "minecraft:block/fire_side_alt0",
"textures": {
"particle": "hee:block/eternal_fire_0",
"fire": "hee:block/eternal_fire_0"
}
}

View File

@@ -1,7 +0,0 @@
{
"parent": "minecraft:block/fire_side_alt1",
"textures": {
"particle": "hee:block/eternal_fire_1",
"fire": "hee:block/eternal_fire_1"
}
}

View File

@@ -1,7 +0,0 @@
{
"parent": "minecraft:block/fire_up0",
"textures": {
"particle": "hee:block/eternal_fire_0",
"fire": "hee:block/eternal_fire_0"
}
}

View File

@@ -1,7 +0,0 @@
{
"parent": "minecraft:block/fire_up1",
"textures": {
"particle": "hee:block/eternal_fire_1",
"fire": "hee:block/eternal_fire_1"
}
}

View File

@@ -1,7 +0,0 @@
{
"parent": "minecraft:block/fire_up_alt0",
"textures": {
"particle": "hee:block/eternal_fire_0",
"fire": "hee:block/eternal_fire_0"
}
}

View File

@@ -1,7 +0,0 @@
{
"parent": "minecraft:block/fire_up_alt1",
"textures": {
"particle": "hee:block/eternal_fire_1",
"fire": "hee:block/eternal_fire_1"
}
}

View File

@@ -1,4 +1,5 @@
{
"parent": "minecraft:block/block",
"textures": {
"particle": "hee:block/loot_chest_particle"
}

View File

@@ -0,0 +1,6 @@
{
"parent": "minecraft:block/cube_all",
"textures": {
"all": "minecraft:block/obsidian"
}
}

View File

@@ -0,0 +1,3 @@
{
"parent": "hee:block/corrupted_energy"
}

View File

@@ -1,3 +1,3 @@
{
"parent": "minecraft:block/obsidian"
"parent": "hee:block/obsidian_falling"
}

View File

@@ -7,7 +7,6 @@
"hee:obsidian_pillar",
"hee:obsidian_smooth_lit",
"hee:obsidian_chiseled_lit",
"hee:obsidian_pillar_lit",
"hee:obsidian_tower_top"
"hee:obsidian_pillar_lit"
]
}

View File

@@ -7,7 +7,6 @@
"hee:obsidian_pillar",
"hee:obsidian_smooth_lit",
"hee:obsidian_chiseled_lit",
"hee:obsidian_pillar_lit",
"hee:obsidian_tower_top"
"hee:obsidian_pillar_lit"
]
}

View File

@@ -1,19 +0,0 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "hee:dusty_stone_decoration"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

View File

@@ -1,17 +0,0 @@
{
"replace": false,
"values": [
"hee:gloomrock",
"hee:gloomrock_bricks",
"hee:gloomrock_smooth",
"hee:gloomrock_smooth_red",
"hee:gloomrock_smooth_orange",
"hee:gloomrock_smooth_yellow",
"hee:gloomrock_smooth_green",
"hee:gloomrock_smooth_cyan",
"hee:gloomrock_smooth_blue",
"hee:gloomrock_smooth_purple",
"hee:gloomrock_smooth_magenta",
"hee:gloomrock_smooth_white"
]
}

View File

@@ -1,7 +0,0 @@
{
"replace": false,
"values": [
"hee:void_portal_frame_crafted",
"hee:void_portal_storage_crafted"
]
}

View File

@@ -1,12 +1,4 @@
{
"replace": false,
"values": [
"hee:potted_autumn_sapling_red",
"hee:potted_autumn_sapling_brown",
"hee:potted_autumn_sapling_orange",
"hee:potted_autumn_sapling_yellowgreen",
"hee:potted_death_flower",
"hee:potted_death_flower_healed",
"hee:potted_death_flower_withered"
]
"values": []
}

View File

@@ -1,9 +1,4 @@
{
"replace": false,
"values": [
"hee:autumn_leaves_red",
"hee:autumn_leaves_brown",
"hee:autumn_leaves_orange",
"hee:autumn_leaves_yellowgreen"
]
"values": []
}

View File

@@ -1,7 +0,0 @@
{
"replace": false,
"values": [
"hee:whitebark_log",
"hee:whitebark"
]
}

View File

@@ -1,9 +1,4 @@
{
"replace": false,
"values": [
"hee:autumn_sapling_red",
"hee:autumn_sapling_brown",
"hee:autumn_sapling_orange",
"hee:autumn_sapling_yellowgreen"
]
"values": []
}

View File

@@ -1,10 +1,4 @@
{
"replace": false,
"values": [
"hee:gloomrock_brick_slab",
"hee:gloomrock_smooth_slab",
"hee:dusty_stone_brick_slab",
"hee:dark_loam_slab",
"hee:whitebark_slab"
]
"values": []
}

View File

@@ -1,10 +1,4 @@
{
"replace": false,
"values": [
"hee:gloomrock_brick_stairs",
"hee:gloomrock_smooth_stairs",
"hee:dusty_stone_brick_stairs",
"hee:obsidian_stairs",
"hee:whitebark_stairs"
]
"values": []
}

View File

@@ -1,6 +1,4 @@
{
"replace": false,
"values": [
"hee:stone_brick_wall"
]
"values": []
}

View File

@@ -1,9 +1,4 @@
{
"replace": false,
"values": [
"hee:autumn_leaves_red",
"hee:autumn_leaves_brown",
"hee:autumn_leaves_orange",
"hee:autumn_leaves_yellowgreen"
]
"values": []
}

View File

@@ -1,7 +0,0 @@
{
"replace": false,
"values": [
"hee:whitebark_log",
"hee:whitebark"
]
}

View File

@@ -1,9 +1,4 @@
{
"replace": false,
"values": [
"hee:autumn_sapling_red",
"hee:autumn_sapling_brown",
"hee:autumn_sapling_orange",
"hee:autumn_sapling_yellowgreen"
]
"values": []
}

View File

@@ -1,10 +1,4 @@
{
"replace": false,
"values": [
"hee:gloomrock_brick_slab",
"hee:gloomrock_smooth_slab",
"hee:dusty_stone_brick_slab",
"hee:dark_loam_slab",
"hee:whitebark_slab"
]
"values": []
}

View File

@@ -1,10 +1,4 @@
{
"replace": false,
"values": [
"hee:gloomrock_brick_stairs",
"hee:gloomrock_smooth_stairs",
"hee:dusty_stone_brick_stairs",
"hee:obsidian_stairs",
"hee:whitebark_stairs"
]
"values": []
}

View File

@@ -1,6 +1,4 @@
{
"replace": false,
"values": [
"hee:stone_brick_wall"
]
"values": []
}

View File

@@ -1,15 +1,15 @@
package chylex.hee.datagen
import chylex.hee.HEE
import chylex.hee.datagen.client.BlockItemModels
import chylex.hee.datagen.client.BlockModels
import chylex.hee.datagen.client.BlockStates
import chylex.hee.datagen.client.ItemModels
import chylex.hee.datagen.client.LangEnglish
import chylex.hee.datagen.server.BlockLootTables
import chylex.hee.datagen.server.BlockTags
import chylex.hee.datagen.server.ItemTags
import chylex.hee.util.forge.SubscribeAllEvents
import net.minecraftforge.eventbus.api.SubscribeEvent
import chylex.hee.system.forge.SubscribeAllEvents
import chylex.hee.system.forge.SubscribeEvent
import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus.MOD
import net.minecraftforge.fml.event.lifecycle.GatherDataEvent
@@ -22,10 +22,10 @@ object DataGen {
with(e.generator) {
if (e.includeClient()) {
addProvider(BlockModels(this, modid, helper))
addProvider(BlockStates(this, modid, helper))
addProvider(BlockModels(this, modid, helper))
addProvider(BlockItemModels(this, modid, helper))
addProvider(ItemModels(this, modid, helper))
addProvider(LangEnglish(this, modid))
}
if (e.includeServer()) {

View File

@@ -1,14 +1,53 @@
package chylex.hee.datagen
import chylex.hee.HEE
import chylex.hee.system.facades.Resource
import net.minecraft.block.Block
import net.minecraft.data.IDataProvider
import net.minecraft.item.Item
import net.minecraft.util.IItemProvider
import net.minecraft.util.ResourceLocation
import net.minecraftforge.client.model.generators.ModelBuilder
import net.minecraftforge.client.model.generators.ModelProvider
import net.minecraftforge.registries.IForgeRegistryEntry
val IForgeRegistryEntry<*>.path: String
get() = registryName!!.path
val IForgeRegistryEntry<*>.isVanilla
get() = Resource.isVanilla(registryName!!)
val IItemProvider.r
get() = when(this) {
is Block -> resource("block/" + this.path, this.isVanilla)
is Item -> resource("item/" + this.path, this.isVanilla)
else -> throw IllegalArgumentException()
}
fun IItemProvider.r(suffix: String): ResourceLocation {
return when(this) {
is Block -> resource("block/" + this.path + suffix, this.isVanilla)
is Item -> resource("item/" + this.path + suffix, this.isVanilla)
else -> throw IllegalArgumentException()
}
}
fun resource(path: String, vanilla: Boolean): ResourceLocation {
return if (vanilla) Resource.Vanilla(path) else Resource.Custom(path)
}
inline fun <T : IDataProvider> T?.safeUnit(callback: T.() -> Unit) {
try {
this?.callback()
} catch (e: Exception) {
} catch(e: Exception) {
HEE.log.error("[DataGen] " + e.message)
}
}
inline fun <T : ModelBuilder<T>, U : ModelProvider<T>> U?.safeUnit(callback: U.() -> Unit) {
try {
this?.callback()
} catch(e: Exception) {
HEE.log.error("[DataGen] " + e.message)
}
}
@@ -16,7 +55,7 @@ inline fun <T : IDataProvider> T?.safeUnit(callback: T.() -> Unit) {
inline fun <T : ModelBuilder<T>, U : ModelProvider<T>> U?.safe(callback: U.() -> T): T? {
return try {
this?.callback()
} catch (e: Exception) {
} catch(e: Exception) {
HEE.log.error("[DataGen] " + e.message)
null
}
@@ -25,8 +64,12 @@ inline fun <T : ModelBuilder<T>, U : ModelProvider<T>> U?.safe(callback: U.() ->
inline fun <T : ModelBuilder<T>> T?.then(callback: T.() -> T): T? {
return try {
this?.callback()
} catch (e: Exception) {
} catch(e: Exception) {
HEE.log.error("[DataGen] " + e.message)
null
}
}
class Callback<T>(val item: T, val suffix: String, val path: String) {
override fun toString() = path
}

View File

@@ -0,0 +1,115 @@
package chylex.hee.datagen.client
import chylex.hee.datagen.client.util.block
import chylex.hee.datagen.client.util.multi
import chylex.hee.datagen.client.util.override
import chylex.hee.datagen.client.util.parent
import chylex.hee.datagen.client.util.simple
import chylex.hee.datagen.r
import chylex.hee.datagen.then
import chylex.hee.init.ModBlocks
import chylex.hee.system.facades.Resource
import net.minecraft.block.Blocks
import net.minecraft.data.DataGenerator
import net.minecraftforge.client.model.generators.ItemModelProvider
import net.minecraftforge.common.data.ExistingFileHelper
class BlockItemModels(generator: DataGenerator, modid: String, existingFileHelper: ExistingFileHelper) : ItemModelProvider(generator, modid, existingFileHelper) {
override fun registerModels() {
// Blocks: Building (Uncategorized)
parent(ModBlocks.STONE_BRICK_WALL, Resource.Custom("block/stone_brick_wall_inventory"), checkExistence = false)
parent(ModBlocks.INFUSED_GLASS, Resource.Custom("block/infused_glass_c0"))
block(ModBlocks.ENDERSOL)
block(ModBlocks.HUMUS)
// Blocks: Building (Gloomrock)
simple(ModBlocks.GLOOMTORCH.asItem())
// Blocks: Building (Grave Dirt)
parent(ModBlocks.GRAVE_DIRT_PLAIN, Resource.Custom("block/grave_dirt_low"))
parent(ModBlocks.GRAVE_DIRT_LOOT, Resource.Custom("block/grave_dirt_loot_4"), checkExistence = false)
parent(ModBlocks.GRAVE_DIRT_SPIDERLING, Resource.Custom("block/grave_dirt_low"))
// Blocks: Interactive (Storage)
parent(ModBlocks.DARK_CHEST, Blocks.CHEST.asItem().r)
parent(ModBlocks.LOOT_CHEST, Blocks.CHEST.asItem().r)
// Blocks: Interactive (Puzzle)
parent(ModBlocks.PUZZLE_PLAIN, Resource.Custom("block/puzzle_base_active"), checkExistence = false)
parent(ModBlocks.PUZZLE_BURST_3, Resource.Custom("block/puzzle_block_inventory")).then {
texture("top", Resource.Custom("block/puzzle_overlay_burst_3"))
}
parent(ModBlocks.PUZZLE_BURST_5, Resource.Custom("block/puzzle_block_inventory")).then {
texture("top", Resource.Custom("block/puzzle_overlay_burst_5"))
}
parent(ModBlocks.PUZZLE_REDIRECT_1, Resource.Custom("block/puzzle_block_inventory")).then {
texture("top", Resource.Custom("block/puzzle_overlay_redirect_1n"))
}
parent(ModBlocks.PUZZLE_REDIRECT_2, Resource.Custom("block/puzzle_block_inventory")).then {
texture("top", Resource.Custom("block/puzzle_overlay_redirect_2ns"))
}
parent(ModBlocks.PUZZLE_REDIRECT_4, Resource.Custom("block/puzzle_block_inventory")).then {
texture("top", Resource.Custom("block/puzzle_overlay_redirect_4"))
}
parent(ModBlocks.PUZZLE_TELEPORT, Resource.Custom("block/puzzle_block_inventory")).then {
texture("top", Resource.Custom("block/puzzle_overlay_teleport"))
}
// Blocks: Interactive (Gates)
block(ModBlocks.EXPERIENCE_GATE)
// Blocks: Interactive (Uncategorized)
simple(ModBlocks.IGNEOUS_PLATE)
simple(ModBlocks.ENHANCED_BREWING_STAND.asItem())
// Blocks: Decorative (Trees)
simple(ModBlocks.WHITEBARK_SAPLING_AUTUMN_RED)
simple(ModBlocks.WHITEBARK_SAPLING_AUTUMN_BROWN)
simple(ModBlocks.WHITEBARK_SAPLING_AUTUMN_ORANGE)
simple(ModBlocks.WHITEBARK_SAPLING_AUTUMN_YELLOWGREEN)
// Blocks: Decorative (Plants)
simple(ModBlocks.DEATH_FLOWER_DECAYING, ModBlocks.DEATH_FLOWER_DECAYING.r("_1")).then {
override(ModBlocks.DEATH_FLOWER_DECAYING.asItem().r("_2")) { predicate(Resource.Custom("death_level"), 4F) }
override(ModBlocks.DEATH_FLOWER_DECAYING.asItem().r("_3")) { predicate(Resource.Custom("death_level"), 8F) }
override(ModBlocks.DEATH_FLOWER_DECAYING.asItem().r("_4")) { predicate(Resource.Custom("death_level"), 12F) }
}
multi(ModBlocks.DEATH_FLOWER_DECAYING, Resource.Vanilla("item/generated"), 1..4) {
texture("layer0", Resource.Custom("block/" + it.path))
}
simple(ModBlocks.DEATH_FLOWER_HEALED)
simple(ModBlocks.DEATH_FLOWER_WITHERED)
// Blocks: Decorative (Uncategorized)
simple(ModBlocks.ANCIENT_COBWEB)
simple(ModBlocks.DRY_VINES, Blocks.VINE.r)
block(ModBlocks.ENDERMAN_HEAD)
// Blocks: Energy
simple(ModBlocks.ENERGY_CLUSTER)
// Blocks: Tables
block(ModBlocks.TABLE_PEDESTAL)
}
}

View File

@@ -1,74 +1,220 @@
package chylex.hee.datagen.client
import chylex.hee.datagen.client.util.cauldron
import chylex.hee.datagen.client.util.cross
import chylex.hee.datagen.client.util.cube
import chylex.hee.datagen.client.util.cubeBottomTop
import chylex.hee.datagen.client.util.cubeColumn
import chylex.hee.datagen.client.util.flowerPot
import chylex.hee.datagen.client.util.leaves
import chylex.hee.datagen.client.util.multi
import chylex.hee.datagen.client.util.parent
import chylex.hee.datagen.client.util.particle
import chylex.hee.datagen.client.util.portalFrame
import chylex.hee.datagen.client.util.simple
import chylex.hee.datagen.client.util.suffixed
import chylex.hee.datagen.client.util.table
import chylex.hee.datagen.client.util.wall
import chylex.hee.datagen.r
import chylex.hee.datagen.then
import chylex.hee.game.Resource.location
import chylex.hee.game.block.BlockAbstractTable
import chylex.hee.game.block.IHeeBlock
import chylex.hee.game.block.properties.BlockModel
import chylex.hee.game.block.properties.BlockModel.CubeBottomTop
import chylex.hee.game.block.properties.BlockModel.CubeColumn
import chylex.hee.game.block.properties.BlockModel.Fluid
import chylex.hee.game.block.properties.BlockModel.FromParent
import chylex.hee.game.block.properties.BlockModel.Manual
import chylex.hee.game.block.properties.BlockModel.Multi
import chylex.hee.game.block.properties.BlockModel.NoAmbientOcclusion
import chylex.hee.game.block.properties.BlockModel.Parent
import chylex.hee.game.block.properties.BlockModel.ParticleOnly
import chylex.hee.game.block.properties.BlockModel.PortalFrame
import chylex.hee.game.block.properties.BlockModel.SimpleBlockModel
import chylex.hee.game.block.properties.BlockModel.Suffixed
import chylex.hee.game.block.properties.BlockModel.Table
import chylex.hee.game.block.properties.BlockModel.WithTextures
import chylex.hee.init.ModBlocks
import net.minecraft.block.Block
import chylex.hee.system.facades.Resource
import net.minecraft.block.Blocks
import net.minecraft.data.DataGenerator
import net.minecraftforge.client.model.generators.BlockModelBuilder
import net.minecraftforge.client.model.generators.BlockModelProvider
import net.minecraftforge.common.data.ExistingFileHelper
class BlockModels(generator: DataGenerator, modid: String, existingFileHelper: ExistingFileHelper) : BlockModelProvider(generator, modid, existingFileHelper) {
override fun registerModels() {
for (block in ModBlocks.ALL) {
(block as? IHeeBlock)?.let { registerModel(block, it.model.generate(block).blockModel) { builder -> builder } }
// Blocks: Building (Uncategorized)
wall(ModBlocks.STONE_BRICK_WALL, Blocks.STONE_BRICKS.r)
simple(ModBlocks.STONE_BRICK_WALL.suffixed("_inventory"), Resource.Vanilla("block/wall_inventory"), "wall", Blocks.STONE_BRICKS.r)
cubeColumn(ModBlocks.ENDERSOL)
cubeBottomTop(ModBlocks.ENDERSOL.suffixed("_merge_1"), ModBlocks.ENDERSOL.r("_merge_1"), Blocks.END_STONE.r, ModBlocks.ENDERSOL.r("_top"))
cubeBottomTop(ModBlocks.ENDERSOL.suffixed("_merge_2"), ModBlocks.ENDERSOL.r("_merge_2"), Blocks.END_STONE.r, ModBlocks.ENDERSOL.r("_top"))
cube(ModBlocks.HUMUS)
cubeBottomTop(ModBlocks.HUMUS.suffixed("_merge"), ModBlocks.HUMUS.r("_merge"), ModBlocks.ENDERSOL.r("_top"), ModBlocks.HUMUS.r)
// Blocks: Building (Obsidian)
cube(ModBlocks.OBSIDIAN_FALLING, Blocks.OBSIDIAN.r)
// Blocks: Building (End Stone)
cubeBottomTop(ModBlocks.END_STONE_INFESTED, bottom = Blocks.END_STONE.r).then {
texture("particle", ModBlocks.END_STONE_INFESTED.r("_top"))
}
}
private fun registerModel(block: Block, model: BlockModel, callback: (BlockModelBuilder) -> BlockModelBuilder) {
when (model) {
is SimpleBlockModel -> simple(block, model.parent, model.textureName, model.textureLocation ?: block.location)?.then(callback)
is CubeBottomTop -> cubeBottomTop(block, model.side ?: block.location("_side"), model.bottom ?: block.location("_bottom"), model.top ?: block.location("_top"))?.then(callback)
is PortalFrame -> portalFrame(block, model.frameBlock.location("_side"), model.frameBlock.location("_top_" + model.topSuffix))?.then(callback)
is ParticleOnly -> particle(block, model.particle)?.then(callback)
is Parent -> parent(model.name, model.parent)?.then(callback)
is FromParent -> parent(block, model.parent)?.then(callback)
is Suffixed -> registerModel(block.suffixed(model.suffix), model.wrapped, callback)
is WithTextures -> registerModel(block, model.baseModel) {
model.textures.entries.fold(callback(it)) { builder, (name, location) -> builder.texture(name, location) }
}
is NoAmbientOcclusion -> registerModel(block, model.baseModel) {
callback(it).ao(false)
}
is Multi -> {
for (innerModel in model.models) {
registerModel(block, innerModel, callback)
}
}
CubeColumn -> cubeColumn(block)?.then(callback)
Table -> table(block as BlockAbstractTable)?.then(callback)
Fluid -> particle(block, block.location("_still"))?.then(callback)
Manual -> return
cubeBottomTop(ModBlocks.END_STONE_BURNED, bottom = Blocks.END_STONE.r).then {
texture("particle", ModBlocks.END_STONE_BURNED.r("_top"))
}
cubeBottomTop(ModBlocks.END_STONE_ENCHANTED, bottom = Blocks.END_STONE.r).then {
texture("particle", ModBlocks.END_STONE_ENCHANTED.r("_top"))
}
// Blocks: Building (Grave Dirt)
cube(ModBlocks.GRAVE_DIRT_PLAIN.suffixed("_full"), ModBlocks.GRAVE_DIRT_PLAIN.r).then {
texture("particle", ModBlocks.GRAVE_DIRT_PLAIN.r)
}
multi(ModBlocks.GRAVE_DIRT_LOOT, Resource.Custom("block/grave_dirt_low"), 1..6) {
texture("top", Resource.Custom("block/$it"))
}
// Blocks: Building (Wood)
cube(ModBlocks.WHITEBARK, ModBlocks.WHITEBARK_LOG.r)
// Blocks: Fluids
particle(ModBlocks.ENDER_GOO, ModBlocks.ENDER_GOO.r("_still"))
particle(ModBlocks.PURIFIED_ENDER_GOO, ModBlocks.PURIFIED_ENDER_GOO.r("_still"))
cauldron(ModBlocks.CAULDRON_ENDER_GOO, ModBlocks.ENDER_GOO.r("_still"))
cauldron(ModBlocks.CAULDRON_PURIFIED_ENDER_GOO, ModBlocks.PURIFIED_ENDER_GOO.r("_still"))
cauldron(ModBlocks.CAULDRON_DRAGONS_BREATH, Resource.Custom("block/dragons_breath_still"))
// Blocks: Interactive (Storage)
particle(ModBlocks.DARK_CHEST, ModBlocks.GLOOMROCK_SMOOTH.r)
parent(ModBlocks.LOOT_CHEST, Resource.Vanilla("block/block")).then {
texture("particle", ModBlocks.LOOT_CHEST.r("_particle"))
}
// Blocks: Interactive (Puzzle)
arrayOf("active", "disabled", "inactive").forEach {
parent("puzzle_base_$it", Resource.Vanilla("block/cube_all")).then {
texture("all", Resource.Custom("block/puzzle_base_$it"))
}
}
arrayOf("burst_3", "burst_5", "redirect_1e", "redirect_1n", "redirect_1s", "redirect_1w", "redirect_2ew", "redirect_2ns", "redirect_4", "teleport").forEach {
parent("puzzle_overlay_$it", Resource.Custom("block/puzzle_overlay")).then {
texture("overlay", Resource.Custom("block/puzzle_overlay_$it"))
}
}
// Blocks: Interactive (Gates)
cubeBottomTop(ModBlocks.EXPERIENCE_GATE, top = ModBlocks.EXPERIENCE_GATE.r("_bottom"))
multi(ModBlocks.EXPERIENCE_GATE, ModBlocks.EXPERIENCE_GATE.r, arrayOf("_rd1", "_rd2", "_ud")) {
texture("top", Resource.Custom("block/experience_gate_top" + it.suffix))
}
cubeBottomTop(ModBlocks.EXPERIENCE_GATE_CONTROLLER, ModBlocks.EXPERIENCE_GATE.r("_side"), ModBlocks.EXPERIENCE_GATE.r("_bottom"), ModBlocks.EXPERIENCE_GATE.r("_top_controller"))
// Blocks: Interactive (Uncategorized)
cubeBottomTop(ModBlocks.INFUSED_TNT, Blocks.TNT.r("_side"), Blocks.TNT.r("_bottom"), Blocks.TNT.r("_top"))
particle(ModBlocks.IGNEOUS_PLATE, ModBlocks.IGNEOUS_PLATE.r)
parent(ModBlocks.ENHANCED_BREWING_STAND, Blocks.BREWING_STAND.r).then {
texture("particle", Blocks.BREWING_STAND.r)
texture("base", Blocks.BREWING_STAND.r("_base"))
texture("stand", ModBlocks.ENHANCED_BREWING_STAND.r)
}
// Blocks: Ores
parent(ModBlocks.STARDUST_ORE, Resource.Custom("block/cube_overlay")).then {
texture("particle", ModBlocks.STARDUST_ORE.r("_particle"))
texture("base", Blocks.END_STONE.r)
}
// Blocks: Decorative (Trees)
cross(ModBlocks.WHITEBARK_SAPLING_AUTUMN_RED)
cross(ModBlocks.WHITEBARK_SAPLING_AUTUMN_BROWN)
cross(ModBlocks.WHITEBARK_SAPLING_AUTUMN_ORANGE)
cross(ModBlocks.WHITEBARK_SAPLING_AUTUMN_YELLOWGREEN)
leaves(ModBlocks.WHITEBARK_LEAVES_AUTUMN_RED)
leaves(ModBlocks.WHITEBARK_LEAVES_AUTUMN_BROWN)
leaves(ModBlocks.WHITEBARK_LEAVES_AUTUMN_ORANGE)
leaves(ModBlocks.WHITEBARK_LEAVES_AUTUMN_YELLOWGREEN)
flowerPot(ModBlocks.POTTED_WHITEBARK_SAPLING_AUTUMN_RED, ModBlocks.WHITEBARK_SAPLING_AUTUMN_RED)
flowerPot(ModBlocks.POTTED_WHITEBARK_SAPLING_AUTUMN_BROWN, ModBlocks.WHITEBARK_SAPLING_AUTUMN_BROWN)
flowerPot(ModBlocks.POTTED_WHITEBARK_SAPLING_AUTUMN_ORANGE, ModBlocks.WHITEBARK_SAPLING_AUTUMN_ORANGE)
flowerPot(ModBlocks.POTTED_WHITEBARK_SAPLING_AUTUMN_YELLOWGREEN, ModBlocks.WHITEBARK_SAPLING_AUTUMN_YELLOWGREEN)
// Blocks: Decorative (Plants)
multi(ModBlocks.DEATH_FLOWER_DECAYING, Resource.Vanilla("block/cross"), 1..4) {
texture("cross", Resource.Custom("block/$it"))
}
cross(ModBlocks.DEATH_FLOWER_HEALED)
cross(ModBlocks.DEATH_FLOWER_WITHERED)
multi(ModBlocks.POTTED_DEATH_FLOWER_DECAYING, Resource.Vanilla("block/flower_pot_cross"), 1..4) {
texture("plant", Resource.Custom("block/death_flower" + it.suffix))
}
flowerPot(ModBlocks.POTTED_DEATH_FLOWER_HEALED, ModBlocks.DEATH_FLOWER_HEALED)
flowerPot(ModBlocks.POTTED_DEATH_FLOWER_WITHERED, ModBlocks.DEATH_FLOWER_WITHERED)
// Blocks: Decorative (Uncategorized)
cross(ModBlocks.ANCIENT_COBWEB)
// Blocks: Portals
portalFrame(ModBlocks.END_PORTAL_FRAME, ModBlocks.END_PORTAL_FRAME.r("_side"), ModBlocks.END_PORTAL_FRAME.r("_top_plain"))
portalFrame(ModBlocks.END_PORTAL_ACCEPTOR, ModBlocks.END_PORTAL_FRAME.r("_side"), ModBlocks.END_PORTAL_FRAME.r("_top_acceptor"))
portalFrame(ModBlocks.VOID_PORTAL_FRAME, ModBlocks.VOID_PORTAL_FRAME.r("_side"), ModBlocks.VOID_PORTAL_FRAME.r("_top_plain"))
portalFrame(ModBlocks.VOID_PORTAL_STORAGE, ModBlocks.VOID_PORTAL_FRAME.r("_side"), ModBlocks.VOID_PORTAL_FRAME.r("_top_storage"))
portalFrame(ModBlocks.VOID_PORTAL_FRAME_CRAFTED, ModBlocks.VOID_PORTAL_FRAME.r("_side"), ModBlocks.VOID_PORTAL_FRAME.r("_top_plain"))
portalFrame(ModBlocks.VOID_PORTAL_STORAGE_CRAFTED, ModBlocks.VOID_PORTAL_FRAME.r("_side"), ModBlocks.VOID_PORTAL_FRAME.r("_top_storage"))
// Blocks: Energy
cross(ModBlocks.CORRUPTED_ENERGY, Blocks.BARRIER.asItem().r).then { ao(false) }
// Blocks: Tables
for(tier in 1..3) {
parent("table_tier_$tier", Resource.Custom("block/table")).then {
texture("particle", "hee:block/table_base")
texture("bottom", "hee:block/table_base")
texture("top", "hee:block/table_base")
texture("side", "hee:block/table_base_side_$tier")
}
}
parent(ModBlocks.TABLE_BASE_TIER_1, Resource.Custom("block/table_tier_1")).then {
Resource.Custom("block/transparent").let {
texture("overlay_top", it)
texture("overlay_side", it)
}
}
parent(ModBlocks.TABLE_BASE_TIER_2, Resource.Custom("block/table_tier_2")).then {
Resource.Custom("block/transparent").let {
texture("overlay_top", it)
texture("overlay_side", it)
}
}
parent(ModBlocks.TABLE_BASE_TIER_3, Resource.Custom("block/table_tier_3")).then {
Resource.Custom("block/transparent").let {
texture("overlay_top", it)
texture("overlay_side", it)
}
}
table(ModBlocks.ACCUMULATION_TABLE_TIER_1)
table(ModBlocks.ACCUMULATION_TABLE_TIER_2)
table(ModBlocks.ACCUMULATION_TABLE_TIER_3)
table(ModBlocks.EXPERIENCE_TABLE_TIER_1)
table(ModBlocks.EXPERIENCE_TABLE_TIER_2)
table(ModBlocks.EXPERIENCE_TABLE_TIER_3)
table(ModBlocks.INFUSION_TABLE_TIER_1)
table(ModBlocks.INFUSION_TABLE_TIER_2)
table(ModBlocks.INFUSION_TABLE_TIER_3)
}
}

View File

@@ -1,53 +1,191 @@
package chylex.hee.datagen.client
import chylex.hee.datagen.client.util.cauldron
import chylex.hee.datagen.client.util.cube
import chylex.hee.datagen.client.util.log
import chylex.hee.datagen.client.util.pillar
import chylex.hee.datagen.client.util.simpleStateAndItem
import chylex.hee.datagen.client.util.simpleStateOnly
import chylex.hee.datagen.client.util.slab
import chylex.hee.datagen.client.util.stairs
import chylex.hee.datagen.client.util.wall
import chylex.hee.game.block.IHeeBlock
import chylex.hee.game.block.properties.BlockStatePreset
import chylex.hee.game.block.properties.BlockStatePreset.Cauldron
import chylex.hee.game.block.properties.BlockStatePreset.Log
import chylex.hee.game.block.properties.BlockStatePreset.None
import chylex.hee.game.block.properties.BlockStatePreset.Pillar
import chylex.hee.game.block.properties.BlockStatePreset.PillarFrom
import chylex.hee.game.block.properties.BlockStatePreset.Simple
import chylex.hee.game.block.properties.BlockStatePreset.SimpleFrom
import chylex.hee.game.block.properties.BlockStatePreset.Slab
import chylex.hee.game.block.properties.BlockStatePreset.Stairs
import chylex.hee.game.block.properties.BlockStatePreset.Wall
import chylex.hee.datagen.r
import chylex.hee.init.ModBlocks
import net.minecraft.block.Block
import net.minecraft.block.RotatedPillarBlock
import net.minecraft.block.SlabBlock
import net.minecraft.block.StairsBlock
import net.minecraft.block.WallBlock
import net.minecraft.block.Blocks
import net.minecraft.data.DataGenerator
import net.minecraftforge.client.model.generators.BlockStateProvider
import net.minecraftforge.common.data.ExistingFileHelper
class BlockStates(generator: DataGenerator, modid: String, existingFileHelper: ExistingFileHelper) : BlockStateProvider(generator, modid, existingFileHelper) {
override fun registerStatesAndModels() {
for (block in ModBlocks.ALL) {
(block as? IHeeBlock)?.let { registerState(block, it.model.generate(block).blockState) }
}
}
private fun registerState(block: Block, model: BlockStatePreset) {
when (model) {
None -> return
Simple -> simpleStateOnly(block)
is SimpleFrom -> simpleStateOnly(block, model.modelBlock)
Pillar -> pillar(block as RotatedPillarBlock)
is PillarFrom -> pillar(block as RotatedPillarBlock, model.modelBlock)
is Stairs -> stairs(block as StairsBlock, model.fullBlock, model.side)
is Slab -> slab(block as SlabBlock, model.fullBlock, model.side)
is Wall -> wall(block as WallBlock, model.fullBlock)
is Cauldron -> cauldron(block, model.fluidTexture)
Log -> log(block as RotatedPillarBlock)
}
// Blocks: Building (Uncategorized)
cube(ModBlocks.ETHEREAL_LANTERN)
cube(ModBlocks.VANTABLOCK)
cube(ModBlocks.ENDIUM_BLOCK)
// Blocks: Building (Gloomrock)
cube(ModBlocks.GLOOMROCK)
cube(ModBlocks.GLOOMROCK_BRICKS)
stairs(ModBlocks.GLOOMROCK_BRICK_STAIRS, ModBlocks.GLOOMROCK_BRICKS)
slab(ModBlocks.GLOOMROCK_BRICK_SLAB, ModBlocks.GLOOMROCK_BRICKS)
cube(ModBlocks.GLOOMROCK_SMOOTH)
stairs(ModBlocks.GLOOMROCK_SMOOTH_STAIRS, ModBlocks.GLOOMROCK_SMOOTH, side = ModBlocks.GLOOMROCK_SMOOTH_SLAB.r("_side"))
slab(ModBlocks.GLOOMROCK_SMOOTH_SLAB, ModBlocks.GLOOMROCK_SMOOTH, side = ModBlocks.GLOOMROCK_SMOOTH_SLAB.r("_side"))
cube(ModBlocks.GLOOMROCK_SMOOTH_RED)
cube(ModBlocks.GLOOMROCK_SMOOTH_ORANGE)
cube(ModBlocks.GLOOMROCK_SMOOTH_YELLOW)
cube(ModBlocks.GLOOMROCK_SMOOTH_GREEN)
cube(ModBlocks.GLOOMROCK_SMOOTH_CYAN)
cube(ModBlocks.GLOOMROCK_SMOOTH_BLUE)
cube(ModBlocks.GLOOMROCK_SMOOTH_PURPLE)
cube(ModBlocks.GLOOMROCK_SMOOTH_MAGENTA)
cube(ModBlocks.GLOOMROCK_SMOOTH_WHITE)
// Blocks: Building (Dusty Stone)
cube(ModBlocks.DUSTY_STONE)
cube(ModBlocks.DUSTY_STONE_CRACKED)
cube(ModBlocks.DUSTY_STONE_DAMAGED)
cube(ModBlocks.DUSTY_STONE_BRICKS)
cube(ModBlocks.DUSTY_STONE_CRACKED_BRICKS)
cube(ModBlocks.DUSTY_STONE_DECORATION)
stairs(ModBlocks.DUSTY_STONE_BRICK_STAIRS, ModBlocks.DUSTY_STONE_BRICKS)
slab(ModBlocks.DUSTY_STONE_BRICK_SLAB, ModBlocks.DUSTY_STONE_BRICKS)
// Blocks: Building (Obsidian)
stairs(ModBlocks.OBSIDIAN_STAIRS, Blocks.OBSIDIAN)
simpleStateAndItem(ModBlocks.OBSIDIAN_FALLING)
cube(ModBlocks.OBSIDIAN_SMOOTH)
cube(ModBlocks.OBSIDIAN_CHISELED)
pillar(ModBlocks.OBSIDIAN_PILLAR)
cube(ModBlocks.OBSIDIAN_SMOOTH_LIT, ModBlocks.OBSIDIAN_SMOOTH)
cube(ModBlocks.OBSIDIAN_CHISELED_LIT, ModBlocks.OBSIDIAN_CHISELED)
pillar(ModBlocks.OBSIDIAN_PILLAR_LIT, ModBlocks.OBSIDIAN_PILLAR)
cube(ModBlocks.OBSIDIAN_TOWER_TOP, ModBlocks.OBSIDIAN_CHISELED)
// Blocks: Building (End Stone)
simpleStateAndItem(ModBlocks.END_STONE_INFESTED)
simpleStateAndItem(ModBlocks.END_STONE_BURNED)
simpleStateAndItem(ModBlocks.END_STONE_ENCHANTED)
// Blocks: Building (Dark Loam)
cube(ModBlocks.DARK_LOAM)
slab(ModBlocks.DARK_LOAM_SLAB, ModBlocks.DARK_LOAM)
// Blocks: Building (Wood)
log(ModBlocks.WHITEBARK_LOG)
simpleStateAndItem(ModBlocks.WHITEBARK)
cube(ModBlocks.WHITEBARK_PLANKS)
stairs(ModBlocks.WHITEBARK_STAIRS, ModBlocks.WHITEBARK_PLANKS)
slab(ModBlocks.WHITEBARK_SLAB, ModBlocks.WHITEBARK_PLANKS)
// Blocks: Building (Miner's Burial)
cube(ModBlocks.MINERS_BURIAL_BLOCK_PLAIN)
cube(ModBlocks.MINERS_BURIAL_BLOCK_CHISELED)
pillar(ModBlocks.MINERS_BURIAL_BLOCK_PILLAR)
cube(ModBlocks.MINERS_BURIAL_BLOCK_JAIL)
simpleStateAndItem(ModBlocks.MINERS_BURIAL_ALTAR)
// Blocks: Fluids
simpleStateOnly(ModBlocks.ENDER_GOO)
simpleStateOnly(ModBlocks.PURIFIED_ENDER_GOO)
// Blocks: Interactive (Storage)
simpleStateOnly(ModBlocks.JAR_O_DUST)
simpleStateOnly(ModBlocks.DARK_CHEST)
simpleStateOnly(ModBlocks.LOOT_CHEST)
// Blocks: Interactive (Puzzle)
cube(ModBlocks.PUZZLE_WALL)
// Blocks: Interactive (Gates)
simpleStateAndItem(ModBlocks.EXPERIENCE_GATE_CONTROLLER)
// Blocks: Interactive (Uncategorized)
simpleStateAndItem(ModBlocks.INFUSED_TNT)
simpleStateOnly(ModBlocks.IGNEOUS_PLATE)
// Blocks: Ores
cube(ModBlocks.END_POWDER_ORE)
cube(ModBlocks.ENDIUM_ORE)
cube(ModBlocks.IGNEOUS_ROCK_ORE)
// Blocks: Decorative (Trees)
simpleStateOnly(ModBlocks.WHITEBARK_SAPLING_AUTUMN_RED)
simpleStateOnly(ModBlocks.WHITEBARK_SAPLING_AUTUMN_BROWN)
simpleStateOnly(ModBlocks.WHITEBARK_SAPLING_AUTUMN_ORANGE)
simpleStateOnly(ModBlocks.WHITEBARK_SAPLING_AUTUMN_YELLOWGREEN)
simpleStateAndItem(ModBlocks.WHITEBARK_LEAVES_AUTUMN_RED)
simpleStateAndItem(ModBlocks.WHITEBARK_LEAVES_AUTUMN_BROWN)
simpleStateAndItem(ModBlocks.WHITEBARK_LEAVES_AUTUMN_ORANGE)
simpleStateAndItem(ModBlocks.WHITEBARK_LEAVES_AUTUMN_YELLOWGREEN)
simpleStateOnly(ModBlocks.POTTED_WHITEBARK_SAPLING_AUTUMN_RED)
simpleStateOnly(ModBlocks.POTTED_WHITEBARK_SAPLING_AUTUMN_BROWN)
simpleStateOnly(ModBlocks.POTTED_WHITEBARK_SAPLING_AUTUMN_ORANGE)
simpleStateOnly(ModBlocks.POTTED_WHITEBARK_SAPLING_AUTUMN_YELLOWGREEN)
// Blocks: Decorative (Plants)
simpleStateOnly(ModBlocks.DEATH_FLOWER_HEALED)
simpleStateOnly(ModBlocks.DEATH_FLOWER_WITHERED)
simpleStateOnly(ModBlocks.POTTED_DEATH_FLOWER_HEALED)
simpleStateOnly(ModBlocks.POTTED_DEATH_FLOWER_WITHERED)
// Blocks: Decorative (Uncategorized)
simpleStateOnly(ModBlocks.ANCIENT_COBWEB)
simpleStateOnly(ModBlocks.ENDERMAN_HEAD, Blocks.SOUL_SAND)
simpleStateOnly(ModBlocks.ENDERMAN_WALL_HEAD, Blocks.SOUL_SAND)
// Blocks: Spawners
simpleStateOnly(ModBlocks.SPAWNER_OBSIDIAN_TOWERS, Blocks.SPAWNER)
// Blocks: Portals
simpleStateOnly(ModBlocks.END_PORTAL_INNER, Blocks.END_PORTAL)
simpleStateAndItem(ModBlocks.END_PORTAL_FRAME)
simpleStateAndItem(ModBlocks.END_PORTAL_ACCEPTOR)
simpleStateOnly(ModBlocks.VOID_PORTAL_INNER, Blocks.END_PORTAL)
simpleStateAndItem(ModBlocks.VOID_PORTAL_FRAME)
simpleStateAndItem(ModBlocks.VOID_PORTAL_STORAGE)
simpleStateAndItem(ModBlocks.VOID_PORTAL_FRAME_CRAFTED)
simpleStateAndItem(ModBlocks.VOID_PORTAL_STORAGE_CRAFTED)
// Blocks: Energy
simpleStateAndItem(ModBlocks.CORRUPTED_ENERGY)
// Blocks: Tables
simpleStateAndItem(ModBlocks.TABLE_BASE_TIER_1)
simpleStateAndItem(ModBlocks.TABLE_BASE_TIER_2)
simpleStateAndItem(ModBlocks.TABLE_BASE_TIER_3)
simpleStateAndItem(ModBlocks.ACCUMULATION_TABLE_TIER_1)
simpleStateAndItem(ModBlocks.ACCUMULATION_TABLE_TIER_2)
simpleStateAndItem(ModBlocks.ACCUMULATION_TABLE_TIER_3)
simpleStateAndItem(ModBlocks.EXPERIENCE_TABLE_TIER_1)
simpleStateAndItem(ModBlocks.EXPERIENCE_TABLE_TIER_2)
simpleStateAndItem(ModBlocks.EXPERIENCE_TABLE_TIER_3)
simpleStateAndItem(ModBlocks.INFUSION_TABLE_TIER_1)
simpleStateAndItem(ModBlocks.INFUSION_TABLE_TIER_2)
simpleStateAndItem(ModBlocks.INFUSION_TABLE_TIER_3)
// Blocks: Utilities
simpleStateAndItem(ModBlocks.SCAFFOLDING)
}
}

View File

@@ -1,106 +1,166 @@
package chylex.hee.datagen.client
import chylex.hee.datagen.client.util.block
import chylex.hee.datagen.client.util.layers
import chylex.hee.datagen.client.util.multi
import chylex.hee.datagen.client.util.override
import chylex.hee.datagen.client.util.parent
import chylex.hee.datagen.client.util.simple
import chylex.hee.datagen.client.util.suffixed
import chylex.hee.datagen.r
import chylex.hee.datagen.then
import chylex.hee.game.Resource
import chylex.hee.game.Resource.location
import chylex.hee.game.block.IHeeBlock
import chylex.hee.game.item.IHeeItem
import chylex.hee.game.item.properties.ItemModel
import chylex.hee.game.item.properties.ItemModel.AsBlock
import chylex.hee.game.item.properties.ItemModel.Copy
import chylex.hee.game.item.properties.ItemModel.FromParent
import chylex.hee.game.item.properties.ItemModel.Layers
import chylex.hee.game.item.properties.ItemModel.Manual
import chylex.hee.game.item.properties.ItemModel.Multi
import chylex.hee.game.item.properties.ItemModel.Named
import chylex.hee.game.item.properties.ItemModel.Simple
import chylex.hee.game.item.properties.ItemModel.SingleItemModel
import chylex.hee.game.item.properties.ItemModel.Skull
import chylex.hee.game.item.properties.ItemModel.SpawnEgg
import chylex.hee.game.item.properties.ItemModel.Suffixed
import chylex.hee.game.item.properties.ItemModel.Wall
import chylex.hee.game.item.properties.ItemModel.WithOverrides
import chylex.hee.game.item.properties.ItemModel.WithTextures
import chylex.hee.init.ModBlocks
import chylex.hee.init.ModItems
import net.minecraft.block.Block
import chylex.hee.system.facades.Resource
import net.minecraft.data.DataGenerator
import net.minecraft.util.IItemProvider
import net.minecraftforge.client.model.generators.ItemModelBuilder
import net.minecraft.item.Items
import net.minecraftforge.client.model.generators.ItemModelProvider
import net.minecraftforge.common.data.ExistingFileHelper
class ItemModels(generator: DataGenerator, modid: String, existingFileHelper: ExistingFileHelper) : ItemModelProvider(generator, modid, existingFileHelper) {
override fun registerModels() {
for (item in ModItems.ALL) {
(item as? IHeeItem)?.let { registerModel(item, it.model) }
// Items: Raw Resources
simple(ModItems.ETHEREUM)
simple(ModItems.ANCIENT_DUST)
simple(ModItems.END_POWDER)
simple(ModItems.STARDUST)
simple(ModItems.ENDIUM_INGOT)
simple(ModItems.ENDIUM_NUGGET)
simple(ModItems.OBSIDIAN_FRAGMENT)
simple(ModItems.IGNEOUS_ROCK)
simple(ModItems.PUZZLE_MEDALLION)
simple(ModItems.INFERNIUM)
simple(ModItems.INFERNIUM_INGOT)
simple(ModItems.AURICION)
simple(ModItems.DRAGON_SCALE)
simple(ModItems.INSTABILITY_ORB)
simple(ModItems.ECTOPLASM)
simple(ModItems.ENCHANTED_CLAW)
// Items: Manufactured Resources
simple(ModItems.ALTERATION_NEXUS)
simple(ModItems.VOID_ESSENCE)
simple(ModItems.OBSIDIAN_ROD)
simple(ModItems.PURITY_EXTRACT)
simple(ModItems.STATIC_CORE)
simple(ModItems.TICKING_CORE)
simple(ModItems.DIRTY_INFERNIUM_INGOT)
simple(ModItems.AMELIOR)
simple(ModItems.REVITALIZATION_SUBSTANCE)
layers(ModItems.BINDING_ESSENCE, arrayOf("binding_essence_primary", "binding_essence_secondary", "binding_essence_tertiary", "binding_essence_quaternary"))
// Items: Nature & Food
simple(ModItems.COMPOST)
simple(ModItems.VOID_SALAD).then {
override(Resource.Custom("item/void_void_salad")) { predicate(Resource.Custom("void_salad_type"), 1F) }
override(Resource.Custom("item/mega_void_salad")) { predicate(Resource.Custom("void_salad_type"), 2F) }
}
for (block in ModBlocks.ALL) {
(block as? IHeeBlock)
?.let { it.model.generate(block).itemModel }
?.let { registerModel(if (it.asItem) block.asItem() else block, it.model) }
simple("void_void_salad")
simple("mega_void_salad")
// Items: Table Cores
simple(ModItems.ACCUMULATION_TABLE_CORE)
simple(ModItems.EXPERIENCE_TABLE_CORE)
simple(ModItems.INFUSION_TABLE_CORE)
// Items: Utilities
simple(ModItems.TABLE_LINK)
simple(ModItems.KNOWLEDGE_NOTE)
parent(ModItems.ENDERMAN_HEAD, Resource.Vanilla("item/template_skull"))
simple(ModItems.EXPERIENCE_BOTTLE, Items.EXPERIENCE_BOTTLE.r)
// Items: Tools
simple(ModItems.VOID_MINER)
simple(ModItems.VOID_BUCKET).then {
override(ModItems.VOID_BUCKET.r("_fluid_level_1")) { predicate(Resource.Custom("void_bucket_cooldown"), 0.01F) }
override(ModItems.VOID_BUCKET.r("_fluid_level_2")) { predicate(Resource.Custom("void_bucket_cooldown"), 0.3F) }
override(ModItems.VOID_BUCKET.r("_fluid_level_3")) { predicate(Resource.Custom("void_bucket_cooldown"), 0.5F) }
override(ModItems.VOID_BUCKET.r("_fluid_level_4")) { predicate(Resource.Custom("void_bucket_cooldown"), 0.7F) }
}
}
private fun registerModel(item: IItemProvider, model: ItemModel) {
registerModel(item, model) { it }
}
private fun registerModel(item: IItemProvider, model: ItemModel, callback: (ItemModelBuilder) -> ItemModelBuilder) {
when (model) {
is SingleItemModel -> registerSingleModel(item, model, callback)
is WithTextures -> registerModel(item, model.baseModel) {
model.textures.entries.fold(callback(it)) { builder, (name, location) -> builder.texture(name, location) }
}
is WithOverrides -> registerModel(item, model.baseModel) {
var builder = callback(it)
for ((property, valueMap) in model.overrides) {
for ((value, overrideModel) in valueMap) {
registerSingleModel(item, overrideModel)
builder = builder.override(overrideModel.getLocation(item.asItem())) {
predicate(property.name, value)
}
}
}
builder
}
is Multi -> {
for (innerModel in model.models) {
registerModel(item, innerModel, callback)
}
}
multi(ModItems.VOID_BUCKET, Resource.Vanilla("item/generated"), Array(4) { "_fluid_level_${it + 1}" }) {
texture("layer0", Resource.Custom("item/void_bucket"))
texture("layer1", Resource.Custom("item/$it"))
}
}
private fun registerSingleModel(item: IItemProvider, model: SingleItemModel) {
registerSingleModel(item, model) { it }
}
simple(ModItems.SCORCHING_PICKAXE)
simple(ModItems.SCORCHING_SHOVEL)
simple(ModItems.SCORCHING_AXE)
simple(ModItems.SCORCHING_SWORD)
simple(ModItems.FLINT_AND_INFERNIUM)
private fun registerSingleModel(item: IItemProvider, model: SingleItemModel, callback: (ItemModelBuilder) -> ItemModelBuilder) {
when (model) {
Manual -> return
Simple -> simple(item)?.then(callback)
AsBlock -> block(item as Block)?.then(callback)
Skull -> parent(item, Resource.Vanilla("item/template_skull"))?.then(callback)
SpawnEgg -> parent(item, Resource.Vanilla("item/template_spawn_egg"))?.then(callback)
Wall -> parent(item, item.suffixed("_inventory").location)?.then(callback)
is Copy -> simple(item, model.item.location)?.then(callback)
is Layers -> layers(item, model.layers)?.then(callback)
is Named -> simple(model.name)?.then(callback)
is FromParent -> parent(item, model.parent)?.then(callback)
is Suffixed -> registerModel(item.suffixed(model.suffix), model.wrapped, callback)
// Items: Fluids
simple(ModItems.ENDER_GOO_BUCKET)
simple(ModItems.PURIFIED_ENDER_GOO_BUCKET)
// Items: Energy
layers(ModItems.ENERGY_ORACLE, arrayOf("energy_oracle", "energy_oracle_indicator_inactive")).then {
override(ModItems.ENERGY_ORACLE.r("_active_mild")) { predicate(Resource.Custom("activity_intensity"), 0.5F) }
override(ModItems.ENERGY_ORACLE.r("_active_full")) { predicate(Resource.Custom("activity_intensity"), 1F) }
}
multi(ModItems.ENERGY_ORACLE, Resource.Vanilla("item/generated"), arrayOf("_active_mild", "_active_full")) {
texture("layer0", Resource.Custom("item/energy_oracle"))
texture("layer1", Resource.Custom("item/energy_oracle_indicator" + it.suffix))
}
simple(ModItems.ENERGY_RECEPTACLE).then {
override(ModItems.ENERGY_RECEPTACLE.r("_with_cluster")) { predicate(Resource.Custom("has_cluster"), 1F) }
}
layers(ModItems.ENERGY_RECEPTACLE.suffixed("_with_cluster"), arrayOf("energy_receptacle", "energy_receptacle_cluster"))
// Items: Gems & Teleportation
simple(ModItems.INFUSED_ENDER_PEARL, Items.ENDER_PEARL.r)
simple(ModItems.SPATIAL_DASH_GEM)
simple(ModItems.LINKING_GEM)
layers(ModItems.PORTAL_TOKEN, arrayOf("portal_token_outline", "portal_token_color_top", "portal_token_color_bottom")).then {
override(ModItems.PORTAL_TOKEN.r("_rare")) { predicate(Resource.Custom("token_type"), 1F) }
override(ModItems.PORTAL_TOKEN.r("_rare_corrupted")) { predicate(Resource.Custom("token_type"), 1.5F) }
override(ModItems.PORTAL_TOKEN.r("_solitary")) { predicate(Resource.Custom("token_type"), 2F) }
}
layers(ModItems.PORTAL_TOKEN.suffixed("_rare"), arrayOf("portal_token_outline", "portal_token_color_top", "portal_token_color_bottom", "portal_token_border_rare"))
layers(ModItems.PORTAL_TOKEN.suffixed("_rare_corrupted"), arrayOf("portal_token_outline", "portal_token_color_top", "portal_token_color_bottom", "portal_token_border_rare", "portal_token_corruption"))
layers(ModItems.PORTAL_TOKEN.suffixed("_solitary"), arrayOf("portal_token_outline", "portal_token_color_top", "portal_token_color_bottom", "portal_token_border_solitary"))
simple(ModItems.BLANK_TOKEN)
// Items: Trinkets
simple(ModItems.TRINKET_POUCH)
simple(ModItems.TOTEM_OF_UNDYING).then {
override(ModItems.TOTEM_OF_UNDYING.r("_shaking")) { predicate(Resource.Custom("is_shaking"), 1F) }
}
simple(ModItems.TOTEM_OF_UNDYING.suffixed("_shaking"))
simple(ModItems.AMULET_OF_RECOVERY)
simple(ModItems.AMULET_OF_RECOVERY.suffixed("_held"))
simple(ModItems.RING_OF_HUNGER)
simple(ModItems.RING_OF_PRESERVATION)
simple(ModItems.TALISMAN_OF_GRIEFING)
simple(ModItems.SCALE_OF_FREEFALL)
// Items: Spawn Eggs
parent(ModItems.SPAWN_ENDER_EYE, Resource.Vanilla("item/template_spawn_egg"))
parent(ModItems.SPAWN_ANGRY_ENDERMAN, Resource.Vanilla("item/template_spawn_egg"))
parent(ModItems.SPAWN_BLOBBY, Resource.Vanilla("item/template_spawn_egg"))
parent(ModItems.SPAWN_ENDERMITE_INSTABILITY, Resource.Vanilla("item/template_spawn_egg"))
parent(ModItems.SPAWN_SPIDERLING, Resource.Vanilla("item/template_spawn_egg"))
parent(ModItems.SPAWN_UNDREAD, Resource.Vanilla("item/template_spawn_egg"))
parent(ModItems.SPAWN_VAMPIRE_BAT, Resource.Vanilla("item/template_spawn_egg"))
}
}

View File

@@ -1,119 +0,0 @@
package chylex.hee.datagen.client
import chylex.hee.HEE
import chylex.hee.client.text.LocalizationStrategy
import chylex.hee.game.block.IHeeBlock
import chylex.hee.game.command.ClientCommandHandler
import chylex.hee.game.item.IHeeItem
import chylex.hee.game.item.infusion.Infusion
import chylex.hee.game.mechanics.energy.IClusterHealth.HealthOverride
import chylex.hee.game.mechanics.energy.IClusterHealth.HealthStatus
import chylex.hee.game.potion.IHeeEffect
import chylex.hee.game.territory.TerritoryType
import chylex.hee.init.ModBlocks
import chylex.hee.init.ModCommands
import chylex.hee.init.ModEffects
import chylex.hee.init.ModEntities
import chylex.hee.init.ModItems
import chylex.hee.init.ModLanguage
import chylex.hee.init.ModPotions
import chylex.hee.init.ModSounds
import chylex.hee.system.getRegistryEntries
import chylex.hee.system.path
import net.minecraft.data.DataGenerator
import net.minecraft.potion.Effect
import net.minecraft.potion.Potion
import net.minecraftforge.common.data.LanguageProvider
class LangEnglish(generator: DataGenerator, modid: String) : LanguageProvider(generator, modid, "en_us") {
private val addedKeys = mutableMapOf<String, String>()
override fun addTranslations() {
for (block in ModBlocks.ALL) {
if (block is IHeeBlock) {
block.localization.localize(block.translationKey.removePrefix("block.hee."))?.let { add(block, it) }
addAll(block.localizationExtra)
}
}
for (item in ModItems.ALL) {
if (item is IHeeItem) {
item.localization.localize(item.translationKey.removePrefix("item.hee.").removePrefix("block.hee."))?.let { add(item, it) }
addAll(item.localizationExtra)
}
}
for (fluid in ModBlocks.FLUIDS) {
add("fluid.hee." + fluid.registryName, fluid.localizedName)
}
for ((type, properties) in ModEntities.ALL) {
properties.localization.localize(type.translationKey.removePrefix("entity.hee."))?.let { add(type, it) }
}
for ((sound, localized) in ModSounds.SUBTITLES) {
add("subtitles.hee." + sound.name.path, localized)
}
for (effect in getRegistryEntries<Effect>(ModEffects)) {
if (effect is IHeeEffect) {
effect.localization.localize(effect.name.removePrefix("effect.hee."))?.let { add(effect, it) }
}
}
for (potion in getRegistryEntries<Potion>(ModPotions)) {
val name = potion.path
val localized = LocalizationStrategy.Default.localize(name)
add("item.minecraft.potion.effect.$name", "Potion of $localized")
add("item.minecraft.splash_potion.effect.$name", "Splash Potion of $localized")
add("item.minecraft.lingering_potion.effect.$name", "Lingering Potion of $localized")
add("item.minecraft.tipped_arrow.effect.$name", "Arrow of $localized")
}
for (territoryType in TerritoryType.ALL) {
add(territoryType.translationKey, LocalizationStrategy.Default.localize(territoryType.title))
}
for (infusion in Infusion.values()) {
add(infusion.translationKey, infusion.localizedName)
}
for (clusterHealth in listOf(*HealthStatus.values(), *HealthOverride.values())) {
add(clusterHealth.translationKey, clusterHealth.localizedName)
}
for (command in ModCommands.admin + ModCommands.debug) {
val name = command.name
add("commands.hee.$name.info", command.description)
for ((key, translation) in command.localization) {
add("commands.hee.$name.$key", translation)
}
}
for (command in ClientCommandHandler.all.values) {
val name = command.name
add("commands.hee.$name.info", command.description)
}
for ((key, localizedText) in ModLanguage.GENERIC) {
add(key, localizedText)
}
}
private fun addAll(map: Map<String, String>) {
for ((key, value) in map) {
add(key, value)
}
}
override fun add(key: String, value: String) {
val previous = addedKeys.put(key, value)
if (previous == null) {
super.add(key, value)
}
else if (value != previous) {
HEE.log.warn("[LangEnglish] Duplicate translation: $key -> $previous -> $value")
}
}
}

View File

@@ -1,12 +1,15 @@
package chylex.hee.datagen.client.util
import chylex.hee.datagen.Callback
import chylex.hee.datagen.path
import chylex.hee.datagen.r
import chylex.hee.datagen.safe
import chylex.hee.datagen.safeUnit
import chylex.hee.datagen.then
import chylex.hee.game.Resource
import chylex.hee.game.Resource.location
import chylex.hee.game.block.BlockAbstractTable
import chylex.hee.system.named
import chylex.hee.system.path
import chylex.hee.system.facades.Resource
import chylex.hee.system.forge.named
import chylex.hee.system.migration.BlockWall
import net.minecraft.block.AbstractBlock
import net.minecraft.block.Block
import net.minecraft.block.Blocks
@@ -26,22 +29,66 @@ fun BlockModelProvider.parent(block: Block, parent: ResourceLocation) = safe {
this.getBuilder(block.path).parent(getExistingFile(parent))
}
fun BlockModelProvider.simple(block: Block, parent: ResourceLocation, textureName: String, textureLocation: ResourceLocation = block.location): BlockModelBuilder? {
fun BlockModelProvider.simple(block: Block, parent: ResourceLocation, textureName: String, textureLocation: ResourceLocation = block.r): BlockModelBuilder? {
return this.parent(block, parent).then { texture(textureName, textureLocation) }
}
fun BlockModelProvider.cubeColumn(block: Block, side: ResourceLocation = block.location, end: ResourceLocation = block.location("_top")) = safe {
fun BlockModelProvider.cube(block: Block, texture: ResourceLocation = block.r): BlockModelBuilder? {
return this.simple(block, Resource.Vanilla("block/cube_all"), "all", texture)
}
fun BlockModelProvider.cross(block: Block, texture: ResourceLocation = block.r): BlockModelBuilder? {
return this.simple(block, Resource.Vanilla("block/cross"), "cross", texture)
}
fun BlockModelProvider.cubeColumn(block: Block, side: ResourceLocation = block.r, end: ResourceLocation = block.r("_top")) = safe {
return this.cubeColumn(block.path, side, end)
}
fun BlockModelProvider.cubeBottomTop(block: Block, side: ResourceLocation, bottom: ResourceLocation, top: ResourceLocation) = safe {
fun BlockModelProvider.cubeBottomTop(block: Block, side: ResourceLocation = block.r("_side"), bottom: ResourceLocation = block.r("_bottom"), top: ResourceLocation = block.r("_top")) = safe {
return this.cubeBottomTop(block.path, side, bottom, top)
}
fun BlockModelProvider.leaves(block: Block): BlockModelBuilder? {
return this.simple(block, Resource.Vanilla("block/leaves"), "all")
}
fun BlockModelProvider.particle(block: Block, particle: ResourceLocation) = safe {
this.getBuilder(block.path).texture("particle", particle)
}
fun BlockModelProvider.multi(block: Block, parent: ResourceLocation, suffixes: Array<String>, callback: BlockModelBuilder.(Callback<Block>) -> Unit) {
for(suffix in suffixes) {
val path = block.path + suffix
this.safeUnit {
this.getBuilder(path).parent(getExistingFile(parent)).callback(Callback(block, suffix, path))
}
}
}
fun BlockModelProvider.multi(block: Block, parent: ResourceLocation, suffixes: IntRange, callback: BlockModelBuilder.(Callback<Block>) -> Unit) {
multi(block, parent, Array(1 + suffixes.last - suffixes.first) { "_${suffixes.first + it}" }, callback)
}
fun BlockModelProvider.wall(block: BlockWall, texture: ResourceLocation) = safeUnit {
wallPost(block.path + "_post", texture)
wallSide(block.path + "_side", texture)
wallSideTall(block.path + "_side_tall", texture)
}
fun BlockModelProvider.cauldron(block: Block, water: ResourceLocation) = safeUnit {
getBuilder(block.path + "_level1").parent(getExistingFile(Resource.Vanilla("block/cauldron_level1"))).texture("water", water)
getBuilder(block.path + "_level2").parent(getExistingFile(Resource.Vanilla("block/cauldron_level2"))).texture("water", water)
getBuilder(block.path + "_level3").parent(getExistingFile(Resource.Vanilla("block/cauldron_level3"))).texture("water", water)
}
fun BlockModelProvider.flowerPot(potBlock: Block, plantBlock: Block) = safe {
this.getBuilder(potBlock.path)
.parent(getExistingFile(Resource.Vanilla("block/flower_pot_cross")))
.texture("plant", plantBlock.r)
}
fun BlockModelProvider.portalFrame(block: Block, side: ResourceLocation, top: ResourceLocation) = safe {
this.getBuilder(block.path)
.parent(getExistingFile(Resource.Custom("block/portal_frame")))

View File

@@ -1,57 +1,63 @@
package chylex.hee.datagen.client.util
import chylex.hee.datagen.r
import chylex.hee.datagen.safeUnit
import chylex.hee.game.Resource
import chylex.hee.game.Resource.location
import chylex.hee.game.block.util.CAULDRON_LEVEL
import chylex.hee.system.path
import chylex.hee.system.migration.BlockRotatedPillar
import chylex.hee.system.migration.BlockSlab
import chylex.hee.system.migration.BlockStairs
import net.minecraft.block.Block
import net.minecraft.block.RotatedPillarBlock
import net.minecraft.block.SlabBlock
import net.minecraft.block.StairsBlock
import net.minecraft.block.WallBlock
import net.minecraft.util.ResourceLocation
import net.minecraftforge.client.model.generators.BlockStateProvider
import net.minecraftforge.client.model.generators.ConfiguredModel
import net.minecraftforge.client.model.generators.ModelFile.UncheckedModelFile
private fun BlockStateProvider.simpleBlockItem(block: Block) {
this.simpleBlockItem(block, UncheckedModelFile(block.r))
}
fun BlockStateProvider.simpleStateOnly(block: Block, model: Block = block) = safeUnit {
this.simpleBlock(block, UncheckedModelFile(model.location))
this.simpleBlock(block, UncheckedModelFile(model.r))
}
fun BlockStateProvider.pillar(block: RotatedPillarBlock, model: Block = block) = safeUnit {
this.axisBlock(block, model.location)
fun BlockStateProvider.simpleStateAndItem(block: Block) = safeUnit {
this.simpleBlock(block, UncheckedModelFile(block.r))
this.simpleBlockItem(block)
}
fun BlockStateProvider.stairs(stairsBlock: StairsBlock, fullBlock: Block, side: ResourceLocation? = null) = safeUnit {
val texture = fullBlock.location
this.stairsBlock(stairsBlock, side ?: texture, texture, texture)
fun BlockStateProvider.cube(block: Block) = safeUnit {
this.simpleBlock(block)
this.simpleBlockItem(block)
}
fun BlockStateProvider.slab(slabBlock: SlabBlock, fullBlock: Block, side: ResourceLocation? = null) = safeUnit {
val texture = fullBlock.location
fun BlockStateProvider.cube(block: Block, model: Block) = safeUnit {
val modelFile = UncheckedModelFile(model.r)
this.simpleBlock(block, modelFile)
this.simpleBlockItem(block, modelFile)
}
fun BlockStateProvider.stairs(stairBlock: BlockStairs, fullBlock: Block, side: ResourceLocation? = null) = safeUnit {
val texture = fullBlock.r
this.stairsBlock(stairBlock, side ?: texture, texture, texture)
this.simpleBlockItem(stairBlock)
}
fun BlockStateProvider.slab(slabBlock: BlockSlab, fullBlock: Block, side: ResourceLocation? = null) = safeUnit {
val texture = fullBlock.r
this.slabBlock(slabBlock, texture, side ?: texture, texture, texture)
this.simpleBlockItem(slabBlock)
}
fun BlockStateProvider.wall(block: WallBlock, fullBlock: Block) = safeUnit {
val texture = fullBlock.location
this.wallBlock(block, texture)
models().simple(block.suffixed("_inventory"), Resource.Vanilla("block/wall_inventory"), "wall", texture)
}
fun BlockStateProvider.cauldron(block: Block, water: ResourceLocation) = safeUnit {
val models = models()
val level1 = models.getBuilder(block.path + "_level1").parent(models.getExistingFile(Resource.Vanilla("block/cauldron_level1"))).texture("water", water)
val level2 = models.getBuilder(block.path + "_level2").parent(models.getExistingFile(Resource.Vanilla("block/cauldron_level2"))).texture("water", water)
val level3 = models.getBuilder(block.path + "_level3").parent(models.getExistingFile(Resource.Vanilla("block/cauldron_level3"))).texture("water", water)
getVariantBuilder(block)
.partialState().with(CAULDRON_LEVEL, 0).addModels(ConfiguredModel(models.getExistingFile(Resource.Vanilla("block/cauldron"))))
.partialState().with(CAULDRON_LEVEL, 1).addModels(ConfiguredModel(level1))
.partialState().with(CAULDRON_LEVEL, 2).addModels(ConfiguredModel(level2))
.partialState().with(CAULDRON_LEVEL, 3).addModels(ConfiguredModel(level3))
}
fun BlockStateProvider.log(block: RotatedPillarBlock) = safeUnit {
fun BlockStateProvider.log(block: BlockRotatedPillar) = safeUnit {
this.logBlock(block)
this.simpleBlockItem(block)
}
fun BlockStateProvider.pillar(block: BlockRotatedPillar) = safeUnit {
this.axisBlock(block)
this.simpleBlockItem(block)
}
fun BlockStateProvider.pillar(block: BlockRotatedPillar, model: Block) = safeUnit {
val modelFile = UncheckedModelFile(model.r)
this.axisBlock(block, model.r)
this.simpleBlockItem(block, modelFile)
}

View File

@@ -1,11 +1,12 @@
package chylex.hee.datagen.client.util
import chylex.hee.datagen.Callback
import chylex.hee.datagen.path
import chylex.hee.datagen.r
import chylex.hee.datagen.safe
import chylex.hee.game.Resource
import chylex.hee.game.Resource.location
import chylex.hee.game.Resource.locationPrefix
import chylex.hee.system.named
import chylex.hee.system.path
import chylex.hee.datagen.safeUnit
import chylex.hee.system.facades.Resource
import chylex.hee.system.forge.named
import net.minecraft.block.Block
import net.minecraft.item.Item
import net.minecraft.util.IItemProvider
@@ -19,49 +20,59 @@ fun Item.suffixed(suffix: String): Item {
return Item(Item.Properties()) named this.path + suffix
}
fun IItemProvider.suffixed(suffix: String): IItemProvider = when (this) {
is Block -> this.suffixed(suffix)
is Item -> this.suffixed(suffix)
else -> throw IllegalArgumentException()
}
private val ItemModelProvider.generated
get() = getExistingFile(Resource.Vanilla("item/generated"))
private fun ItemModelProvider.build(item: IItemProvider): ItemModelBuilder {
return this.getBuilder(when (item) {
is Block -> item.path
is Item -> item.path
else -> throw IllegalArgumentException()
})
private fun IItemProvider.path() = when(this) {
is Block -> this.path
is Item -> this.path
else -> throw IllegalArgumentException()
}
fun ItemModelProvider.parent(item: IItemProvider, parent: ResourceLocation) = safe {
this.build(item).parent(getExistingFile(parent))
private fun ItemModelProvider.build(item: IItemProvider): ItemModelBuilder {
return this.getBuilder(item.path())
}
fun ItemModelProvider.parent(item: IItemProvider, parent: ResourceLocation, checkExistence: Boolean = true) = safe {
this.build(item).parent(if (checkExistence) getExistingFile(parent) else UncheckedModelFile(parent))
}
fun ItemModelProvider.simple(path: String, texture: String = "item/$path") = safe {
this.getBuilder(path).parent(generated).texture("layer0", texture)
}
fun ItemModelProvider.simple(item: IItemProvider, texture: ResourceLocation = item.location) = safe {
fun ItemModelProvider.simple(item: IItemProvider, texture: ResourceLocation = item.r) = safe {
this.build(item).parent(generated).texture("layer0", texture)
}
fun ItemModelProvider.layers(item: IItemProvider, layers: Array<out String>) = safe {
var builder = this.build(item).parent(generated)
fun ItemModelProvider.layers(item: Item, layers: Array<String>) = safe {
var builder = this.getBuilder(item.path).parent(generated)
for ((index, layer) in layers.withIndex()) {
builder = builder.texture("layer$index", Resource.Custom(item.locationPrefix + layer))
for((index, layer) in layers.withIndex()) {
builder = builder.texture("layer$index", Resource.Custom("item/$layer"))
}
builder
}
fun ItemModelProvider.block(block: Block, parent: Block = block) = safe {
this.getBuilder(block.path).parent(UncheckedModelFile(parent.location))
fun ItemModelProvider.multi(item: IItemProvider, parent: ResourceLocation, suffixes: Array<String>, callback: ItemModelBuilder.(Callback<IItemProvider>) -> Unit) {
for(suffix in suffixes) {
val path = item.path() + suffix
this.safeUnit {
this.getBuilder(path).parent(getExistingFile(parent)).callback(Callback(item, suffix, path))
}
}
}
inline fun ItemModelBuilder.override(model: ResourceLocation, callback: OverrideBuilder.() -> OverrideBuilder): ItemModelBuilder {
fun ItemModelProvider.multi(item: IItemProvider, parent: ResourceLocation, suffixes: IntRange, callback: ItemModelBuilder.(Callback<IItemProvider>) -> Unit) {
multi(item, parent, Array(1 + suffixes.last - suffixes.first) { "_${suffixes.first + it}" }, callback)
}
fun ItemModelProvider.block(block: Block, parent: Block = block) = safe {
this.getBuilder(block.path).parent(UncheckedModelFile(parent.r))
}
fun ItemModelBuilder.override(model: ResourceLocation, callback: OverrideBuilder.() -> OverrideBuilder): ItemModelBuilder? {
return this.override().model(UncheckedModelFile(model)).let(callback).end()
}

View File

@@ -1,42 +1,99 @@
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 net.minecraft.block.Block
import net.minecraft.block.FlowerPotBlock
import chylex.hee.init.ModItems
import net.minecraft.block.Blocks
import net.minecraft.data.DataGenerator
import net.minecraft.loot.LootTables
class BlockLootTables(generator: DataGenerator) : BlockLootTableProvider(generator) {
override val consumer = object : RegistrationConsumer() {
override fun addTables() {
for (block in ModBlocks.ALL) {
(block as? IHeeBlock)?.let { registerDrop(block, it.drop) }
}
}
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)
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)
when (drop) {
Nothing, Manual -> return
Self -> registerDropSelfLootTable(block)
NamedTile -> registerLootTable(block, withName)
FlowerPot -> registerFlowerPot(block as FlowerPotBlock)
is OneOf -> registerDropping(block, drop.item)
}
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)
}
}
}

View File

@@ -1,32 +1,46 @@
package chylex.hee.datagen.server
import chylex.hee.game.block.IHeeBlock
import chylex.hee.datagen.server.util.add
import chylex.hee.game.block.BlockWhitebarkSapling
import chylex.hee.init.ModBlocks
import chylex.hee.system.forge.getRegistryEntries
import chylex.hee.system.migration.BlockFlowerPot
import chylex.hee.system.migration.BlockLeaves
import chylex.hee.system.migration.BlockSlab
import chylex.hee.system.migration.BlockStairs
import chylex.hee.system.migration.BlockWall
import net.minecraft.block.Block
import net.minecraft.data.BlockTagsProvider
import net.minecraft.data.DataGenerator
import net.minecraft.tags.ITag.INamedTag
import net.minecraft.tags.BlockTags
import net.minecraftforge.common.Tags
import net.minecraftforge.common.data.ExistingFileHelper
class BlockTags(generator: DataGenerator, modId: String, existingFileHelper: ExistingFileHelper?) : BlockTagsProvider(generator, modId, existingFileHelper) {
private val registeredTags = mutableSetOf<INamedTag<Block>>()
val allRegisteredTags: Set<INamedTag<Block>>
get() = registeredTags
private val blocks = getRegistryEntries<Block>(ModBlocks)
override fun registerTags() {
for (block in ModBlocks.ALL) {
val tags = (block as? IHeeBlock)?.tags
if (!tags.isNullOrEmpty()) {
registerTags(block, tags)
}
}
}
getOrCreateBuilder(BlockTags.BAMBOO_PLANTABLE_ON).add(ModBlocks.HUMUS)
getOrCreateBuilder(BlockTags.FLOWER_POTS).add(blocks.filterIsInstance<BlockFlowerPot>())
getOrCreateBuilder(BlockTags.IMPERMEABLE).add(ModBlocks.INFUSED_GLASS)
getOrCreateBuilder(BlockTags.LEAVES).add(blocks.filterIsInstance<BlockLeaves>())
getOrCreateBuilder(BlockTags.LOGS).add(ModBlocks.WHITEBARK_LOG, ModBlocks.WHITEBARK)
getOrCreateBuilder(BlockTags.PORTALS).add(ModBlocks.END_PORTAL_INNER, ModBlocks.VOID_PORTAL_INNER)
getOrCreateBuilder(BlockTags.PLANKS).add(ModBlocks.WHITEBARK_PLANKS)
getOrCreateBuilder(BlockTags.SAPLINGS).add(blocks.filterIsInstance<BlockWhitebarkSapling>())
getOrCreateBuilder(BlockTags.SLABS).add(blocks.filterIsInstance<BlockSlab>())
getOrCreateBuilder(BlockTags.STAIRS).add(blocks.filterIsInstance<BlockStairs>())
getOrCreateBuilder(BlockTags.WALLS).add(blocks.filterIsInstance<BlockWall>())
getOrCreateBuilder(BlockTags.WOODEN_SLABS).add(ModBlocks.WHITEBARK_SLAB)
getOrCreateBuilder(BlockTags.WOODEN_STAIRS).add(ModBlocks.WHITEBARK_STAIRS)
private fun registerTags(block: Block, tags: List<INamedTag<Block>>) {
for (tag in tags) {
getOrCreateBuilder(tag).addItemEntry(block)
registeredTags.add(tag)
}
getOrCreateBuilder(Tags.Blocks.CHESTS).add(ModBlocks.DARK_CHEST)
getOrCreateBuilder(Tags.Blocks.END_STONES).add(ModBlocks.END_STONE_INFESTED, ModBlocks.END_STONE_BURNED, ModBlocks.END_STONE_ENCHANTED)
getOrCreateBuilder(Tags.Blocks.GLASS).add(ModBlocks.INFUSED_GLASS)
getOrCreateBuilder(Tags.Blocks.OBSIDIAN).add(ModBlocks.OBSIDIAN_FALLING)
getOrCreateBuilder(Tags.Blocks.OBSIDIAN).add(ModBlocks.OBSIDIAN_SMOOTH, ModBlocks.OBSIDIAN_CHISELED, ModBlocks.OBSIDIAN_PILLAR)
getOrCreateBuilder(Tags.Blocks.OBSIDIAN).add(ModBlocks.OBSIDIAN_SMOOTH_LIT, ModBlocks.OBSIDIAN_CHISELED_LIT, ModBlocks.OBSIDIAN_PILLAR_LIT)
getOrCreateBuilder(Tags.Blocks.ORES).add(ModBlocks.END_POWDER_ORE, ModBlocks.ENDIUM_ORE, ModBlocks.STARDUST_ORE, ModBlocks.IGNEOUS_ROCK_ORE)
getOrCreateBuilder(Tags.Blocks.STORAGE_BLOCKS).add(ModBlocks.ENDIUM_BLOCK)
}
}

View File

@@ -1,33 +1,38 @@
package chylex.hee.datagen.server
import chylex.hee.game.item.IHeeItem
import chylex.hee.init.ModItems
import net.minecraft.data.BlockTagsProvider
import net.minecraft.data.DataGenerator
import net.minecraft.data.ItemTagsProvider
import net.minecraft.item.Item
import net.minecraft.tags.ITag.INamedTag
import net.minecraft.tags.BlockTags
import net.minecraft.tags.ItemTags
import net.minecraftforge.common.Tags
import net.minecraftforge.common.data.ExistingFileHelper
class ItemTags(dataGenerator: DataGenerator, private val blockTags: BlockTags, modId: String, existingFileHelper: ExistingFileHelper?) : ItemTagsProvider(dataGenerator, blockTags, modId, existingFileHelper) {
class ItemTags(dataGenerator: DataGenerator, blockTagProvider: BlockTagsProvider, modId: String, existingFileHelper: ExistingFileHelper?) : ItemTagsProvider(dataGenerator, blockTagProvider, modId, existingFileHelper) {
override fun registerTags() {
val itemTags = ItemTags.getAllTags().associateBy { it.name }
copy(BlockTags.LEAVES, ItemTags.LEAVES)
copy(BlockTags.LOGS, ItemTags.LOGS)
copy(BlockTags.PLANKS, ItemTags.PLANKS)
copy(BlockTags.SAPLINGS, ItemTags.SAPLINGS)
copy(BlockTags.SLABS, ItemTags.SLABS)
copy(BlockTags.STAIRS, ItemTags.STAIRS)
copy(BlockTags.WALLS, ItemTags.WALLS)
copy(BlockTags.WOODEN_SLABS, ItemTags.WOODEN_SLABS)
copy(BlockTags.WOODEN_STAIRS, ItemTags.WOODEN_STAIRS)
for (blockTag in blockTags.allRegisteredTags) {
itemTags[blockTag.name]?.let { copy(blockTag, it) }
}
copy(Tags.Blocks.CHESTS, Tags.Items.CHESTS)
copy(Tags.Blocks.END_STONES, Tags.Items.END_STONES)
copy(Tags.Blocks.GLASS, Tags.Items.GLASS)
copy(Tags.Blocks.OBSIDIAN, Tags.Items.OBSIDIAN)
copy(Tags.Blocks.ORES, Tags.Items.ORES)
copy(Tags.Blocks.STORAGE_BLOCKS, Tags.Items.STORAGE_BLOCKS)
for (item in ModItems.ALL) {
val tags = (item as? IHeeItem)?.tags
if (!tags.isNullOrEmpty()) {
registerTags(item, tags)
}
}
}
private fun registerTags(item: Item, tags: List<INamedTag<Item>>) {
for (tag in tags) {
getOrCreateBuilder(tag).addItemEntry(item)
}
getOrCreateBuilder(Tags.Items.DUSTS).add(ModItems.ANCIENT_DUST, ModItems.END_POWDER, ModItems.STARDUST)
getOrCreateBuilder(Tags.Items.ENDER_PEARLS).add(ModItems.INFUSED_ENDER_PEARL)
getOrCreateBuilder(Tags.Items.HEADS).add(ModItems.ENDERMAN_HEAD)
getOrCreateBuilder(Tags.Items.INGOTS).add(ModItems.ENDIUM_INGOT, ModItems.INFERNIUM_INGOT, ModItems.DIRTY_INFERNIUM_INGOT)
getOrCreateBuilder(Tags.Items.NUGGETS).add(ModItems.ENDIUM_NUGGET)
getOrCreateBuilder(Tags.Items.RODS).add(ModItems.OBSIDIAN_ROD)
}
}

View File

@@ -1,5 +1,6 @@
package chylex.hee.datagen.server.util
import chylex.hee.system.migration.BlockFlowerPot
import com.mojang.datafixers.util.Pair
import net.minecraft.block.Block
import net.minecraft.data.DataGenerator
@@ -10,6 +11,7 @@ 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
@@ -31,12 +33,12 @@ abstract class BlockLootTableProvider(generator: DataGenerator) : LootTableProvi
protected abstract class RegistrationConsumer : BlockLootTables() {
private val lootTables = mutableMapOf<ResourceLocation, Builder>()
abstract override fun addTables()
override fun addTables() {}
final override fun accept(consumer: BiConsumer<ResourceLocation?, Builder?>) {
addTables()
for ((location, table) in lootTables) {
for((location, table) in lootTables) {
consumer.accept(location, table)
}
@@ -47,6 +49,22 @@ 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: BlockFlowerPot) {
registerFlowerPot(block)
}
protected companion object {
val withName = BlockLootTables::droppingWithName
}

View File

@@ -3,5 +3,5 @@ package chylex.hee.datagen.server.util
import net.minecraft.data.TagsProvider
fun <T> TagsProvider.Builder<T>.add(items: List<T>) {
items.forEach(this::addItemEntry)
items.forEach(this::add)
}

View File

@@ -1,7 +1,7 @@
{
"pack": {
"description": "Hardcore Ender Expansion 2 (Datagen)",
"pack_format": 6,
"_comment": ""
}
"pack": {
"description": "Hardcore Ender Expansion 2 (Datagen)",
"pack_format": 6,
"_comment": ""
}
}

View File

@@ -1,143 +0,0 @@
package chylex.hee.client
import chylex.hee.client.render.RenderStateBuilder
import chylex.hee.client.render.util.DF_ONE
import chylex.hee.client.render.util.DF_ZERO
import chylex.hee.client.render.util.SF_ONE_MINUS_SRC_ALPHA
import chylex.hee.client.render.util.SF_SRC_ALPHA
import chylex.hee.client.util.MC
import chylex.hee.game.item.util.nbtOrNull
import chylex.hee.game.world.util.floodFill
import chylex.hee.game.world.util.getBlock
import chylex.hee.game.world.util.getState
import chylex.hee.game.world.util.isAir
import chylex.hee.game.world.util.removeBlock
import chylex.hee.game.world.util.setState
import chylex.hee.util.nbt.hasKey
import net.minecraft.block.BlockState
import net.minecraft.client.renderer.vertex.DefaultVertexFormats
import net.minecraft.entity.player.PlayerEntity
import net.minecraft.item.BlockItem
import net.minecraft.item.Items
import net.minecraft.util.Direction
import net.minecraft.util.Direction.DOWN
import net.minecraft.util.Direction.EAST
import net.minecraft.util.Direction.NORTH
import net.minecraft.util.Direction.SOUTH
import net.minecraft.util.Direction.UP
import net.minecraft.util.Direction.WEST
import net.minecraft.util.Hand.MAIN_HAND
import net.minecraft.util.Hand.OFF_HAND
import net.minecraft.util.math.BlockPos
import net.minecraft.util.math.BlockRayTraceResult
import net.minecraft.util.math.shapes.ISelectionContext
import net.minecraft.world.IWorld
import net.minecraftforge.client.event.DrawHighlightEvent
import net.minecraftforge.event.entity.player.PlayerInteractEvent.LeftClickBlock
import net.minecraftforge.event.entity.player.PlayerInteractEvent.RightClickBlock
import net.minecraftforge.event.world.BlockEvent.BreakEvent
import net.minecraftforge.eventbus.api.SubscribeEvent
import org.lwjgl.opengl.GL11
object BuildStick {
private val RENDER_TYPE_LINE = with(RenderStateBuilder()) {
line(2.25)
blend(SF_SRC_ALPHA, DF_ONE, SF_ONE_MINUS_SRC_ALPHA, DF_ZERO)
layering(RenderStateBuilder.LAYERING_OFFSET_Z)
mask(RenderStateBuilder.MASK_COLOR)
buildType("hee:debug_line", DefaultVertexFormats.POSITION_COLOR, GL11.GL_LINES, bufferSize = 256)
}
private fun isHoldingBuildStick(player: PlayerEntity): Boolean {
val heldItem = player.getHeldItem(MAIN_HAND)
return heldItem.item === Items.STICK && heldItem.nbtOrNull.hasKey("HEE_BUILD")
}
private fun getBuildStickBlocks(world: IWorld, pos: BlockPos, state: BlockState, face: Direction): List<BlockPos> {
val floodFaces = when (face) {
UP, DOWN -> listOf(NORTH, SOUTH, EAST, WEST)
NORTH, SOUTH -> listOf(UP, DOWN, EAST, WEST)
EAST, WEST -> listOf(UP, DOWN, NORTH, SOUTH)
else -> emptyList()
}
val limit = 1000
val block = state.block
return pos.floodFill(floodFaces, limit) { it.getBlock(world) === block }.takeIf { it.size < limit }.orEmpty()
}
private var lastLeftClickHit: BlockRayTraceResult? = null
@SubscribeEvent
fun onLeftClickBlock(e: LeftClickBlock) {
val world = e.world
if (isHoldingBuildStick(e.player) && !world.isRemote) {
lastLeftClickHit = MC.instance.objectMouseOver as? BlockRayTraceResult
}
}
@SubscribeEvent
fun onBlockBreak(e: BreakEvent) {
val world = e.world
if (isHoldingBuildStick(e.player) && !world.isRemote) {
val hit = lastLeftClickHit ?: return
for (pos in getBuildStickBlocks(world, e.pos, e.state, hit.face)) {
pos.removeBlock(world)
}
}
}
@SubscribeEvent
fun onRightClickBlock(e: RightClickBlock) {
val world = e.world
val player = e.player
if (isHoldingBuildStick(player) && !world.isRemote) {
val state = e.pos.getState(world)
val face = e.face!!
val place = (player.getHeldItem(OFF_HAND).item as? BlockItem)?.block?.defaultState ?: state
for (pos in getBuildStickBlocks(world, e.pos, state, face)) {
val offset = pos.offset(face)
if (offset.isAir(world)) {
offset.setState(world, place)
}
}
}
}
@SubscribeEvent
fun onRenderOverlay(e: DrawHighlightEvent.HighlightBlock) {
val player = MC.player!!
if (isHoldingBuildStick(player)) {
val hit = MC.instance.objectMouseOver as? BlockRayTraceResult ?: return
val world = player.world
val center = hit.pos
val info = e.info
val matrix = e.matrix.last.matrix
val builder = e.buffers.getBuffer(RENDER_TYPE_LINE)
for (pos in getBuildStickBlocks(world, center, center.getState(world), hit.face)) {
val x = pos.x - info.projectedView.x
val y = pos.y - info.projectedView.y
val z = pos.z - info.projectedView.z
val shape = pos.getState(world).getShape(world, pos, ISelectionContext.forEntity(info.renderViewEntity))
shape.forEachEdge { x1, y1, z1, x2, y2, z2 ->
builder.pos(matrix, (x1 + x).toFloat(), (y1 + y).toFloat(), (z1 + z).toFloat()).color(1F, 1F, 1F, 1F).endVertex()
builder.pos(matrix, (x2 + x).toFloat(), (y2 + y).toFloat(), (z2 + z).toFloat()).color(1F, 1F, 1F, 1F).endVertex()
}
}
e.isCanceled = true
}
}
}

View File

@@ -1,42 +0,0 @@
package chylex.hee.client
import chylex.hee.client.util.MC
import chylex.hee.debug.benchmark.TerritoryGenerationBenchmarkScreen
import chylex.hee.util.color.RGB
import com.mojang.blaze3d.matrix.MatrixStack
import net.minecraft.client.gui.screen.Screen
import net.minecraft.client.gui.widget.button.Button
import net.minecraft.util.text.StringTextComponent
import net.minecraftforge.client.event.InputEvent.KeyInputEvent
import net.minecraftforge.eventbus.api.SubscribeEvent
import org.lwjgl.glfw.GLFW
object DebugMenu {
@SubscribeEvent
fun onKeyPressed(e: KeyInputEvent) {
if (e.action != GLFW.GLFW_RELEASE) {
return
}
if (e.key == GLFW.GLFW_KEY_F12) {
MC.instance.displayGuiScreen(DebugMenuScreen(MC.currentScreen))
}
}
private class DebugMenuScreen(private val parentScreen: Screen?) : Screen(StringTextComponent("HEE 2 Debug")) {
override fun init() {
addButton(Button(width / 2 - 100, 36, 200, 20, StringTextComponent("Territory Generation Benchmark")) { MC.instance.displayGuiScreen(TerritoryGenerationBenchmarkScreen(this)) })
addButton(Button(width / 2 - 100, height - 40, 200, 20, StringTextComponent("Close")) { closeScreen() })
}
override fun render(matrix: MatrixStack, mouseX: Int, mouseY: Int, partialTicks: Float) {
renderBackground(matrix)
drawCenteredString(matrix, font, title, width / 2, 15, RGB(255u).i)
super.render(matrix, mouseX, mouseY, partialTicks)
}
override fun closeScreen() {
MC.instance.displayGuiScreen(parentScreen)
}
}
}

View File

@@ -1,27 +0,0 @@
package chylex.hee.client
import chylex.hee.client.util.MC
import net.minecraftforge.client.event.InputEvent.KeyInputEvent
import net.minecraftforge.eventbus.api.SubscribeEvent
import org.lwjgl.glfw.GLFW
object GameModeToggle {
@SubscribeEvent
fun onKeyPressed(e: KeyInputEvent) {
if (e.action != GLFW.GLFW_PRESS) {
return
}
if (e.key == GLFW.GLFW_KEY_GRAVE_ACCENT) {
val player = MC.player ?: return
if (player.isCreative) {
val ctrl = (e.modifiers and GLFW.GLFW_MOD_CONTROL) != 0
player.sendChatMessage(if (ctrl) "/gamemode spectator" else "/gamemode survival")
}
else {
player.sendChatMessage("/gamemode creative")
}
}
}
}

View File

@@ -1,19 +0,0 @@
package chylex.hee.client
import chylex.hee.client.render.TerritoryRenderer
import chylex.hee.client.util.MC
import chylex.hee.game.world.isInEndDimension
import net.minecraftforge.client.event.RenderGameOverlayEvent
import net.minecraftforge.eventbus.api.SubscribeEvent
object TerritoryVoidDebug {
@SubscribeEvent
fun onRenderGameOverlayText(e: RenderGameOverlayEvent.Text) {
if (MC.settings.showDebugInfo && MC.player?.isInEndDimension == true) {
with(e.left) {
add("")
add("End Void Factor: ${"%.3f".format(TerritoryRenderer.currentVoidFactor)}")
}
}
}
}

View File

@@ -1,71 +0,0 @@
package chylex.hee.debug
import chylex.hee.HEE
import chylex.hee.client.BuildStick
import chylex.hee.client.DebugMenu
import chylex.hee.client.GameModeToggle
import chylex.hee.client.TerritoryVoidDebug
import chylex.hee.game.block.BlockScaffoldingDebug
import chylex.hee.game.command.client.CommandClientDebugToggles
import chylex.hee.game.command.client.CommandClientScaffolding
import chylex.hee.game.command.server.CommandServerInstability
import chylex.hee.game.command.server.CommandServerStructure
import chylex.hee.game.command.server.CommandServerTerritory
import chylex.hee.game.command.server.CommandServerTestWorld
import chylex.hee.system.IDebugModule
import chylex.hee.util.forge.Side
import chylex.hee.util.forge.Sided
import chylex.hee.util.forge.SubscribeAllEvents
import chylex.hee.util.forge.SubscribeEvent
import net.minecraftforge.client.event.GuiOpenEvent
import net.minecraftforge.common.MinecraftForge
import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus.MOD
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent
@SubscribeAllEvents(modid = HEE.ID, bus = MOD)
internal object Debug : IDebugModule {
init {
HEE.debug = true
HEE.debugModule = this
}
override val clientCommands
get() = listOf(
CommandClientScaffolding,
CommandClientDebugToggles
)
override val serverCommands
get() = listOf(
CommandServerInstability,
CommandServerStructure,
CommandServerTerritory,
CommandServerTestWorld
)
override val scaffoldingBlockBehavior
get() = BlockScaffoldingDebug
@SubscribeEvent
fun onClientSetup(@Suppress("UNUSED_PARAMETER") e: FMLClientSetupEvent) {
initializeClient()
}
@Sided(Side.CLIENT)
private fun initializeClient() {
if (HEE.debug) {
MinecraftForge.EVENT_BUS.register(DebugMenu)
MinecraftForge.EVENT_BUS.register(BuildStick)
MinecraftForge.EVENT_BUS.register(GameModeToggle)
MinecraftForge.EVENT_BUS.register(TerritoryVoidDebug)
MinecraftForge.EVENT_BUS.register(object : Any() {
@SubscribeEvent
fun onGuiOpen(@Suppress("UNUSED_PARAMETER") e: GuiOpenEvent) {
PowerShell.maximizeWindow()
MinecraftForge.EVENT_BUS.unregister(this)
}
})
}
}
}

View File

@@ -1,26 +0,0 @@
package chylex.hee.debug
import chylex.hee.game.Environment
import chylex.hee.util.forge.Side
import org.apache.commons.lang3.SystemUtils
import java.io.File
import java.lang.management.ManagementFactory
internal object PowerShell {
private fun canExecutePowershell(scriptName: String): Boolean {
return SystemUtils.IS_OS_WINDOWS && Environment.side == Side.CLIENT && File(scriptName).exists()
}
fun setClipboardContents(file: File) {
if (canExecutePowershell("filecopy.ps1")) {
ProcessBuilder("powershell.exe", "-ExecutionPolicy", "Unrestricted", "-Sta", "-File", "filecopy.ps1", file.absolutePath).start()
}
}
fun maximizeWindow() {
if (canExecutePowershell("maximize.ps1")) {
val pid = ManagementFactory.getRuntimeMXBean().name.split("@")[0]
ProcessBuilder("powershell.exe", "-ExecutionPolicy", "Unrestricted", "-File", "maximize.ps1", pid).start()
}
}
}

View File

@@ -1,80 +0,0 @@
package chylex.hee.debug.benchmark
import chylex.hee.HEE
import chylex.hee.client.util.MC
import chylex.hee.game.Environment
import chylex.hee.game.territory.TerritoryType
import chylex.hee.game.world.generation.structure.world.SegmentedWorld
import chylex.hee.util.color.RGB
import com.mojang.blaze3d.matrix.MatrixStack
import net.minecraft.client.gui.screen.Screen
import net.minecraft.client.gui.widget.button.Button
import net.minecraft.util.text.StringTextComponent
import net.minecraft.util.text.TranslationTextComponent
import net.minecraft.world.World
import java.util.Random
class TerritoryGenerationBenchmarkScreen(private val parentScreen: Screen) : Screen(StringTextComponent("Territory Generation Benchmark")) {
private val generated = mutableListOf<SegmentedWorld>()
override fun init() {
try {
Environment.getDimension(World.OVERWORLD)
} catch (e: NullPointerException) {
println("Must be in a world!")
closeScreen()
return
}
val x = width / 2 - 100
addButton(Button(x, 36, 200, 20, StringTextComponent("(All)")) { runAll() })
for ((index, territory) in TerritoryType.ALL.withIndex()) {
val y = 36 + (22 * (index + 1))
addButton(Button(x, y, 200, 20, TranslationTextComponent(territory.translationKey)) { runOnce(territory) })
}
addButton(Button(x, height - 40, 200, 20, StringTextComponent("Close")) { closeScreen() })
}
override fun render(matrix: MatrixStack, mouseX: Int, mouseY: Int, partialTicks: Float) {
renderBackground(matrix)
drawCenteredString(matrix, font, title, width / 2, 15, RGB(255u).i)
super.render(matrix, mouseX, mouseY, partialTicks)
}
override fun closeScreen() {
MC.instance.displayGuiScreen(parentScreen)
}
private fun runAll() {
generated.clear()
for (territory in TerritoryType.ALL) {
if (territory.gen === TerritoryType.Companion.GeneratorDummy) {
continue
}
for (seed in 0L until 5L) {
runImpl(territory, seed)
}
}
HEE.log.info("[TerritoryGenerationBenchmarkScreen] done!")
}
private fun runOnce(territory: TerritoryType) {
generated.clear()
runImpl(territory, 0L)
}
private fun runImpl(territory: TerritoryType, seed: Long) {
HEE.log.info("[TerritoryGenerationBenchmarkScreen] generating " + territory.name)
val timeStart = System.currentTimeMillis()
generated.add(territory.generate(Random(seed)).first)
val timeEnd = System.currentTimeMillis()
HEE.log.info("[TerritoryGenerationBenchmarkScreen] finished in ${timeEnd - timeStart} ms")
}
}

View File

@@ -1,102 +0,0 @@
package chylex.hee.game.block
import chylex.hee.debug.PowerShell
import chylex.hee.game.Environment
import chylex.hee.game.block.components.IPlayerUseBlockComponent
import chylex.hee.game.command.client.CommandClientScaffolding
import chylex.hee.game.world.generation.structure.file.StructureFile
import chylex.hee.game.world.generation.util.WorldToStructureWorldAdapter
import chylex.hee.game.world.util.getBlock
import chylex.hee.game.world.util.offsetUntilExcept
import chylex.hee.util.math.BoundingBox
import chylex.hee.util.math.Pos
import net.minecraft.block.BlockState
import net.minecraft.block.Blocks
import net.minecraft.entity.player.PlayerEntity
import net.minecraft.nbt.CompressedStreamTools
import net.minecraft.util.ActionResultType
import net.minecraft.util.ActionResultType.FAIL
import net.minecraft.util.ActionResultType.SUCCESS
import net.minecraft.util.Direction
import net.minecraft.util.Direction.DOWN
import net.minecraft.util.Direction.EAST
import net.minecraft.util.Direction.NORTH
import net.minecraft.util.Direction.SOUTH
import net.minecraft.util.Direction.UP
import net.minecraft.util.Direction.WEST
import net.minecraft.util.Hand
import net.minecraft.util.Util
import net.minecraft.util.math.BlockPos
import net.minecraft.util.text.StringTextComponent
import net.minecraft.util.text.TextFormatting
import net.minecraft.world.World
import java.nio.file.Files
object BlockScaffoldingDebug : IPlayerUseBlockComponent {
override fun use(state: BlockState, world: World, pos: BlockPos, player: PlayerEntity, hand: Hand): ActionResultType {
if (world.isRemote && player.isSneaking && !player.abilities.isFlying) {
val palette = CommandClientScaffolding.currentPalette
if (palette == null) {
player.sendMessage(StringTextComponent("No structure set."), Util.DUMMY_UUID)
return FAIL
}
val minPos = findMinPos(world, pos)?.let { findMinPos(world, it) } // double pass to find min from any side
val maxPos = minPos?.let { findMaxPos(world, it) }
if (minPos == null || maxPos == null) {
player.sendMessage(StringTextComponent("Could not find structure boundaries."), Util.DUMMY_UUID)
return FAIL
}
val box = BoundingBox(minPos, maxPos)
val serverWorld = Environment.getDimension(world.dimensionKey)
val (structureTag, missingMappings) = StructureFile.save(WorldToStructureWorldAdapter(serverWorld, serverWorld.rand, box.min), box.size, palette, state.block)
val structureFile = Files.createTempDirectory("HardcoreEnderExpansion_Structure_").resolve(CommandClientScaffolding.currentFile).toFile()
CompressedStreamTools.write(structureTag, structureFile)
PowerShell.setClipboardContents(structureFile)
if (missingMappings.isNotEmpty()) {
player.sendMessage(StringTextComponent("Missing mappings for states:"), Util.DUMMY_UUID)
for (missingMapping in missingMappings) {
player.sendMessage(StringTextComponent(" - ${TextFormatting.GRAY}$missingMapping"), Util.DUMMY_UUID)
}
}
player.sendMessage(StringTextComponent("Generated structure file of ${box.size}."), Util.DUMMY_UUID)
return SUCCESS
}
return FAIL
}
// Helpers
private fun find(world: World, pos: BlockPos?, direction: Direction): BlockPos? {
return pos?.offsetUntilExcept(direction, 0..255) { it.getBlock(world) === Blocks.AIR }
}
private fun findMinPos(world: World, pos: BlockPos): BlockPos? {
val bottomPos = find(world, pos, DOWN)
val y = bottomPos?.y
val x = find(world, bottomPos, WEST)?.x
val z = find(world, bottomPos, NORTH)?.z
return if (x == null || y == null || z == null) null else Pos(x, y, z)
}
private fun findMaxPos(world: World, pos: BlockPos): BlockPos? {
val topPos = find(world, pos, UP)
val y = topPos?.y
val x = find(world, topPos, EAST)?.x
val z = find(world, topPos, SOUTH)?.z
return if (x == null || y == null || z == null) null else Pos(x, y, z)
}
}

View File

@@ -1,7 +0,0 @@
{
"pack": {
"description": "Hardcore Ender Expansion 2 (Debug Library)",
"pack_format": 6,
"_comment": ""
}
}

View File

@@ -1,31 +0,0 @@
buildscript {
repositories {
mavenCentral()
maven { url = "https://files.minecraftforge.net/maven" }
}
dependencies {
classpath group: "net.minecraftforge.gradle", name: "ForgeGradle", version: forge_gradle_version, changing: true
classpath group: "org.jetbrains.kotlin", name: "kotlin-gradle-plugin", version: kotlin_version
}
}
apply plugin: "net.minecraftforge.gradle"
minecraft {
mappings channel: "snapshot", version: rootProject.mapping_version
setAccessTransformers(rootProject.access_transformers)
}
dependencies {
minecraft "net.minecraftforge:forge:" + mc_version + "-" + forge_version
implementation project(":util")
}
jar {
manifest {
attributes([
"FMLModType": "LIBRARY"
])
}
}

View File

@@ -1,88 +0,0 @@
package chylex.hee.client.text
sealed class LocalizationStrategy {
abstract fun localize(key: String): String?
object Default : LocalizationStrategy() {
private val nonCapitalizedWords = setOf("of", "and")
override fun localize(key: String): String {
return key.split('_').joinToString(" ") {
if (nonCapitalizedWords.contains(it)) it else it.replaceFirstChar(Char::titlecaseChar)
}
}
}
open class ReplaceWords(private val wrapped: LocalizationStrategy, private val toReplace: String, private val replacement: String?) : LocalizationStrategy() {
constructor(toReplace: String, replacement: String?) : this(Default, toReplace, replacement)
override fun localize(key: String): String? {
val localized = wrapped.localize(key) ?: return null
val words = localized.split(' ').toMutableList()
val toDelete = this.toReplace.split(' ')
for (index in words.indices) {
if (toDelete.withIndex().all { (offset, word) -> words[index + offset] == word }) {
words.subList(index, index + toDelete.size).clear()
replacement?.let { words.add(index, it) }
break
}
}
return words.joinToString(" ")
}
}
class DeleteWords(wrapped: LocalizationStrategy, toDelete: String) : ReplaceWords(wrapped, toDelete, null) {
constructor(toDelete: String) : this(Default, toDelete)
}
class Parenthesized(private val wrapped: LocalizationStrategy = Default, private val wordCount: Int, private val wordOffset: Int = 0, private val fromStart: Boolean = false) : LocalizationStrategy() {
override fun localize(key: String): String? {
val localized = wrapped.localize(key) ?: return null
val words = localized.split(' ').toMutableList()
val firstIndex = if (fromStart) wordOffset else words.size - wordOffset - wordCount
val lastIndex = firstIndex + wordCount - 1
if (firstIndex < 0 || lastIndex > words.lastIndex) {
return localized
}
words[firstIndex] = '(' + words[firstIndex]
words[lastIndex] = words[lastIndex] + ')'
return words.joinToString(" ")
}
}
class MoveToBeginning(private val wrapped: LocalizationStrategy = Default, private val wordCount: Int, private val wordOffset: Int = 0, private val fromStart: Boolean = false) : LocalizationStrategy() {
override fun localize(key: String): String? {
val localized = wrapped.localize(key) ?: return null
val words = localized.split(' ').toMutableList()
val firstIndex = if (fromStart) wordOffset else words.size - wordOffset - wordCount
if (firstIndex < 0 || firstIndex + wordCount > words.size) {
return localized
}
val subList = words.subList(firstIndex, firstIndex + wordCount)
val movedWords = subList.toList()
subList.clear()
words.addAll(0, movedWords)
return words.joinToString(" ")
}
}
class Custom(private val localized: String) : LocalizationStrategy() {
override fun localize(key: String): String {
return localized
}
}
object None : LocalizationStrategy() {
override fun localize(key: String): String? {
return null
}
}
}

View File

@@ -1,45 +0,0 @@
package chylex.hee.game
import chylex.hee.HEE
import chylex.hee.system.isVanilla
import chylex.hee.system.path
import net.minecraft.block.Block
import net.minecraft.item.Item
import net.minecraft.util.IItemProvider
import net.minecraft.util.ResourceLocation
object Resource {
const val NAMESPACE_VANILLA = "minecraft"
fun Vanilla(path: String) = ResourceLocation(NAMESPACE_VANILLA, path)
fun Custom(path: String) = ResourceLocation(HEE.ID, path)
fun isVanilla(location: ResourceLocation) = location.namespace == NAMESPACE_VANILLA
fun isCustom(location: ResourceLocation) = location.namespace == HEE.ID
operator fun invoke(path: String, isVanilla: Boolean): ResourceLocation {
return if (isVanilla) Vanilla(path) else Custom(path)
}
val IItemProvider.locationPrefix
get() = when (this) {
is Block -> "block/"
is Item -> "item/"
else -> throw IllegalArgumentException()
}
val IItemProvider.location
get() = when (this) {
is Block -> Resource(this.locationPrefix + this.path, this.isVanilla)
is Item -> Resource(this.locationPrefix + this.path, this.isVanilla)
else -> throw IllegalArgumentException()
}
fun IItemProvider.location(suffix: String): ResourceLocation {
return when (this) {
is Block -> Resource(this.locationPrefix + this.path + suffix, this.isVanilla)
is Item -> Resource(this.locationPrefix + this.path + suffix, this.isVanilla)
else -> throw IllegalArgumentException()
}
}
}

View File

@@ -1,11 +0,0 @@
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 { // TODO abstract
override val drop
get() = if (lootTable == LootTables.EMPTY) BlockDrop.Nothing else BlockDrop.Self
}

View File

@@ -1,5 +0,0 @@
package chylex.hee.game.block
import net.minecraft.block.Block
abstract class HeeBlock2(properties: Properties) : Block(properties), IHeeBlock

View File

@@ -1,229 +0,0 @@
package chylex.hee.game.block
import chylex.hee.game.block.builder.HeeBlockComponents
import chylex.hee.game.world.util.getBlock
import chylex.hee.util.forge.Side
import chylex.hee.util.forge.Sided
import chylex.hee.util.forge.asBool
import net.minecraft.block.Block
import net.minecraft.block.BlockRenderType
import net.minecraft.block.BlockState
import net.minecraft.client.util.ITooltipFlag
import net.minecraft.entity.Entity
import net.minecraft.entity.EntitySpawnPlacementRegistry.PlacementType
import net.minecraft.entity.EntityType
import net.minecraft.entity.LivingEntity
import net.minecraft.entity.player.PlayerEntity
import net.minecraft.item.BlockItemUseContext
import net.minecraft.item.ItemStack
import net.minecraft.loot.LootContext
import net.minecraft.state.StateContainer.Builder
import net.minecraft.tileentity.TileEntity
import net.minecraft.util.ActionResultType
import net.minecraft.util.Direction
import net.minecraft.util.Hand
import net.minecraft.util.Mirror
import net.minecraft.util.Rotation
import net.minecraft.util.math.BlockPos
import net.minecraft.util.math.BlockRayTraceResult
import net.minecraft.util.math.RayTraceResult
import net.minecraft.util.math.shapes.ISelectionContext
import net.minecraft.util.math.shapes.VoxelShape
import net.minecraft.util.text.ITextComponent
import net.minecraft.world.Explosion
import net.minecraft.world.IBlockReader
import net.minecraft.world.IWorld
import net.minecraft.world.IWorldReader
import net.minecraft.world.World
import net.minecraft.world.server.ServerWorld
import java.util.Random
abstract class HeeBlockWithComponents(properties: Properties, components: HeeBlockComponents) : HeeBlock2(properties) {
private companion object {
private val RAND = Random()
}
private val states = components.states.build()
private val name = components.name
private val tooltip = components.tooltip
private val shape = components.shape
private val renderType = components.renderType
private val ambientOcclusionValue = components.ambientOcclusionValue
private val clientEffects = components.clientEffects
private val drops = components.drops
private val harvestability = components.harvestability
private val experience = components.experience
private val flammability = components.flammability
private val entity = components.entity
private val placement = components.placement
private val onAdded = components.onAdded
private val onNeighborChanged = components.onNeighborChanged
private val setStateFromNeighbor = components.setStateFromNeighbor
private val scheduledTick = components.scheduledTick
private val randomTick = components.randomTick
private val playerUse = components.playerUse
private val onExploded = components.onExploded
private val onCreatureSpawning = components.onCreatureSpawning
private val collideWithEntity = components.collideWithEntity
private var isAir = components.isAir
init {
defaultState = states.applyDefaults(stateContainer.baseState)
}
abstract override fun fillStateContainer(builder: Builder<Block, BlockState>)
override fun rotate(state: BlockState, rotation: Rotation): BlockState {
return states.getRotatedState(state, rotation)
}
override fun mirror(state: BlockState, mirror: Mirror): BlockState {
return states.getMirroredState(state, mirror)
}
override fun getTranslationKey(): String {
return name?.translationKey ?: super.getTranslationKey()
}
@Sided(Side.CLIENT)
override fun addInformation(stack: ItemStack, world: IBlockReader?, lines: MutableList<ITextComponent>, flags: ITooltipFlag) {
tooltip?.add(lines, stack, flags.isAdvanced, world)
}
@Suppress("DEPRECATION")
override fun getShape(state: BlockState, worldIn: IBlockReader, pos: BlockPos, context: ISelectionContext): VoxelShape {
return shape?.getShape(state) ?: super.getShape(state, worldIn, pos, context)
}
@Suppress("DEPRECATION")
override fun getCollisionShape(state: BlockState, worldIn: IBlockReader, pos: BlockPos, context: ISelectionContext): VoxelShape {
return shape?.getCollisionShape(state) ?: super.getCollisionShape(state, worldIn, pos, context)
}
override fun getRaytraceShape(state: BlockState, worldIn: IBlockReader, pos: BlockPos): VoxelShape {
return super.getRaytraceShape(state, worldIn, pos)
}
@Suppress("DEPRECATION")
override fun getRenderType(state: BlockState): BlockRenderType {
return renderType ?: super.getRenderType(state)
}
@Sided(Side.CLIENT)
@Suppress("DEPRECATION")
override fun getAmbientOcclusionLightValue(state: BlockState, worldIn: IBlockReader, pos: BlockPos): Float {
return ambientOcclusionValue ?: super.getAmbientOcclusionLightValue(state, worldIn, pos)
}
@Sided(Side.CLIENT)
override fun animateTick(state: BlockState, world: World, pos: BlockPos, rand: Random) {
clientEffects?.randomTick(state, world, pos, rand)
}
@Suppress("DEPRECATION")
override fun getDrops(state: BlockState, context: LootContext.Builder): MutableList<ItemStack> {
return drops?.getDrops(state, context) ?: super.getDrops(state, context)
}
override fun getPickBlock(state: BlockState, target: RayTraceResult, world: IBlockReader, pos: BlockPos, player: PlayerEntity): ItemStack {
return drops?.getPickBlock(state, world, pos) ?: super.getPickBlock(state, target, world, pos, player)
}
override fun canHarvestBlock(state: BlockState, world: IBlockReader, pos: BlockPos, player: PlayerEntity): Boolean {
return harvestability?.canHarvest(player)?.asBool ?: super.canHarvestBlock(state, world, pos, player)
}
override fun getExpDrop(state: BlockState, world: IWorldReader, pos: BlockPos, fortune: Int, silktouch: Int): Int {
return experience?.getExperience((world as? World)?.rand ?: RAND) ?: 0
}
override fun getFlammability(state: BlockState, world: IBlockReader, pos: BlockPos, face: Direction): Int {
return flammability?.takeIfFlammable(state)?.flammability ?: 0
}
override fun getFireSpreadSpeed(state: BlockState, world: IBlockReader, pos: BlockPos, face: Direction): Int {
return flammability?.takeIfFlammable(state)?.fireSpread ?: 0
}
override fun hasTileEntity(state: BlockState): Boolean {
return entity != null
}
override fun createTileEntity(state: BlockState, world: IBlockReader): TileEntity? {
return entity?.create()
}
@Suppress("DEPRECATION")
override fun isValidPosition(state: BlockState, world: IWorldReader, pos: BlockPos): Boolean {
return placement?.isPositionValid(state, world, pos) ?: super.isValidPosition(state, world, pos)
}
override fun getStateForPlacement(context: BlockItemUseContext): BlockState? {
return placement?.getPlacedState(defaultState, context.world, context.pos, context) ?: super.getStateForPlacement(context)
}
override fun onBlockPlacedBy(world: World, pos: BlockPos, state: BlockState, placer: LivingEntity?, stack: ItemStack) {
placement?.onPlacedBy(state, world, pos, placer, stack)
}
override fun onBlockAdded(state: BlockState, world: World, pos: BlockPos, oldState: BlockState, isMoving: Boolean) {
onAdded?.onAdded(state, world, pos)
scheduledTick?.onAdded(state, world, pos, world.rand)
}
@Suppress("DEPRECATION")
override fun neighborChanged(state: BlockState, world: World, pos: BlockPos, neighborBlock: Block, neighborPos: BlockPos, isMoving: Boolean) {
super.neighborChanged(state, world, pos, neighborBlock, neighborPos, isMoving)
onNeighborChanged?.onNeighborChanged(state, world, pos, neighborBlock, neighborPos.getBlock(world), neighborPos)
}
@Suppress("DEPRECATION")
override fun updatePostPlacement(state: BlockState, neighborFacing: Direction, neighborState: BlockState, world: IWorld, currentPos: BlockPos, neighborPos: BlockPos): BlockState {
return setStateFromNeighbor?.getNewState(state, world, currentPos, neighborFacing, neighborPos) ?: super.updatePostPlacement(state, neighborFacing, neighborState, world, currentPos, neighborPos)
}
override fun tick(state: BlockState, world: ServerWorld, pos: BlockPos, rand: Random) {
scheduledTick?.onTick(state, world, pos, rand)
}
override fun randomTick(state: BlockState, world: ServerWorld, pos: BlockPos, rand: Random) {
randomTick?.onTick(state, world, pos, rand)
}
@Suppress("DEPRECATION")
override fun onBlockActivated(state: BlockState, world: World, pos: BlockPos, player: PlayerEntity, hand: Hand, hit: BlockRayTraceResult): ActionResultType {
return playerUse?.use(state, world, pos, player, hand) ?: super.onBlockActivated(state, world, pos, player, hand, hit)
}
override fun canDropFromExplosion(state: BlockState, world: IBlockReader, pos: BlockPos, explosion: Explosion): Boolean {
return onExploded?.canDrop(explosion) ?: super.canDropFromExplosion(state, world, pos, explosion)
}
override fun onBlockExploded(state: BlockState, world: World, pos: BlockPos, explosion: Explosion) {
onExploded?.onExploded(state, world, pos, explosion)
super.onBlockExploded(state, world, pos, explosion)
}
override fun canCreatureSpawn(state: BlockState, world: IBlockReader, pos: BlockPos, type: PlacementType?, entityType: EntityType<*>?): Boolean {
return onCreatureSpawning?.canSpawn(world, pos, type, entityType)?.asBool ?: super.canCreatureSpawn(state, world, pos, type, entityType)
}
override fun onEntityCollision(state: BlockState, world: World, pos: BlockPos, entity: Entity) {
collideWithEntity?.collide(state, world, pos, entity)
}
override fun isAir(state: BlockState, world: IBlockReader, pos: BlockPos): Boolean {
return isAir ?: super.isAir(state, world, pos)
}
override fun propagatesSkylightDown(state: BlockState, world: IBlockReader, pos: BlockPos): Boolean {
return isAir == true || super.propagatesSkylightDown(state, world, pos)
}
}

View File

@@ -1,45 +0,0 @@
package chylex.hee.game.block
import chylex.hee.client.text.LocalizationStrategy
import chylex.hee.game.block.builder.AbstractHeeBlockBuilder
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
import chylex.hee.game.block.properties.BlockTint
import chylex.hee.game.block.properties.IBlockStateModelSupplier
import net.minecraft.block.Block
import net.minecraft.tags.ITag.INamedTag
interface IHeeBlock {
val localization: LocalizationStrategy
get() = LocalizationStrategy.Default
val localizationExtra: Map<String, String>
get() = emptyMap()
val model: IBlockStateModelSupplier
get() = BlockModel.Cube
val renderLayer: BlockRenderLayer
get() = SOLID
val tint: BlockTint?
get() = null
val drop: BlockDrop
get() = BlockDrop.Self
val tags: List<INamedTag<Block>>
get() = emptyList()
class FromBuilder(builder: AbstractHeeBlockBuilder<*>) : IHeeBlock {
override val localization = builder.localization ?: super.localization
override val localizationExtra = builder.localizationExtra.toMap()
override val model = builder.model ?: super.model
override val renderLayer = builder.renderLayer ?: super.renderLayer
override val tint = builder.tint
override val drop = builder.drop ?: super.drop
override val tags = builder.tags.toList()
}
}

View File

@@ -1,149 +0,0 @@
package chylex.hee.game.block.builder
import chylex.hee.client.text.LocalizationStrategy
import chylex.hee.game.block.IHeeBlock
import chylex.hee.game.block.properties.BlockDrop
import chylex.hee.game.block.properties.BlockHardness
import chylex.hee.game.block.properties.BlockHarvestTool
import chylex.hee.game.block.properties.BlockRenderLayer
import chylex.hee.game.block.properties.BlockTint
import chylex.hee.game.block.properties.IBlockStateModelSupplier
import net.minecraft.block.AbstractBlock.IPositionPredicate
import net.minecraft.block.AbstractBlock.Properties
import net.minecraft.block.Block
import net.minecraft.block.SoundType
import net.minecraft.block.material.Material
import net.minecraft.block.material.MaterialColor
import net.minecraft.tags.ITag.INamedTag
abstract class AbstractHeeBlockBuilder<T : Block> {
private companion object {
private val DEFAULT_MATERIAL = Material.Builder(MaterialColor.AIR).build()
private fun always(value: Boolean): IPositionPredicate {
return IPositionPredicate { _, _, _ -> value }
}
}
var localization: LocalizationStrategy? = null
val localizationExtra = mutableMapOf<String, String>()
var model: IBlockStateModelSupplier? = null
var renderLayer: BlockRenderLayer? = null
var material: Material? = null
var color: MaterialColor? = null
var sound: SoundType? = null
var tint: BlockTint? = null
var light: Int? = null
var isSolid: Boolean? = null
var isOpaque: Boolean? = null
var suffocates: Boolean? = null
var blocksVision: Boolean? = null
var drop: BlockDrop? = null
var tool: BlockHarvestTool? = null
var hardness: BlockHardness? = null
private val lazyComponents = lazy(::HeeBlockComponents)
val components
get() = lazyComponents.value
val tags = mutableListOf<INamedTag<Block>>()
val interfaces = HeeBlockInterfaces()
fun includeFrom(source: AbstractHeeBlockBuilder<*>) {
source.localization?.let { this.localization = it }
this.localizationExtra.putAll(source.localizationExtra)
source.model?.let { this.model = it }
source.renderLayer?.let { this.renderLayer = it }
source.material?.let { this.material = it }
source.color?.let { this.color = it }
source.sound?.let { this.sound = it }
source.tint?.let { this.tint = it }
source.light?.let { this.light = it }
source.isSolid?.let { this.isSolid = it }
source.isOpaque?.let { this.isOpaque = it }
source.suffocates?.let { this.suffocates = it }
source.blocksVision?.let { this.blocksVision = it }
source.drop?.let { this.drop = it }
source.tool?.let { this.tool = it }
source.hardness?.let { this.hardness = it }
if (source.lazyComponents.isInitialized()) {
this.components.includeFrom(source.components)
}
this.tags.addAll(source.tags)
this.interfaces.includeFrom(source.interfaces)
}
protected val heeDelegate
get() = object : IHeeBlock {
override val localization = this@AbstractHeeBlockBuilder.localization ?: super.localization
override val localizationExtra = this@AbstractHeeBlockBuilder.localizationExtra.toMap()
override val model = this@AbstractHeeBlockBuilder.model ?: super.model
override val renderLayer = this@AbstractHeeBlockBuilder.renderLayer ?: super.renderLayer
override val tint = this@AbstractHeeBlockBuilder.tint
override val drop = this@AbstractHeeBlockBuilder.drop ?: super.drop
override val tags = this@AbstractHeeBlockBuilder.tags.toList()
}
private fun buildProperties(setup: ((Properties) -> Properties)?): Properties {
val material = material ?: DEFAULT_MATERIAL
val color = color ?: material.color
val tool = tool ?: BlockHarvestTool.NONE
var properties = Properties.create(material, color)
if (setup != null) {
properties = setup(properties)
}
properties = tool.applyTo(properties)
properties = properties.apply(sound, Properties::sound)
properties = properties.apply(light) { level -> setLightLevel { level } }
properties = properties.apply(isOpaque) { setOpaque(always(it)) }
properties = properties.apply(suffocates) { setSuffocates(always(it)) }
properties = properties.apply(blocksVision) { setBlocksVision(always(it)) }
properties = properties.apply(hardness) { it.applyTo(this) }
if (isSolid == false) {
properties = properties.notSolid()
}
if (!material.blocksMovement()) {
if (isSolid == true) {
throw UnsupportedOperationException("[AbstractHeeBlockBuilder] cannot create a block that does not block movement and is solid at the same time")
}
properties = properties.doesNotBlockMovement()
}
if (drop === BlockDrop.Nothing) {
properties = properties.noDrops()
}
if (lazyComponents.isInitialized() && components.randomTick != null) {
properties = properties.tickRandomly()
}
return properties
}
private inline fun <T> Properties.apply(value: T?, function: Properties.(T) -> Properties): Properties {
return if (value == null) this else function(value)
}
fun build(propertiesSetup: (Properties.() -> Properties)? = null): T {
val components = if (lazyComponents.isInitialized()) components else null
return buildBlock(buildProperties(propertiesSetup), components)
}
internal abstract fun buildBlock(properties: Properties, components: HeeBlockComponents?): T
}

View File

@@ -1,26 +0,0 @@
package chylex.hee.game.block.builder
import chylex.hee.game.block.HeeBlock2
import chylex.hee.game.block.HeeBlockWithComponents
import chylex.hee.game.block.IHeeBlock
import chylex.hee.game.block.interfaces.IBlockWithInterfaces
import net.minecraft.block.AbstractBlock.Properties
import net.minecraft.block.Block
import net.minecraft.block.BlockState
import net.minecraft.state.StateContainer.Builder
open class HeeBlockBuilder : AbstractHeeBlockBuilder<HeeBlock2>() {
override fun buildBlock(properties: Properties, components: HeeBlockComponents?): HeeBlock2 {
if (components != null) {
return object : HeeBlockWithComponents(properties, components), IHeeBlock by IHeeBlock.FromBuilder(this@HeeBlockBuilder), IBlockWithInterfaces by interfaces.delegate {
override fun fillStateContainer(builder: Builder<Block, BlockState>) {
components.states.fillContainer(builder)
}
}
}
return object : HeeBlock2(properties), IHeeBlock by IHeeBlock.FromBuilder(this), IBlockWithInterfaces by interfaces.delegate {}
}
}
inline fun HeeBlockBuilder(setup: HeeBlockBuilder.() -> Unit) = HeeBlockBuilder().apply(setup)

View File

@@ -1,86 +0,0 @@
package chylex.hee.game.block.builder
import chylex.hee.game.block.components.IBlockAddedComponent
import chylex.hee.game.block.components.IBlockClientEffectsComponent
import chylex.hee.game.block.components.IBlockCollideWithEntityComponent
import chylex.hee.game.block.components.IBlockDropsComponent
import chylex.hee.game.block.components.IBlockEntityComponent
import chylex.hee.game.block.components.IBlockExperienceComponent
import chylex.hee.game.block.components.IBlockExplodedComponent
import chylex.hee.game.block.components.IBlockHarvestabilityComponent
import chylex.hee.game.block.components.IBlockNameComponent
import chylex.hee.game.block.components.IBlockNeighborChanged
import chylex.hee.game.block.components.IBlockPlacementComponent
import chylex.hee.game.block.components.IBlockRandomTickComponent
import chylex.hee.game.block.components.IBlockScheduledTickComponent
import chylex.hee.game.block.components.IBlockShapeComponent
import chylex.hee.game.block.components.ICreatureSpawningOnBlockComponent
import chylex.hee.game.block.components.IFlammableBlockComponent
import chylex.hee.game.block.components.IPlayerUseBlockComponent
import chylex.hee.game.block.components.ISetBlockStateFromNeighbor
import chylex.hee.game.item.components.ITooltipComponent
import net.minecraft.block.BlockRenderType
class HeeBlockComponents {
val states = HeeBlockStates.Builder()
var name: IBlockNameComponent? = null
var tooltip: ITooltipComponent? = null
var shape: IBlockShapeComponent? = null
var renderType: BlockRenderType? = null
var ambientOcclusionValue: Float? = null
var clientEffects: IBlockClientEffectsComponent? = null
var drops: IBlockDropsComponent? = null
var harvestability: IBlockHarvestabilityComponent? = null
var experience: IBlockExperienceComponent? = null
var flammability: IFlammableBlockComponent? = null
var entity: IBlockEntityComponent? = null
var placement: IBlockPlacementComponent? = null
var onAdded: IBlockAddedComponent? = null
var onNeighborChanged: IBlockNeighborChanged? = null
var setStateFromNeighbor: ISetBlockStateFromNeighbor? = null
var scheduledTick: IBlockScheduledTickComponent? = null
var randomTick: IBlockRandomTickComponent? = null
var playerUse: IPlayerUseBlockComponent? = null
var onExploded: IBlockExplodedComponent? = null
var onCreatureSpawning: ICreatureSpawningOnBlockComponent? = null
var collideWithEntity: IBlockCollideWithEntityComponent? = null
var isAir: Boolean? = null
fun includeFrom(source: HeeBlockComponents) {
source.name?.let { this.name = it }
source.tooltip?.let { this.tooltip = it }
source.shape?.let { this.shape = it }
source.renderType?.let { this.renderType = it }
source.ambientOcclusionValue?.let { this.ambientOcclusionValue = it }
source.clientEffects?.let { this.clientEffects = it }
source.drops?.let { this.drops = it }
source.harvestability?.let { this.harvestability = it }
source.experience?.let { this.experience = it }
source.flammability?.let { this.flammability = it }
source.entity?.let { this.entity = it }
source.placement?.let { this.placement = it }
source.onAdded?.let { this.onAdded = it }
source.onNeighborChanged?.let { this.onNeighborChanged = it }
source.setStateFromNeighbor?.let { this.setStateFromNeighbor = it }
source.scheduledTick?.let { this.scheduledTick = it }
source.randomTick?.let { this.randomTick = it }
source.playerUse?.let { this.playerUse = it }
source.onExploded?.let { this.onExploded = it }
source.onCreatureSpawning?.let { this.onCreatureSpawning = it }
source.collideWithEntity?.let { this.collideWithEntity = it }
source.isAir?.let { this.isAir = it }
}
}

View File

@@ -1,23 +0,0 @@
package chylex.hee.game.block.builder
import chylex.hee.game.block.interfaces.BlockInterfaceContainer
import chylex.hee.game.block.interfaces.IBlockInterface
import chylex.hee.game.block.interfaces.NoBlockInterfaces
class HeeBlockInterfaces {
private val interfaces = mutableMapOf<Class<out IBlockInterface>, Any>()
internal val delegate
get() = if (interfaces.isEmpty())
NoBlockInterfaces
else
BlockInterfaceContainer(interfaces)
operator fun <T : IBlockInterface> set(type: Class<T>, impl: T) {
interfaces[type] = impl
}
fun includeFrom(source: HeeBlockInterfaces) {
this.interfaces.putAll(source.interfaces)
}
}

View File

@@ -1,50 +0,0 @@
package chylex.hee.game.block.builder
import chylex.hee.game.block.util.BlockStateGenerics
import net.minecraft.block.Block
import net.minecraft.block.BlockState
import net.minecraft.state.Property
import net.minecraft.state.StateContainer
import net.minecraft.util.Direction
import net.minecraft.util.Mirror
import net.minecraft.util.Rotation
class HeeBlockStates private constructor(private val statesWithDefaults: Map<Property<*>, Comparable<*>>, private val facingProperty: Property<Direction>?) {
fun applyDefaults(state: BlockState): BlockState {
if (statesWithDefaults.isEmpty()) {
return state
}
return statesWithDefaults.entries.fold(state) { acc, entry ->
BlockStateGenerics.withProperty(acc, entry.key, entry.value)
}
}
fun getRotatedState(state: BlockState, rotation: Rotation): BlockState {
return facingProperty?.let { state.with(it, rotation.rotate(state[it])) } ?: state
}
fun getMirroredState(state: BlockState, mirror: Mirror): BlockState {
return facingProperty?.let { state.with(it, mirror.mirror(state[it])) } ?: state
}
class Builder {
private val statesWithDefaults = mutableMapOf<Property<*>, Comparable<*>>()
var facingProperty: Property<Direction>? = null
fun <T : Comparable<T>> set(state: Property<T>, default: T) {
statesWithDefaults[state] = default
}
fun fillContainer(builder: StateContainer.Builder<Block, BlockState>) {
for (property in statesWithDefaults.keys) {
builder.add(property)
}
}
fun build(): HeeBlockStates {
return HeeBlockStates(statesWithDefaults.toMap(), facingProperty)
}
}
}

View File

@@ -1,9 +0,0 @@
package chylex.hee.game.block.components
import net.minecraft.block.BlockState
import net.minecraft.util.math.BlockPos
import net.minecraft.world.World
fun interface IBlockAddedComponent {
fun onAdded(state: BlockState, world: World, pos: BlockPos)
}

View File

@@ -1,10 +0,0 @@
package chylex.hee.game.block.components
import net.minecraft.block.BlockState
import net.minecraft.util.math.BlockPos
import net.minecraft.world.World
import java.util.Random
interface IBlockClientEffectsComponent {
fun randomTick(state: BlockState, world: World, pos: BlockPos, rand: Random) {}
}

View File

@@ -1,10 +0,0 @@
package chylex.hee.game.block.components
import net.minecraft.block.BlockState
import net.minecraft.entity.Entity
import net.minecraft.util.math.BlockPos
import net.minecraft.world.World
fun interface IBlockCollideWithEntityComponent {
fun collide(state: BlockState, world: World, pos: BlockPos, entity: Entity)
}

View File

@@ -1,15 +0,0 @@
package chylex.hee.game.block.components
import net.minecraft.block.BlockState
import net.minecraft.item.ItemStack
import net.minecraft.loot.LootContext
import net.minecraft.util.math.BlockPos
import net.minecraft.world.IBlockReader
interface IBlockDropsComponent {
fun getDrops(state: BlockState, context: LootContext.Builder): MutableList<ItemStack>
fun getPickBlock(state: BlockState, world: IBlockReader, pos: BlockPos): ItemStack? {
return null
}
}

View File

@@ -1,7 +0,0 @@
package chylex.hee.game.block.components
import net.minecraft.tileentity.TileEntity
fun interface IBlockEntityComponent {
fun create(): TileEntity
}

View File

@@ -1,7 +0,0 @@
package chylex.hee.game.block.components
import java.util.Random
fun interface IBlockExperienceComponent {
fun getExperience(rand: Random): Int
}

View File

@@ -1,11 +0,0 @@
package chylex.hee.game.block.components
import net.minecraft.block.BlockState
import net.minecraft.util.math.BlockPos
import net.minecraft.world.Explosion
import net.minecraft.world.World
interface IBlockExplodedComponent {
fun canDrop(explosion: Explosion): Boolean
fun onExploded(state: BlockState, world: World, pos: BlockPos, explosion: Explosion)
}

View File

@@ -1,8 +0,0 @@
package chylex.hee.game.block.components
import chylex.hee.util.forge.EventResult
import net.minecraft.entity.player.PlayerEntity
fun interface IBlockHarvestabilityComponent {
fun canHarvest(player: PlayerEntity): EventResult
}

View File

@@ -1,19 +0,0 @@
package chylex.hee.game.block.components
import net.minecraft.block.Block
interface IBlockNameComponent {
val translationKey: String
companion object {
fun of(translationKey: String) = object : IBlockNameComponent {
override val translationKey
get() = translationKey
}
fun of(block: Block) = object : IBlockNameComponent {
override val translationKey
get() = block.translationKey
}
}
}

View File

@@ -1,10 +0,0 @@
package chylex.hee.game.block.components
import net.minecraft.block.Block
import net.minecraft.block.BlockState
import net.minecraft.util.math.BlockPos
import net.minecraft.world.World
fun interface IBlockNeighborChanged {
fun onNeighborChanged(state: BlockState, world: World, pos: BlockPos, oldNeighborBlock: Block, newNeighborBlock: Block, neighborPos: BlockPos)
}

View File

@@ -1,21 +0,0 @@
package chylex.hee.game.block.components
import net.minecraft.block.BlockState
import net.minecraft.entity.LivingEntity
import net.minecraft.item.BlockItemUseContext
import net.minecraft.item.ItemStack
import net.minecraft.util.math.BlockPos
import net.minecraft.world.IWorldReader
import net.minecraft.world.World
interface IBlockPlacementComponent {
fun isPositionValid(state: BlockState, world: IWorldReader, pos: BlockPos): Boolean {
return true
}
fun getPlacedState(defaultState: BlockState, world: World, pos: BlockPos, context: BlockItemUseContext): BlockState {
return defaultState
}
fun onPlacedBy(state: BlockState, world: World, pos: BlockPos, placer: LivingEntity?, stack: ItemStack) {}
}

View File

@@ -1,10 +0,0 @@
package chylex.hee.game.block.components
import net.minecraft.block.BlockState
import net.minecraft.util.math.BlockPos
import net.minecraft.world.World
import java.util.Random
fun interface IBlockRandomTickComponent {
fun onTick(state: BlockState, world: World, pos: BlockPos, rand: Random)
}

View File

@@ -1,19 +0,0 @@
package chylex.hee.game.block.components
import chylex.hee.game.block.properties.TickSchedule
import net.minecraft.block.BlockState
import net.minecraft.util.math.BlockPos
import net.minecraft.world.World
import java.util.Random
interface IBlockScheduledTickComponent {
/**
* Return the amount of ticks before the first [onTick] call after the block is added to the world.
*/
fun onAdded(state: BlockState, world: World, pos: BlockPos, rand: Random): TickSchedule
/**
* Return the amount of ticks before the next [onTick] call.
*/
fun onTick(state: BlockState, world: World, pos: BlockPos, rand: Random): TickSchedule
}

View File

@@ -1,30 +0,0 @@
package chylex.hee.game.block.components
import chylex.hee.game.block.util.asVoxelShape
import net.minecraft.block.BlockState
import net.minecraft.util.math.AxisAlignedBB
import net.minecraft.util.math.shapes.VoxelShape
interface IBlockShapeComponent {
fun getShape(state: BlockState): VoxelShape
fun getCollisionShape(state: BlockState): VoxelShape? {
return null
}
fun getRaytraceShape(state: BlockState): VoxelShape? {
return null
}
companion object {
fun of(shape: VoxelShape) = object : IBlockShapeComponent {
override fun getShape(state: BlockState): VoxelShape {
return shape
}
}
fun of(aabb: AxisAlignedBB): IBlockShapeComponent {
return of(aabb.asVoxelShape)
}
}
}

View File

@@ -1,11 +0,0 @@
package chylex.hee.game.block.components
import chylex.hee.util.forge.EventResult
import net.minecraft.entity.EntitySpawnPlacementRegistry.PlacementType
import net.minecraft.entity.EntityType
import net.minecraft.util.math.BlockPos
import net.minecraft.world.IBlockReader
fun interface ICreatureSpawningOnBlockComponent {
fun canSpawn(world: IBlockReader, pos: BlockPos, placementType: PlacementType?, entityType: EntityType<*>?): EventResult
}

View File

@@ -1,20 +0,0 @@
package chylex.hee.game.block.components
import net.minecraft.block.BlockState
import net.minecraft.state.properties.BlockStateProperties
interface IFlammableBlockComponent {
val flammability: Int
val fireSpread: Int
fun takeIfFlammable(state: BlockState): IFlammableBlockComponent? {
return this.takeUnless { state.hasProperty(BlockStateProperties.WATERLOGGED) && state[BlockStateProperties.WATERLOGGED] }
}
companion object {
fun of(flammability: Int, fireSpread: Int) = object : IFlammableBlockComponent {
override val flammability = flammability
override val fireSpread = fireSpread
}
}
}

View File

@@ -1,12 +0,0 @@
package chylex.hee.game.block.components
import net.minecraft.block.BlockState
import net.minecraft.entity.player.PlayerEntity
import net.minecraft.util.ActionResultType
import net.minecraft.util.Hand
import net.minecraft.util.math.BlockPos
import net.minecraft.world.World
fun interface IPlayerUseBlockComponent {
fun use(state: BlockState, world: World, pos: BlockPos, player: PlayerEntity, hand: Hand): ActionResultType
}

View File

@@ -1,10 +0,0 @@
package chylex.hee.game.block.components
import net.minecraft.block.BlockState
import net.minecraft.util.Direction
import net.minecraft.util.math.BlockPos
import net.minecraft.world.IWorld
fun interface ISetBlockStateFromNeighbor {
fun getNewState(state: BlockState, world: IWorld, pos: BlockPos, neighborFacing: Direction, neighborPos: BlockPos): BlockState
}

View File

@@ -1,8 +0,0 @@
package chylex.hee.game.block.entity
import net.minecraft.block.Block
import net.minecraft.tileentity.TileEntity
interface IHeeTileEntityType<T : TileEntity> {
val blocks: Array<out Block>
}

View File

@@ -1,9 +0,0 @@
package chylex.hee.game.block.interfaces
internal class BlockInterfaceContainer(interfaces: Map<Class<out IBlockInterface>, Any>) : IBlockWithInterfaces {
private val interfaces = interfaces.toMap()
override fun getInterface(type: Class<out IBlockInterface>): Any? {
return interfaces[type]
}
}

View File

@@ -1,6 +0,0 @@
package chylex.hee.game.block.interfaces
/**
* Marks interfaces that can be attached to blocks.
*/
interface IBlockInterface

View File

@@ -1,15 +0,0 @@
package chylex.hee.game.block.interfaces
import net.minecraft.block.Block
interface IBlockWithInterfaces {
fun getInterface(type: Class<out IBlockInterface>): Any?
}
inline fun <reified T : IBlockInterface> IBlockWithInterfaces.getHeeInterface(): T? {
return this.getInterface(T::class.java) as? T
}
inline fun <reified T : IBlockInterface> Block.getHeeInterface(): T? {
return (this as? IBlockWithInterfaces)?.getHeeInterface()
}

Some files were not shown because too many files have changed in this diff Show More