Compare commits
15 Commits
Author | SHA1 | Date | |
---|---|---|---|
57fa9c4263 | |||
a4ce4504c6 | |||
332b3df632 | |||
f6c2ea900c | |||
af7aadc9ca | |||
f83d2c220f | |||
74801ef10b | |||
7f2f3692c3 | |||
0039e70591 | |||
2b6db5fabd | |||
4e0809c863 | |||
976ab95b3b | |||
138258d845 | |||
0003fc6c6b | |||
344ae127a9 |
11
README.md
11
README.md
@ -12,6 +12,11 @@ Put jsons with the same structure as
|
|||||||
src/main/resources/data/simple_creator/items/test_item.json
|
src/main/resources/data/simple_creator/items/test_item.json
|
||||||
src/main/resources/data/simple_creator/blocks/test_block.json
|
src/main/resources/data/simple_creator/blocks/test_block.json
|
||||||
```
|
```
|
||||||
in a (newly introduced) global datapack `(minecraft root)/datapacks`.
|
in a (newly introduced) global folder `(minecraft root)/simplyCreated`
|
||||||
This datapack needs a `pack.mcmeta`.
|
(automatically created on first startup).
|
||||||
After a restart, the so created items are available ingame.
|
If you set `enableTestThings: true`, example ones will be copied.
|
||||||
|
After a restart, the so created items are available ingame.
|
||||||
|
|
||||||
|
You will need to add a ton of metadata
|
||||||
|
(translations, correct tools, mining levels) via datapacks.
|
||||||
|
I recommend using a mod like https://modrinth.com/mod/globalpacks in addition
|
@ -1,21 +1,163 @@
|
|||||||
"material":
|
"itemGroup" ~ string
|
||||||
|
one of:
|
||||||
|
minecraft:building_blocks, minecraft:colored_blocks,
|
||||||
|
minecraft:natural_blocks, minecraft:functional_blocks,
|
||||||
|
minecraft:redstone_blocks, minecraft:hotbar, minecraft:search,
|
||||||
|
minecraft:tools_and_utilities, minecraft:combat,
|
||||||
|
minecraft:food_and_drinks, minecraft:ingredients, minecraft:spawn_eggs,
|
||||||
|
minecraft:op_blocks, minecraft:inventory
|
||||||
|
the creative inventory tab
|
||||||
|
|
||||||
//controls what happens when a piston pushes this block
|
"soundGroup" ~ string
|
||||||
|
one of:
|
||||||
|
intentionally_empty, wood, gravel, grass, lily_pad, stone,
|
||||||
|
metal, glass, wool, sand, snow, powder_snow, ladder, anvil,
|
||||||
|
slime, honey, wet_grass, coral, bamboo, bamboo_sapling,
|
||||||
|
scaffolding, sweet_berry_bush, crop, stem, vine, nether_wart,
|
||||||
|
lantern, nether_stem, nylium, fungus, roots, shroomlight,
|
||||||
|
weeping_vines, weeping_vines_low_pitch, soul_sand, soul_soil,
|
||||||
|
basalt, wart_block, netherrack, nether_bricks, nether_sprouts,
|
||||||
|
nether_ore, bone, netherite, ancient_debris, lodestone, chain,
|
||||||
|
nether_gold_ore, gilded_blackstone, candle, amethyst_block,
|
||||||
|
amethyst_cluster, small_amethyst_bud, medium_amethyst_bud,
|
||||||
|
large_amethyst_bud, tuff, tuff_bricks, polished_tuff, calcite,
|
||||||
|
dripstone_block, pointed_dripstone, copper, copper_bulb,
|
||||||
|
copper_grate, cave_vines, spore_blossom, azalea, flowering_azalea,
|
||||||
|
moss_carpet, pink_petals, moss_block, big_dripleaf,
|
||||||
|
small_dripleaf, rooted_dirt, hanging_roots, azalea_leaves,
|
||||||
|
sculk_sensor, sculk_catalyst, sculk, sculk_vein, sculk_shrieker,
|
||||||
|
glow_lichen, deepslate, deepslate_bricks, deepslate_tiles,
|
||||||
|
polished_deepslate, froglight, frogspawn, mangrove_roots,
|
||||||
|
muddy_mangrove_roots, mud, mud_bricks, packed_mud, hanging_sign,
|
||||||
|
nether_wood_hanging_sign, bamboo_wood_hanging_sign, bamboo_wood,
|
||||||
|
nether_wood, cherry_wood, cherry_sapling, cherry_leaves,
|
||||||
|
cherry_wood_hanging_sign, chiseled_bookshelf, suspicious_sand,
|
||||||
|
suspicious_gravel, decorated_pot, decorated_pot_shatter,
|
||||||
|
trial_spawner, sponge, wet_sponge, vault, heavy_core,
|
||||||
|
cobweb
|
||||||
|
changes how the block sounds
|
||||||
|
|
||||||
"blocksMovement" ~ boolean
|
"dropTableId" ~ string
|
||||||
//this sets whether water can flow away this block if "collidable" is false, otherwise subtily changes how fluids look around it
|
the id of the drop table to use e.g. "minecraft:blocks/diamond_ore"
|
||||||
|
what loot table is used for blockdrops when broken successfully
|
||||||
|
|
||||||
"collidable" ~ boolean
|
"collidable" ~ boolean
|
||||||
//this sets whether the block has collision. if false you (and monsters) can walk throught the block.
|
this sets whether the block has collision. if false you (and monsters) can walk throught the block.
|
||||||
|
|
||||||
|
"lightLevel" ~ int
|
||||||
|
0-15
|
||||||
|
how much light does the block produce
|
||||||
|
|
||||||
|
"explosionResistance" ~ float
|
||||||
|
0.0-3600000.0+
|
||||||
|
the resistance against explosions 6.0 is stone, 3600000.0 is bedrock, wood is usually 2.0 or 3.0
|
||||||
|
|
||||||
|
"hardness" ~ float
|
||||||
|
-1.0-50.0+
|
||||||
|
how hard it is to break the block. -1.0 is unbreakable, 50.0 is obsidian, 1.5 is stone, 2.0 cobble
|
||||||
|
|
||||||
|
"slipperiness" ~ float
|
||||||
|
|
||||||
|
"movementVelocityMultiplier" ~ float
|
||||||
|
|
||||||
|
"jumpVelocityMultiplier" ~ float
|
||||||
|
|
||||||
|
"opaque" ~ boolean
|
||||||
|
|
||||||
|
"allowsSpawning" ~ boolean
|
||||||
|
|
||||||
|
"solidBlock" ~ boolean
|
||||||
|
|
||||||
|
"suffocates" ~ boolean
|
||||||
|
|
||||||
|
"blockVision" ~ boolean
|
||||||
|
|
||||||
|
"postProcess" ~ boolean
|
||||||
|
|
||||||
|
"emissiveLighting" ~ boolean
|
||||||
|
whether the block texture is always rendered as if in bright light.
|
||||||
|
|
||||||
|
"modelOffset" ~ string
|
||||||
|
one of:
|
||||||
|
none, xz, xyz
|
||||||
|
slightly moves the model randomly. used e.g. for grass.
|
||||||
|
|
||||||
|
"pistonBehavior" ~ string
|
||||||
|
one of:
|
||||||
|
normal, destroy, block, ignore, push_only
|
||||||
|
controls what happens when a piston pushes this block
|
||||||
|
|
||||||
|
"instrument" ~ string
|
||||||
|
one of:
|
||||||
|
harp, basedrum, snare, hat, bass, flute, bell, guitar, chime,
|
||||||
|
xylophone, iron_xylophone, cow_bell, didgeridoo, bit, banjo,
|
||||||
|
pling, zombie, skeleton, creeper, dragon, wither_skeleton, piglin,
|
||||||
|
custom_head
|
||||||
|
|
||||||
"burnable" ~ boolean
|
"burnable" ~ boolean
|
||||||
//does lava ignite the block
|
does lava ignite the block
|
||||||
|
|
||||||
"burnChance" ~ int
|
"burnChance" ~ int
|
||||||
//how fast the block burns down (leaves 60, wood 5, flowers 100) if 0, block will never burn down.
|
how fast the block burns down (leaves 60, wood 5, flowers 100) if 0, block will never burn down.
|
||||||
|
|
||||||
"spreadChance" ~ int
|
"spreadChance" ~ int
|
||||||
//how easily this block catches fire ( wood 5, leaves 30, flowers 60) if null, block can only be ignited by lava if burnable.
|
how easily this block catches fire ( wood 5, leaves 30, flowers 60) if null, block can only be ignited by lava if burnable.
|
||||||
|
|
||||||
"breakByHand" ~ boolean
|
"replaceable" ~ boolean
|
||||||
//this sets whether the block drops when brocken without tool.
|
can be replaced like grass
|
||||||
|
|
||||||
|
"noBlockBreakParticles" ~ boolean
|
||||||
|
|
||||||
|
"requiresTool" ~ boolean
|
||||||
|
this sets whether the block drops when broken without tool.
|
||||||
|
|
||||||
|
"breaksInstantly" ~ boolean
|
||||||
|
|
||||||
|
"mapColor" ~ string
|
||||||
|
one of:
|
||||||
|
clear (0x000000), pale_green (0x7FB238), pale_yellow (0xF7E9A3),
|
||||||
|
white_gray (0xC7C7C7), bright_red (0xFF0000), pale_purple (0xA0A0FF),
|
||||||
|
iron_gray (0xA7A7A7), dark_green (0x007C00), white (0xFFFFFF),
|
||||||
|
light_blue_gray (0xA4A8B8), dirt_brown (0x976D4D),
|
||||||
|
stone_gray (0x707070), water_blue (0x4040FF), oak_tan (9402184),
|
||||||
|
off_white (0xFFFCF5), orange (14188339), magenta (11685080),
|
||||||
|
light_blue (6724056), YELLOW (0xE5E533), lime (0x7FCC19),
|
||||||
|
pink (0xF27FA5), gray (0x4C4C4C), light_gray (0x999999),
|
||||||
|
cyan (0x4C7F99), purple (0x7F3FB2), blue (0x334CB2),
|
||||||
|
brown (0x664C33), green (0x667F33), red (0x993333),
|
||||||
|
black (0x191919), gold (0xFAEE4D), diamond_blue (0x5CDBD5),
|
||||||
|
lapis_blue (0x4A80FF), emerald_green (0x00D93A),
|
||||||
|
spruce_brown (0x815631), dark_red (0x700200),
|
||||||
|
terracotta_white (0xD1B1A1), terracotta_orange (0x9F5224),
|
||||||
|
terracotta_magenta (0x95576C), terracotta_light_blue (0x706C8A),
|
||||||
|
terracotta_yellow (0xBA8524), terracotta_lime (0x677535),
|
||||||
|
terracotta_pink (0xA04D4E), terracotta_gray (0x392923),
|
||||||
|
terracotta_light_gray (0x876B62), TERRACOTTA_CYAN (0x575C5C),
|
||||||
|
terracotta_purple (0x7A4958), terracotta_blue (0x4C3E5C),
|
||||||
|
terracotta_brown (0x4C3223), terracotta_green (0x4C522A),
|
||||||
|
terracotta_red (0x8E3C2E), terracotta_black (0x251610),
|
||||||
|
dull_red (0xBD3031), dull_pink (0x943F61), dark_crimson (0x5C191D),
|
||||||
|
teal (0x167E86), dark_aqua (0x3A8E8C), dark_dull_pink (0x562C3E),
|
||||||
|
bright_teal (0x14B485), deepslate_gray (0x646464),
|
||||||
|
raw_iron_pink (0xD8AF93), lichen_green (0x7FA796)
|
||||||
|
|
||||||
|
"renderLayer" ~ string
|
||||||
|
one of:
|
||||||
|
solid, cutout_mipped, cutout, translucent,
|
||||||
|
translucent_moving_block, translucent_no_crumbling,
|
||||||
|
leash, water_mask, armor_glint, armor_entity_glint, glint_translucent,
|
||||||
|
glint, direct_glint, entity_glint, direct_entity_glint, text_background,
|
||||||
|
text_background_see_through, lightning, tripwire, end_portal,
|
||||||
|
end_gateway, lines, line_strip, debug_filled_box, debug_quads,
|
||||||
|
debug_section_quads, gui, gui_overlay, gui_text_highlight,
|
||||||
|
gui_ghost_recipe_overlay
|
||||||
|
different renderLayers allow different graphical effects.
|
||||||
|
Only the first 4 are interesting
|
||||||
|
solid = solid block no transparency
|
||||||
|
stone ...
|
||||||
|
cutout_mipped = 100% or no transparency, ?gets softened far away when mipmapping is enabled?
|
||||||
|
glass, leaves and similar
|
||||||
|
cutout = 100% or no transparency
|
||||||
|
flowers, saplings...
|
||||||
|
translucent = full alpha support
|
||||||
|
ice, stained glass, portal...
|
||||||
|
110
build.gradle
110
build.gradle
@ -1,85 +1,103 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id 'fabric-loom' version '0.2.6-SNAPSHOT'
|
id "com.modrinth.minotaur" version "2.+"
|
||||||
|
id 'fabric-loom' version '1.9-SNAPSHOT'
|
||||||
id 'maven-publish'
|
id 'maven-publish'
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
|
||||||
targetCompatibility = JavaVersion.VERSION_1_8
|
|
||||||
|
|
||||||
archivesBaseName = project.archives_base_name
|
|
||||||
version = project.mod_version
|
version = project.mod_version
|
||||||
group = project.maven_group
|
group = project.maven_group
|
||||||
|
|
||||||
minecraft {
|
base {
|
||||||
|
archivesName = project.archives_base_name
|
||||||
}
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
// Add repositories to retrieve artifacts from in here.
|
||||||
|
// You should only use this when depending on other mods because
|
||||||
|
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
|
||||||
|
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
|
||||||
|
// for more information about repositories.
|
||||||
|
maven {
|
||||||
|
url = "https://api.modrinth.com/maven"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
//to change the versions see the gradle.properties file
|
// To change the versions see the gradle.properties file
|
||||||
minecraft "com.mojang:minecraft:${project.minecraft_version}"
|
minecraft "com.mojang:minecraft:${project.minecraft_version}"
|
||||||
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
|
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
|
||||||
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
|
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
|
||||||
implementation 'com.google.code.findbugs:jsr305:3.0.2'
|
|
||||||
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_api_version}"
|
|
||||||
|
|
||||||
modCompile "me.sargunvohra.mcmods:autoconfig1u:2.0"
|
// Fabric API. This is technically optional, but you probably want it anyway.
|
||||||
include "me.sargunvohra.mcmods:autoconfig1u:2.0"
|
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
|
||||||
modApi "me.shedaniel.cloth:config-2:2.13.1"
|
|
||||||
include "me.shedaniel.cloth:config-2:2.13.1"
|
modImplementation "maven.modrinth:midnightlib:${project.midnightlib_version}"
|
||||||
modImplementation "io.github.prospector:modmenu:1.10.0+build.28"
|
include "maven.modrinth:midnightlib:${project.midnightlib_version}"
|
||||||
|
|
||||||
|
// modImplementation "net.fabricmc.fabric-api:fabric-api-deprecated:${project.fabric_version}"
|
||||||
|
}
|
||||||
|
|
||||||
|
configurations.include.transitive = true
|
||||||
|
configurations.include.dependencies.each {
|
||||||
|
if (!it.name.contains("bom") && !it.name.contains("fabric")) {
|
||||||
|
it.transitive = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
processResources {
|
processResources {
|
||||||
inputs.property "version", project.version
|
inputs.property "version", project.version
|
||||||
|
|
||||||
from(sourceSets.main.resources.srcDirs) {
|
filesMatching("fabric.mod.json") {
|
||||||
include "fabric.mod.json"
|
|
||||||
expand "version": project.version
|
expand "version": project.version
|
||||||
}
|
}
|
||||||
|
|
||||||
from(sourceSets.main.resources.srcDirs) {
|
|
||||||
exclude "fabric.mod.json"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ensure that the encoding is set to UTF-8, no matter what the system default is
|
tasks.withType(JavaCompile).configureEach {
|
||||||
// this fixes some edge cases with special characters not displaying correctly
|
it.options.release = 21
|
||||||
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
|
|
||||||
tasks.withType(JavaCompile) {
|
|
||||||
options.encoding = "UTF-8"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
|
java {
|
||||||
// if it is present.
|
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
|
||||||
// If you remove this task, sources will not be generated.
|
// if it is present.
|
||||||
task sourcesJar(type: Jar, dependsOn: classes) {
|
// If you remove this line, sources will not be generated.
|
||||||
classifier = "sources"
|
withSourcesJar()
|
||||||
from sourceSets.main.allSource
|
|
||||||
|
sourceCompatibility = JavaVersion.VERSION_21
|
||||||
|
targetCompatibility = JavaVersion.VERSION_21
|
||||||
}
|
}
|
||||||
|
|
||||||
jar {
|
jar {
|
||||||
from "LICENSE"
|
from("LICENSE") {
|
||||||
|
rename { "${it}_${project.archivesBaseName}"}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
import com.modrinth.minotaur.dependencies.DependencyType
|
||||||
|
import com.modrinth.minotaur.dependencies.ModDependency
|
||||||
|
|
||||||
|
modrinth {
|
||||||
|
projectId = 'vHsuCD0F' // The ID of your Modrinth project. Slugs will not work.
|
||||||
|
uploadFile = remapJar // Tells Minotaur to use the remapped jar
|
||||||
|
versionType = "alpha"
|
||||||
|
dependencies = [
|
||||||
|
new ModDependency('P7dR8mSH', DependencyType.REQUIRED), //required dependency on Fabric API
|
||||||
|
new ModDependency('codAaoxh', DependencyType.EMBEDDED), //embedded midnightlib
|
||||||
|
]
|
||||||
|
}
|
||||||
// configure the maven publication
|
// configure the maven publication
|
||||||
publishing {
|
publishing {
|
||||||
publications {
|
publications {
|
||||||
mavenJava(MavenPublication) {
|
mavenJava(MavenPublication) {
|
||||||
// add all the jars that should be included when publishing to maven
|
from components.java
|
||||||
artifact(jar) {
|
|
||||||
builtBy remapJar
|
|
||||||
}
|
|
||||||
artifact("${project.buildDir.absolutePath}/libs/${archivesBaseName}-${project.version}.jar"){
|
|
||||||
builtBy remapJar
|
|
||||||
}
|
|
||||||
artifact(sourcesJar) {
|
|
||||||
builtBy remapSourcesJar
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// select the repositories you want to publish to
|
// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
|
||||||
repositories {
|
repositories {
|
||||||
// uncomment to publish to the local maven
|
// Add repositories to publish to here.
|
||||||
// mavenLocal()
|
// Notice: This block does NOT have the same function as the block in the top level.
|
||||||
|
// The repositories here will be used for publishing your artifact, not for
|
||||||
|
// retrieving dependencies.
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,14 +1,16 @@
|
|||||||
org.gradle.jvmargs = -Xmx1G
|
org.gradle.jvmargs = -Xmx1G
|
||||||
|
|
||||||
#Fabric properties
|
#Fabric properties
|
||||||
minecraft_version = 1.15.2
|
minecraft_version=1.21.4
|
||||||
yarn_mappings = 1.15.2+build.15
|
yarn_mappings=1.21.4+build.7
|
||||||
loader_version = 0.8.2+build.194
|
loader_version=0.16.9
|
||||||
|
|
||||||
|
# Fabric API
|
||||||
|
fabric_version=0.114.0+1.21.4
|
||||||
|
|
||||||
#Mod properties
|
#Mod properties
|
||||||
mod_version = 0.8.0
|
mod_version = 0.10.3
|
||||||
maven_group = quimufu.simple_creator
|
maven_group = quimufu.simple_creator
|
||||||
archives_base_name = simple_creator
|
archives_base_name = simple_creator
|
||||||
|
|
||||||
#Dependencies
|
midnightlib_version=1.6.6-fabric
|
||||||
fabric_api_version = 0.5.12+build.296-1.15
|
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
4
gradle/wrapper/gradle-wrapper.properties
vendored
4
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,5 +1,7 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.5.1-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
|
||||||
|
networkTimeout=10000
|
||||||
|
validateDistributionUrl=true
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
298
gradlew
vendored
298
gradlew
vendored
@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env sh
|
#!/bin/sh
|
||||||
|
|
||||||
#
|
#
|
||||||
# Copyright 2015 the original author or authors.
|
# Copyright © 2015-2021 the original authors.
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
@ -15,80 +15,116 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
#
|
#
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
#
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
##
|
#
|
||||||
## Gradle start up script for UN*X
|
# Gradle start up script for POSIX generated by Gradle.
|
||||||
##
|
#
|
||||||
|
# Important for running:
|
||||||
|
#
|
||||||
|
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||||
|
# noncompliant, but you have some other compliant shell such as ksh or
|
||||||
|
# bash, then to run this script, type that shell name before the whole
|
||||||
|
# command line, like:
|
||||||
|
#
|
||||||
|
# ksh Gradle
|
||||||
|
#
|
||||||
|
# Busybox and similar reduced shells will NOT work, because this script
|
||||||
|
# requires all of these POSIX shell features:
|
||||||
|
# * functions;
|
||||||
|
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||||
|
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||||
|
# * compound commands having a testable exit status, especially «case»;
|
||||||
|
# * various built-in commands including «command», «set», and «ulimit».
|
||||||
|
#
|
||||||
|
# Important for patching:
|
||||||
|
#
|
||||||
|
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||||
|
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||||
|
#
|
||||||
|
# The "traditional" practice of packing multiple parameters into a
|
||||||
|
# space-separated string is a well documented source of bugs and security
|
||||||
|
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||||
|
# options in "$@", and eventually passing that to Java.
|
||||||
|
#
|
||||||
|
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||||
|
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||||
|
# see the in-line comments for details.
|
||||||
|
#
|
||||||
|
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||||
|
# Darwin, MinGW, and NonStop.
|
||||||
|
#
|
||||||
|
# (3) This script is generated from the Groovy template
|
||||||
|
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||||
|
# within the Gradle project.
|
||||||
|
#
|
||||||
|
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||||
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
# Attempt to set APP_HOME
|
# Attempt to set APP_HOME
|
||||||
|
|
||||||
# Resolve links: $0 may be a link
|
# Resolve links: $0 may be a link
|
||||||
PRG="$0"
|
app_path=$0
|
||||||
# Need this for relative symlinks.
|
|
||||||
while [ -h "$PRG" ] ; do
|
# Need this for daisy-chained symlinks.
|
||||||
ls=`ls -ld "$PRG"`
|
while
|
||||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||||
if expr "$link" : '/.*' > /dev/null; then
|
[ -h "$app_path" ]
|
||||||
PRG="$link"
|
do
|
||||||
else
|
ls=$( ls -ld "$app_path" )
|
||||||
PRG=`dirname "$PRG"`"/$link"
|
link=${ls#*' -> '}
|
||||||
fi
|
case $link in #(
|
||||||
|
/*) app_path=$link ;; #(
|
||||||
|
*) app_path=$APP_HOME$link ;;
|
||||||
|
esac
|
||||||
done
|
done
|
||||||
SAVED="`pwd`"
|
|
||||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
|
||||||
APP_HOME="`pwd -P`"
|
|
||||||
cd "$SAVED" >/dev/null
|
|
||||||
|
|
||||||
APP_NAME="Gradle"
|
# This is normally unused
|
||||||
APP_BASE_NAME=`basename "$0"`
|
# shellcheck disable=SC2034
|
||||||
|
APP_BASE_NAME=${0##*/}
|
||||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
|
||||||
|
' "$PWD" ) || exit
|
||||||
|
|
||||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
MAX_FD="maximum"
|
MAX_FD=maximum
|
||||||
|
|
||||||
warn () {
|
warn () {
|
||||||
echo "$*"
|
echo "$*"
|
||||||
}
|
} >&2
|
||||||
|
|
||||||
die () {
|
die () {
|
||||||
echo
|
echo
|
||||||
echo "$*"
|
echo "$*"
|
||||||
echo
|
echo
|
||||||
exit 1
|
exit 1
|
||||||
}
|
} >&2
|
||||||
|
|
||||||
# OS specific support (must be 'true' or 'false').
|
# OS specific support (must be 'true' or 'false').
|
||||||
cygwin=false
|
cygwin=false
|
||||||
msys=false
|
msys=false
|
||||||
darwin=false
|
darwin=false
|
||||||
nonstop=false
|
nonstop=false
|
||||||
case "`uname`" in
|
case "$( uname )" in #(
|
||||||
CYGWIN* )
|
CYGWIN* ) cygwin=true ;; #(
|
||||||
cygwin=true
|
Darwin* ) darwin=true ;; #(
|
||||||
;;
|
MSYS* | MINGW* ) msys=true ;; #(
|
||||||
Darwin* )
|
NONSTOP* ) nonstop=true ;;
|
||||||
darwin=true
|
|
||||||
;;
|
|
||||||
MINGW* )
|
|
||||||
msys=true
|
|
||||||
;;
|
|
||||||
NONSTOP* )
|
|
||||||
nonstop=true
|
|
||||||
;;
|
|
||||||
esac
|
esac
|
||||||
|
|
||||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||||
|
|
||||||
|
|
||||||
# Determine the Java command to use to start the JVM.
|
# Determine the Java command to use to start the JVM.
|
||||||
if [ -n "$JAVA_HOME" ] ; then
|
if [ -n "$JAVA_HOME" ] ; then
|
||||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||||
# IBM's JDK on AIX uses strange locations for the executables
|
# IBM's JDK on AIX uses strange locations for the executables
|
||||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||||
else
|
else
|
||||||
JAVACMD="$JAVA_HOME/bin/java"
|
JAVACMD=$JAVA_HOME/bin/java
|
||||||
fi
|
fi
|
||||||
if [ ! -x "$JAVACMD" ] ; then
|
if [ ! -x "$JAVACMD" ] ; then
|
||||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||||
@ -97,92 +133,120 @@ Please set the JAVA_HOME variable in your environment to match the
|
|||||||
location of your Java installation."
|
location of your Java installation."
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
JAVACMD="java"
|
JAVACMD=java
|
||||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
if ! command -v java >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
|
||||||
Please set the JAVA_HOME variable in your environment to match the
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
location of your Java installation."
|
location of your Java installation."
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Increase the maximum file descriptors if we can.
|
# Increase the maximum file descriptors if we can.
|
||||||
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||||
MAX_FD_LIMIT=`ulimit -H -n`
|
case $MAX_FD in #(
|
||||||
if [ $? -eq 0 ] ; then
|
max*)
|
||||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||||
MAX_FD="$MAX_FD_LIMIT"
|
# shellcheck disable=SC2039,SC3045
|
||||||
fi
|
MAX_FD=$( ulimit -H -n ) ||
|
||||||
ulimit -n $MAX_FD
|
warn "Could not query maximum file descriptor limit"
|
||||||
if [ $? -ne 0 ] ; then
|
esac
|
||||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
case $MAX_FD in #(
|
||||||
fi
|
'' | soft) :;; #(
|
||||||
else
|
*)
|
||||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||||
fi
|
# shellcheck disable=SC2039,SC3045
|
||||||
fi
|
ulimit -n "$MAX_FD" ||
|
||||||
|
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||||
# For Darwin, add options to specify how the application appears in the dock
|
|
||||||
if $darwin; then
|
|
||||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
|
||||||
fi
|
|
||||||
|
|
||||||
# For Cygwin, switch paths to Windows format before running java
|
|
||||||
if $cygwin ; then
|
|
||||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
|
||||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
|
||||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
|
||||||
|
|
||||||
# We build the pattern for arguments to be converted via cygpath
|
|
||||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
|
||||||
SEP=""
|
|
||||||
for dir in $ROOTDIRSRAW ; do
|
|
||||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
|
||||||
SEP="|"
|
|
||||||
done
|
|
||||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
|
||||||
# Add a user-defined pattern to the cygpath arguments
|
|
||||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
|
||||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
|
||||||
fi
|
|
||||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
|
||||||
i=0
|
|
||||||
for arg in "$@" ; do
|
|
||||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
|
||||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
|
||||||
|
|
||||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
|
||||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
|
||||||
else
|
|
||||||
eval `echo args$i`="\"$arg\""
|
|
||||||
fi
|
|
||||||
i=$((i+1))
|
|
||||||
done
|
|
||||||
case $i in
|
|
||||||
(0) set -- ;;
|
|
||||||
(1) set -- "$args0" ;;
|
|
||||||
(2) set -- "$args0" "$args1" ;;
|
|
||||||
(3) set -- "$args0" "$args1" "$args2" ;;
|
|
||||||
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
|
||||||
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
|
||||||
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
|
||||||
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
|
||||||
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
|
||||||
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Escape application args
|
# Collect all arguments for the java command, stacking in reverse order:
|
||||||
save () {
|
# * args from the command line
|
||||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
# * the main class name
|
||||||
echo " "
|
# * -classpath
|
||||||
}
|
# * -D...appname settings
|
||||||
APP_ARGS=$(save "$@")
|
# * --module-path (only if needed)
|
||||||
|
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||||
|
|
||||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
if "$cygwin" || "$msys" ; then
|
||||||
|
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||||
|
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||||
|
|
||||||
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
|
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||||
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
|
|
||||||
cd "$(dirname "$0")"
|
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||||
|
for arg do
|
||||||
|
if
|
||||||
|
case $arg in #(
|
||||||
|
-*) false ;; # don't mess with options #(
|
||||||
|
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||||
|
[ -e "$t" ] ;; #(
|
||||||
|
*) false ;;
|
||||||
|
esac
|
||||||
|
then
|
||||||
|
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||||
|
fi
|
||||||
|
# Roll the args list around exactly as many times as the number of
|
||||||
|
# args, so each arg winds up back in the position where it started, but
|
||||||
|
# possibly modified.
|
||||||
|
#
|
||||||
|
# NB: a `for` loop captures its iteration list before it begins, so
|
||||||
|
# changing the positional parameters here affects neither the number of
|
||||||
|
# iterations, nor the values presented in `arg`.
|
||||||
|
shift # remove old arg
|
||||||
|
set -- "$@" "$arg" # push replacement arg
|
||||||
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
|
|
||||||
|
# Collect all arguments for the java command:
|
||||||
|
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||||
|
# and any embedded shellness will be escaped.
|
||||||
|
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||||
|
# treated as '${Hostname}' itself on the command line.
|
||||||
|
|
||||||
|
set -- \
|
||||||
|
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||||
|
-classpath "$CLASSPATH" \
|
||||||
|
org.gradle.wrapper.GradleWrapperMain \
|
||||||
|
"$@"
|
||||||
|
|
||||||
|
# Stop when "xargs" is not available.
|
||||||
|
if ! command -v xargs >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
die "xargs is not available"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Use "xargs" to parse quoted args.
|
||||||
|
#
|
||||||
|
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||||
|
#
|
||||||
|
# In Bash we could simply go:
|
||||||
|
#
|
||||||
|
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||||
|
# set -- "${ARGS[@]}" "$@"
|
||||||
|
#
|
||||||
|
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||||
|
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||||
|
# character that might be a shell metacharacter, then use eval to reverse
|
||||||
|
# that process (while maintaining the separation between arguments), and wrap
|
||||||
|
# the whole thing up as a single "set" statement.
|
||||||
|
#
|
||||||
|
# This will of course break if any of these variables contains a newline or
|
||||||
|
# an unmatched quote.
|
||||||
|
#
|
||||||
|
|
||||||
|
eval "set -- $(
|
||||||
|
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||||
|
xargs -n1 |
|
||||||
|
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||||
|
tr '\n' ' '
|
||||||
|
)" '"$@"'
|
||||||
|
|
||||||
exec "$JAVACMD" "$@"
|
exec "$JAVACMD" "$@"
|
||||||
|
60
gradlew.bat
vendored
60
gradlew.bat
vendored
@ -13,8 +13,10 @@
|
|||||||
@rem See the License for the specific language governing permissions and
|
@rem See the License for the specific language governing permissions and
|
||||||
@rem limitations under the License.
|
@rem limitations under the License.
|
||||||
@rem
|
@rem
|
||||||
|
@rem SPDX-License-Identifier: Apache-2.0
|
||||||
|
@rem
|
||||||
|
|
||||||
@if "%DEBUG%" == "" @echo off
|
@if "%DEBUG%"=="" @echo off
|
||||||
@rem ##########################################################################
|
@rem ##########################################################################
|
||||||
@rem
|
@rem
|
||||||
@rem Gradle startup script for Windows
|
@rem Gradle startup script for Windows
|
||||||
@ -25,10 +27,14 @@
|
|||||||
if "%OS%"=="Windows_NT" setlocal
|
if "%OS%"=="Windows_NT" setlocal
|
||||||
|
|
||||||
set DIRNAME=%~dp0
|
set DIRNAME=%~dp0
|
||||||
if "%DIRNAME%" == "" set DIRNAME=.
|
if "%DIRNAME%"=="" set DIRNAME=.
|
||||||
|
@rem This is normally unused
|
||||||
set APP_BASE_NAME=%~n0
|
set APP_BASE_NAME=%~n0
|
||||||
set APP_HOME=%DIRNAME%
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
|
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||||
|
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||||
|
|
||||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||||
|
|
||||||
@ -37,13 +43,13 @@ if defined JAVA_HOME goto findJavaFromJavaHome
|
|||||||
|
|
||||||
set JAVA_EXE=java.exe
|
set JAVA_EXE=java.exe
|
||||||
%JAVA_EXE% -version >NUL 2>&1
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
if "%ERRORLEVEL%" == "0" goto init
|
if %ERRORLEVEL% equ 0 goto execute
|
||||||
|
|
||||||
echo.
|
echo. 1>&2
|
||||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
|
||||||
echo.
|
echo. 1>&2
|
||||||
echo Please set the JAVA_HOME variable in your environment to match the
|
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||||
echo location of your Java installation.
|
echo location of your Java installation. 1>&2
|
||||||
|
|
||||||
goto fail
|
goto fail
|
||||||
|
|
||||||
@ -51,48 +57,36 @@ goto fail
|
|||||||
set JAVA_HOME=%JAVA_HOME:"=%
|
set JAVA_HOME=%JAVA_HOME:"=%
|
||||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||||
|
|
||||||
if exist "%JAVA_EXE%" goto init
|
if exist "%JAVA_EXE%" goto execute
|
||||||
|
|
||||||
echo.
|
echo. 1>&2
|
||||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
|
||||||
echo.
|
echo. 1>&2
|
||||||
echo Please set the JAVA_HOME variable in your environment to match the
|
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||||
echo location of your Java installation.
|
echo location of your Java installation. 1>&2
|
||||||
|
|
||||||
goto fail
|
goto fail
|
||||||
|
|
||||||
:init
|
|
||||||
@rem Get command-line arguments, handling Windows variants
|
|
||||||
|
|
||||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
|
||||||
|
|
||||||
:win9xME_args
|
|
||||||
@rem Slurp the command line arguments.
|
|
||||||
set CMD_LINE_ARGS=
|
|
||||||
set _SKIP=2
|
|
||||||
|
|
||||||
:win9xME_args_slurp
|
|
||||||
if "x%~1" == "x" goto execute
|
|
||||||
|
|
||||||
set CMD_LINE_ARGS=%*
|
|
||||||
|
|
||||||
:execute
|
:execute
|
||||||
@rem Setup the command line
|
@rem Setup the command line
|
||||||
|
|
||||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||||
|
|
||||||
|
|
||||||
@rem Execute Gradle
|
@rem Execute Gradle
|
||||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||||
|
|
||||||
:end
|
:end
|
||||||
@rem End local scope for the variables with windows NT shell
|
@rem End local scope for the variables with windows NT shell
|
||||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||||
|
|
||||||
:fail
|
:fail
|
||||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||||
rem the _cmd.exe /c_ return code!
|
rem the _cmd.exe /c_ return code!
|
||||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
set EXIT_CODE=%ERRORLEVEL%
|
||||||
exit /b 1
|
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||||
|
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||||
|
exit /b %EXIT_CODE%
|
||||||
|
|
||||||
:mainEnd
|
:mainEnd
|
||||||
if "%OS%"=="Windows_NT" endlocal
|
if "%OS%"=="Windows_NT" endlocal
|
||||||
|
@ -1,462 +0,0 @@
|
|||||||
Some materials have certain effects, apart from their properties.
|
|
||||||
They have effect on how noteblocks sound when the block is below:
|
|
||||||
material -> soundtype
|
|
||||||
---------------------
|
|
||||||
stone -> basedrum
|
|
||||||
sand -> snare
|
|
||||||
glass -> hat
|
|
||||||
wood -> bass
|
|
||||||
others -> harp
|
|
||||||
The "water" material should cause crashes (or at least errors in connection with the frostwalker enchantment. (untested)
|
|
||||||
Some materials prevent the block being broken by water, even if the other conditions are met:
|
|
||||||
portal
|
|
||||||
structure_void
|
|
||||||
underwater_plant
|
|
||||||
seagrass
|
|
||||||
The "ice" material negates the stronger downward flow next to solid blocks. i.e. for waterfalls: block ~ air
|
|
||||||
Some materials are broken faster by sword. This can also be achieved via tag "leaves".
|
|
||||||
plant
|
|
||||||
replaceable_plant
|
|
||||||
unused_plant
|
|
||||||
pumpkin
|
|
||||||
Some materials let the block when mined with an axe be broken faster:
|
|
||||||
wood
|
|
||||||
plant
|
|
||||||
replaceable_plant
|
|
||||||
bamboo
|
|
||||||
Some materials let the block when mined with an Pickaxe be broken faster and drop loot:
|
|
||||||
metal
|
|
||||||
anvil
|
|
||||||
stone
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All materials with their settings:
|
|
||||||
"air"
|
|
||||||
pistonBehavior: "normal"
|
|
||||||
blocksMovement: false
|
|
||||||
burnable: false
|
|
||||||
breakByHand: true
|
|
||||||
liquid: false
|
|
||||||
replaceable: true
|
|
||||||
solid: false
|
|
||||||
blocksLight: false
|
|
||||||
|
|
||||||
"structure_void"
|
|
||||||
pistonBehavior: "normal"
|
|
||||||
blocksMovement: false
|
|
||||||
burnable: false
|
|
||||||
breakByHand: true
|
|
||||||
liquid: false
|
|
||||||
replaceable: true
|
|
||||||
solid: false
|
|
||||||
blocksLight: false
|
|
||||||
|
|
||||||
"portal"
|
|
||||||
pistonBehavior: "block"
|
|
||||||
blocksMovement: false
|
|
||||||
burnable: false
|
|
||||||
breakByHand: true
|
|
||||||
liquid: false
|
|
||||||
replaceable: false
|
|
||||||
solid: false
|
|
||||||
blocksLight: false
|
|
||||||
|
|
||||||
"carpet"
|
|
||||||
pistonBehavior: "normal"
|
|
||||||
blocksMovement: false
|
|
||||||
burnable: true
|
|
||||||
breakByHand: true
|
|
||||||
liquid: false
|
|
||||||
replaceable: false
|
|
||||||
solid: false
|
|
||||||
blocksLight: false
|
|
||||||
|
|
||||||
"plant"
|
|
||||||
pistonBehavior: "destroy"
|
|
||||||
blocksMovement: false
|
|
||||||
burnable: false
|
|
||||||
breakByHand: true
|
|
||||||
liquid: false
|
|
||||||
replaceable: false
|
|
||||||
solid: false
|
|
||||||
blocksLight: false
|
|
||||||
|
|
||||||
"underwater_plant"
|
|
||||||
pistonBehavior: "destroy"
|
|
||||||
blocksMovement: false
|
|
||||||
burnable: false
|
|
||||||
breakByHand: true
|
|
||||||
liquid: false
|
|
||||||
replaceable: false
|
|
||||||
solid: false
|
|
||||||
blocksLight: false
|
|
||||||
|
|
||||||
"replaceable_plant"
|
|
||||||
pistonBehavior: "destroy"
|
|
||||||
blocksMovement: false
|
|
||||||
burnable: true
|
|
||||||
breakByHand: true
|
|
||||||
liquid: false
|
|
||||||
replaceable: true
|
|
||||||
solid: false
|
|
||||||
blocksLight: false
|
|
||||||
|
|
||||||
"seagrass"
|
|
||||||
pistonBehavior: "destroy"
|
|
||||||
blocksMovement: false
|
|
||||||
burnable: false
|
|
||||||
breakByHand: true
|
|
||||||
liquid: false
|
|
||||||
replaceable: true
|
|
||||||
solid: false
|
|
||||||
blocksLight: false
|
|
||||||
|
|
||||||
"water"
|
|
||||||
pistonBehavior: "destroy"
|
|
||||||
blocksMovement: false
|
|
||||||
burnable: false
|
|
||||||
breakByHand: true
|
|
||||||
liquid: true
|
|
||||||
replaceable: true
|
|
||||||
solid: false
|
|
||||||
blocksLight: false
|
|
||||||
|
|
||||||
"bubble_column"
|
|
||||||
pistonBehavior: "destroy"
|
|
||||||
blocksMovement: false
|
|
||||||
burnable: false
|
|
||||||
breakByHand: true
|
|
||||||
liquid: true
|
|
||||||
replaceable: true
|
|
||||||
solid: false
|
|
||||||
blocksLight: false
|
|
||||||
|
|
||||||
"lava"
|
|
||||||
pistonBehavior: "destroy"
|
|
||||||
blocksMovement: false
|
|
||||||
burnable: false
|
|
||||||
breakByHand: true
|
|
||||||
liquid: true
|
|
||||||
replaceable: true
|
|
||||||
solid: false
|
|
||||||
blocksLight: false
|
|
||||||
|
|
||||||
"snow"
|
|
||||||
pistonBehavior: "destroy"
|
|
||||||
blocksMovement: false
|
|
||||||
burnable: false
|
|
||||||
breakByHand: false
|
|
||||||
liquid: false
|
|
||||||
replaceable: true
|
|
||||||
solid: false
|
|
||||||
blocksLight: false
|
|
||||||
|
|
||||||
"fire"
|
|
||||||
pistonBehavior: "destroy"
|
|
||||||
blocksMovement: false
|
|
||||||
burnable: false
|
|
||||||
breakByHand: true
|
|
||||||
liquid: false
|
|
||||||
replaceable: true
|
|
||||||
solid: false
|
|
||||||
blocksLight: false
|
|
||||||
|
|
||||||
"part"
|
|
||||||
pistonBehavior: "destroy"
|
|
||||||
blocksMovement: false
|
|
||||||
burnable: false
|
|
||||||
breakByHand: true
|
|
||||||
liquid: false
|
|
||||||
replaceable: false
|
|
||||||
solid: false
|
|
||||||
blocksLight: false
|
|
||||||
|
|
||||||
"cobweb"
|
|
||||||
pistonBehavior: "destroy"
|
|
||||||
blocksMovement: false
|
|
||||||
burnable: false
|
|
||||||
breakByHand: false
|
|
||||||
liquid: false
|
|
||||||
replaceable: false
|
|
||||||
solid: true
|
|
||||||
blocksLight: false
|
|
||||||
|
|
||||||
"redstone_lamp"
|
|
||||||
pistonBehavior: "normal"
|
|
||||||
blocksMovement: true
|
|
||||||
burnable: false
|
|
||||||
breakByHand: true
|
|
||||||
liquid: false
|
|
||||||
replaceable: false
|
|
||||||
solid: true
|
|
||||||
blocksLight: true
|
|
||||||
|
|
||||||
"clay"
|
|
||||||
pistonBehavior: "normal"
|
|
||||||
blocksMovement: true
|
|
||||||
burnable: false
|
|
||||||
breakByHand: true
|
|
||||||
liquid: false
|
|
||||||
replaceable: false
|
|
||||||
solid: true
|
|
||||||
blocksLight: true
|
|
||||||
|
|
||||||
"earth"
|
|
||||||
pistonBehavior: "normal"
|
|
||||||
blocksMovement: true
|
|
||||||
burnable: false
|
|
||||||
breakByHand: true
|
|
||||||
liquid: false
|
|
||||||
replaceable: false
|
|
||||||
solid: true
|
|
||||||
blocksLight: true
|
|
||||||
|
|
||||||
"organic"
|
|
||||||
pistonBehavior: "normal"
|
|
||||||
blocksMovement: true
|
|
||||||
burnable: false
|
|
||||||
breakByHand: true
|
|
||||||
liquid: false
|
|
||||||
replaceable: false
|
|
||||||
solid: true
|
|
||||||
blocksLight: true
|
|
||||||
|
|
||||||
"packed_ice"
|
|
||||||
pistonBehavior: "normal"
|
|
||||||
blocksMovement: true
|
|
||||||
burnable: false
|
|
||||||
breakByHand: true
|
|
||||||
liquid: false
|
|
||||||
replaceable: false
|
|
||||||
solid: true
|
|
||||||
blocksLight: true
|
|
||||||
|
|
||||||
"sand"
|
|
||||||
pistonBehavior: "normal"
|
|
||||||
blocksMovement: true
|
|
||||||
burnable: false
|
|
||||||
breakByHand: true
|
|
||||||
liquid: false
|
|
||||||
replaceable: false
|
|
||||||
solid: true
|
|
||||||
blocksLight: true
|
|
||||||
|
|
||||||
"sponge"
|
|
||||||
pistonBehavior: "normal"
|
|
||||||
blocksMovement: true
|
|
||||||
burnable: false
|
|
||||||
breakByHand: true
|
|
||||||
liquid: false
|
|
||||||
replaceable: false
|
|
||||||
solid: true
|
|
||||||
blocksLight: true
|
|
||||||
|
|
||||||
"shulker_box"
|
|
||||||
pistonBehavior: "normal"
|
|
||||||
blocksMovement: true
|
|
||||||
burnable: false
|
|
||||||
breakByHand: true
|
|
||||||
liquid: false
|
|
||||||
replaceable: false
|
|
||||||
solid: true
|
|
||||||
blocksLight: true
|
|
||||||
|
|
||||||
"wood"
|
|
||||||
pistonBehavior: "normal"
|
|
||||||
blocksMovement: true
|
|
||||||
burnable: true
|
|
||||||
breakByHand: true
|
|
||||||
liquid: false
|
|
||||||
replaceable: false
|
|
||||||
solid: true
|
|
||||||
blocksLight: true
|
|
||||||
|
|
||||||
"bamboo_sapling"
|
|
||||||
pistonBehavior: "destroy"
|
|
||||||
blocksMovement: false
|
|
||||||
burnable: true
|
|
||||||
breakByHand: true
|
|
||||||
liquid: false
|
|
||||||
replaceable: false
|
|
||||||
solid: true
|
|
||||||
blocksLight: true
|
|
||||||
|
|
||||||
"bamboo"
|
|
||||||
pistonBehavior: "destroy"
|
|
||||||
blocksMovement: true
|
|
||||||
burnable: true
|
|
||||||
breakByHand: true
|
|
||||||
liquid: false
|
|
||||||
replaceable: false
|
|
||||||
solid: true
|
|
||||||
blocksLight: true
|
|
||||||
|
|
||||||
"wool"
|
|
||||||
pistonBehavior: "normal"
|
|
||||||
blocksMovement: true
|
|
||||||
burnable: true
|
|
||||||
breakByHand: true
|
|
||||||
liquid: false
|
|
||||||
replaceable: false
|
|
||||||
solid: true
|
|
||||||
blocksLight: true
|
|
||||||
|
|
||||||
"tnt"
|
|
||||||
pistonBehavior: "normal"
|
|
||||||
blocksMovement: true
|
|
||||||
burnable: true
|
|
||||||
breakByHand: true
|
|
||||||
liquid: false
|
|
||||||
replaceable: false
|
|
||||||
solid: true
|
|
||||||
blocksLight: false
|
|
||||||
|
|
||||||
"leaves"
|
|
||||||
pistonBehavior: "destroy"
|
|
||||||
blocksMovement: true
|
|
||||||
burnable: true
|
|
||||||
breakByHand: true
|
|
||||||
liquid: false
|
|
||||||
replaceable: false
|
|
||||||
solid: true
|
|
||||||
blocksLight: false
|
|
||||||
|
|
||||||
"glass"
|
|
||||||
pistonBehavior: "normal"
|
|
||||||
blocksMovement: true
|
|
||||||
burnable: false
|
|
||||||
breakByHand: true
|
|
||||||
liquid: false
|
|
||||||
replaceable: false
|
|
||||||
solid: true
|
|
||||||
blocksLight: false
|
|
||||||
|
|
||||||
"ice"
|
|
||||||
pistonBehavior: "normal"
|
|
||||||
blocksMovement: true
|
|
||||||
burnable: false
|
|
||||||
breakByHand: true
|
|
||||||
liquid: false
|
|
||||||
replaceable: false
|
|
||||||
solid: true
|
|
||||||
blocksLight: false
|
|
||||||
|
|
||||||
"cactus"
|
|
||||||
pistonBehavior: "destroy"
|
|
||||||
blocksMovement: true
|
|
||||||
burnable: false
|
|
||||||
breakByHand: true
|
|
||||||
liquid: false
|
|
||||||
replaceable: false
|
|
||||||
solid: true
|
|
||||||
blocksLight: false
|
|
||||||
|
|
||||||
"stone"
|
|
||||||
pistonBehavior: "normal"
|
|
||||||
blocksMovement: true
|
|
||||||
burnable: false
|
|
||||||
breakByHand: false
|
|
||||||
liquid: false
|
|
||||||
replaceable: false
|
|
||||||
solid: true
|
|
||||||
blocksLight: true
|
|
||||||
|
|
||||||
"metal"
|
|
||||||
pistonBehavior: "normal"
|
|
||||||
blocksMovement: true
|
|
||||||
burnable: false
|
|
||||||
breakByHand: false
|
|
||||||
liquid: false
|
|
||||||
replaceable: false
|
|
||||||
solid: true
|
|
||||||
blocksLight: true
|
|
||||||
|
|
||||||
"snow_block"
|
|
||||||
pistonBehavior: "normal"
|
|
||||||
blocksMovement: true
|
|
||||||
burnable: false
|
|
||||||
breakByHand: false
|
|
||||||
liquid: false
|
|
||||||
replaceable: false
|
|
||||||
solid: true
|
|
||||||
blocksLight: true
|
|
||||||
|
|
||||||
"anvil"
|
|
||||||
pistonBehavior: "block"
|
|
||||||
blocksMovement: true
|
|
||||||
burnable: false
|
|
||||||
breakByHand: false
|
|
||||||
liquid: false
|
|
||||||
replaceable: false
|
|
||||||
solid: true
|
|
||||||
blocksLight: true
|
|
||||||
|
|
||||||
"barrier"
|
|
||||||
pistonBehavior: "block"
|
|
||||||
blocksMovement: true
|
|
||||||
burnable: false
|
|
||||||
breakByHand: false
|
|
||||||
liquid: false
|
|
||||||
replaceable: false
|
|
||||||
solid: true
|
|
||||||
blocksLight: true
|
|
||||||
|
|
||||||
"piston"
|
|
||||||
pistonBehavior: "block"
|
|
||||||
blocksMovement: true
|
|
||||||
burnable: false
|
|
||||||
breakByHand: true
|
|
||||||
liquid: false
|
|
||||||
replaceable: false
|
|
||||||
solid: true
|
|
||||||
blocksLight: true
|
|
||||||
|
|
||||||
"unused_plant"
|
|
||||||
pistonBehavior: "destroy"
|
|
||||||
blocksMovement: true
|
|
||||||
burnable: false
|
|
||||||
breakByHand: true
|
|
||||||
liquid: false
|
|
||||||
replaceable: false
|
|
||||||
solid: true
|
|
||||||
blocksLight: true
|
|
||||||
|
|
||||||
"pumpkin"
|
|
||||||
pistonBehavior: "destroy"
|
|
||||||
blocksMovement: true
|
|
||||||
burnable: false
|
|
||||||
breakByHand: true
|
|
||||||
liquid: false
|
|
||||||
replaceable: false
|
|
||||||
solid: true
|
|
||||||
blocksLight: true
|
|
||||||
|
|
||||||
"egg"
|
|
||||||
pistonBehavior: "destroy"
|
|
||||||
blocksMovement: true
|
|
||||||
burnable: false
|
|
||||||
breakByHand: true
|
|
||||||
liquid: false
|
|
||||||
replaceable: false
|
|
||||||
solid: true
|
|
||||||
blocksLight: true
|
|
||||||
|
|
||||||
"cake"
|
|
||||||
pistonBehavior: "destroy"
|
|
||||||
blocksMovement: true
|
|
||||||
burnable: false
|
|
||||||
breakByHand: true
|
|
||||||
liquid: false
|
|
||||||
replaceable: false
|
|
||||||
solid: true
|
|
||||||
blocksLight: true
|
|
||||||
|
|
||||||
"pistonBehavior":
|
|
||||||
normal,
|
|
||||||
destroy,
|
|
||||||
block,
|
|
||||||
ignore,
|
|
||||||
push_only
|
|
@ -1,10 +1,10 @@
|
|||||||
pluginManagement {
|
pluginManagement {
|
||||||
repositories {
|
repositories {
|
||||||
jcenter()
|
|
||||||
maven {
|
maven {
|
||||||
name = 'Fabric'
|
name = 'Fabric'
|
||||||
url = 'https://maven.fabricmc.net/'
|
url = 'https://maven.fabricmc.net/'
|
||||||
}
|
}
|
||||||
|
mavenCentral()
|
||||||
gradlePluginPortal()
|
gradlePluginPortal()
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -4,20 +4,34 @@ import com.google.common.collect.Maps;
|
|||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import net.minecraft.block.*;
|
import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents;
|
||||||
|
import net.fabricmc.fabric.api.registry.FlammableBlockRegistry;
|
||||||
|
import net.minecraft.block.AbstractBlock;
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.block.MapColor;
|
||||||
|
import net.minecraft.block.enums.NoteBlockInstrument;
|
||||||
import net.minecraft.block.piston.PistonBehavior;
|
import net.minecraft.block.piston.PistonBehavior;
|
||||||
|
import net.minecraft.entity.EntityType;
|
||||||
import net.minecraft.item.BlockItem;
|
import net.minecraft.item.BlockItem;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemGroup;
|
import net.minecraft.item.ItemGroup;
|
||||||
|
import net.minecraft.item.Items;
|
||||||
|
import net.minecraft.loot.LootTable;
|
||||||
|
import net.minecraft.registry.Registries;
|
||||||
|
import net.minecraft.registry.Registry;
|
||||||
|
import net.minecraft.registry.RegistryKey;
|
||||||
|
import net.minecraft.registry.RegistryKeys;
|
||||||
import net.minecraft.sound.BlockSoundGroup;
|
import net.minecraft.sound.BlockSoundGroup;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.JsonHelper;
|
|
||||||
import net.minecraft.util.Pair;
|
import net.minecraft.util.Pair;
|
||||||
import net.minecraft.util.registry.Registry;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.world.BlockView;
|
||||||
import org.apache.logging.log4j.Level;
|
import org.apache.logging.log4j.Level;
|
||||||
|
import quimufu.simple_creator.mixin.BlockSettingsAccessor;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
import static quimufu.simple_creator.SimpleCreatorMod.log;
|
import static quimufu.simple_creator.SimpleCreatorMod.log;
|
||||||
|
|
||||||
@ -34,8 +48,8 @@ public class BlockResourceLoader extends GenericManualResourceLoader<Pair<Block,
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void register(Identifier id, Pair<Block, Item> thing) {
|
protected void register(Identifier id, Pair<Block, Item> thing) {
|
||||||
Registry.register(Registry.BLOCK, id, thing.getLeft());
|
Registry.register(Registries.BLOCK, id, thing.getLeft());
|
||||||
Registry.register(Registry.ITEM, id, thing.getRight());
|
Registry.register(Registries.ITEM, id, thing.getRight());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -47,381 +61,387 @@ public class BlockResourceLoader extends GenericManualResourceLoader<Pair<Block,
|
|||||||
@Override
|
@Override
|
||||||
protected Pair<Block, Item> deserialize(Pair<Identifier, JsonObject> e) {
|
protected Pair<Block, Item> deserialize(Pair<Identifier, JsonObject> e) {
|
||||||
JsonObject jo = e.getRight();
|
JsonObject jo = e.getRight();
|
||||||
Material material;
|
log(Level.INFO, e.getRight().toString());
|
||||||
if(JsonHelper.hasString(jo, "material")){
|
|
||||||
String materialString = JsonHelper.getString(jo, "material");
|
|
||||||
material = getMaterial(materialString);
|
|
||||||
} else if (JsonHelper.getObject(jo,"material", null)!=null){
|
|
||||||
// get material information
|
|
||||||
JsonObject jmo = JsonHelper.getObject(jo, "material");
|
|
||||||
MaterialSettingsPojo mspj = GSON.fromJson(jmo, MaterialSettingsPojo.class);
|
|
||||||
//build material
|
|
||||||
material = getSettings(mspj);
|
|
||||||
} else {
|
|
||||||
material = Material.EARTH;
|
|
||||||
}
|
|
||||||
|
|
||||||
// get block information
|
// get block information
|
||||||
BlockSettingsPojo bspj = GSON.fromJson(jo, BlockSettingsPojo.class);
|
BlockSettingsPojo bspj = GSON.fromJson(jo, BlockSettingsPojo.class);
|
||||||
|
|
||||||
// move block information in Block.Settings (!!hacky!!)
|
// move block information in Block.Settings (!!hacky!!)
|
||||||
Block.Settings bs = getSettings(material, bspj);
|
Block.Settings bs = getSettings(bspj);
|
||||||
|
|
||||||
// parse item group
|
// parse item group
|
||||||
String group = JsonHelper.getString(jo, "itemGroup", "misc");
|
String group = bspj.itemGroup;
|
||||||
ItemGroup g = ItemResourceLoader.findGroup(group);
|
RegistryKey<ItemGroup> g = ItemResourceLoader.findGroup(group);
|
||||||
|
|
||||||
|
bs.registryKey(RegistryKey.of(Registries.BLOCK.getKey(), e.getLeft()));
|
||||||
|
|
||||||
//create block and corresponding item
|
//create block and corresponding item
|
||||||
Block resB = new Block(bs);
|
Block resB = new Block(bs);
|
||||||
Item resI = new BlockItem(resB, new Item.Settings().group(g));
|
|
||||||
|
|
||||||
FireBlock fireBlock = (FireBlock) Blocks.FIRE;
|
Item.Settings is = new Item.Settings();
|
||||||
|
is.useBlockPrefixedTranslationKey();
|
||||||
|
is.registryKey(RegistryKey.of(Registries.ITEM.getKey(), e.getLeft()));
|
||||||
|
Item resI = new BlockItem(resB, is);
|
||||||
|
|
||||||
int burnChance = JsonHelper.getInt(jo,"burnChance", -1);
|
ItemGroupEvents.modifyEntriesEvent(g).register(content -> content.add(resI));
|
||||||
int spreadChance = JsonHelper.getInt(jo,"spreadChance", -1);
|
|
||||||
if(burnChance!=-1 && spreadChance!=-1){
|
int burnChance = bspj.burnChance;
|
||||||
//spreadChance and burnChance are the wrong way around in yarn
|
int spreadChance = bspj.spreadChance;
|
||||||
fireBlock.registerFlammableBlock(resB, spreadChance, burnChance);
|
if (burnChance != -1 && spreadChance != -1) {
|
||||||
|
FlammableBlockRegistry.getDefaultInstance().add(resB, spreadChance, burnChance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SimpleCreatorMod.BLOCKS_RENDER_LAYER.add(new Pair<>(resB, bspj.renderLayer));
|
||||||
return new Pair<>(resB, resI);
|
return new Pair<>(resB, resI);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Material getSettings(MaterialSettingsPojo mspj) {
|
private Block.Settings getSettings(BlockSettingsPojo bspj) {
|
||||||
return new Material(
|
AbstractBlock.Settings blockSettings = AbstractBlock.Settings.create();
|
||||||
MaterialColor.PINK,
|
|
||||||
mspj.liquid,
|
|
||||||
mspj.solid,
|
|
||||||
mspj.blocksMovement,
|
|
||||||
mspj.blocksLight,
|
|
||||||
mspj.breakByHand,
|
|
||||||
mspj.burnable,
|
|
||||||
mspj.replaceable,
|
|
||||||
getPistonBehavior(mspj.pistonBehavior));
|
|
||||||
|
|
||||||
|
blockSettings
|
||||||
|
.slipperiness(bspj.slipperiness)
|
||||||
|
.velocityMultiplier(bspj.movementVelocityMultiplier)
|
||||||
|
.jumpVelocityMultiplier(bspj.jumpVelocityMultiplier)
|
||||||
|
.sounds(getSoundGroup(bspj.soundGroup))
|
||||||
|
.lootTable(Optional.ofNullable(getDropTableId(bspj.dropTableId)))
|
||||||
|
.mapColor(getMapColor(bspj.mapColor))
|
||||||
|
.allowsSpawning(bspj.allowsSpawning ? BlockResourceLoader::always : BlockResourceLoader::never)
|
||||||
|
.solidBlock(bspj.solidBlock ? BlockResourceLoader::always : BlockResourceLoader::never)
|
||||||
|
.suffocates(bspj.suffocates ? BlockResourceLoader::always : BlockResourceLoader::never)
|
||||||
|
.blockVision(bspj.blockVision ? BlockResourceLoader::always : BlockResourceLoader::never)
|
||||||
|
.postProcess(bspj.postProcess ? BlockResourceLoader::always : BlockResourceLoader::never)
|
||||||
|
.emissiveLighting(bspj.emissiveLighting ? BlockResourceLoader::always : BlockResourceLoader::never)
|
||||||
|
.hardness(bspj.hardness)
|
||||||
|
.resistance(bspj.explosionResistance)
|
||||||
|
.offset(getOffset(bspj.modelOffset))
|
||||||
|
.pistonBehavior(getPistonBehavior(bspj.pistonBehavior))
|
||||||
|
.instrument(getInstrument(bspj.instrument))
|
||||||
|
.luminance((blockState) -> bspj.lightLevel);
|
||||||
|
|
||||||
|
((BlockSettingsAccessor) blockSettings)
|
||||||
|
.setCollidable(bspj.collidable);
|
||||||
|
|
||||||
|
if (bspj.burnable) {
|
||||||
|
blockSettings.burnable();
|
||||||
|
}
|
||||||
|
//not supported for now
|
||||||
|
//blockSettings.liquid()
|
||||||
|
if (bspj.solidBlock) {
|
||||||
|
blockSettings.solid();
|
||||||
|
} else {
|
||||||
|
blockSettings.notSolid();
|
||||||
|
}
|
||||||
|
if (bspj.replaceable) {
|
||||||
|
blockSettings.replaceable();
|
||||||
|
}
|
||||||
|
//not supported for now
|
||||||
|
//blockSettings.air()
|
||||||
|
|
||||||
|
if (bspj.noBlockBreakParticles) {
|
||||||
|
blockSettings.noBlockBreakParticles();
|
||||||
|
}
|
||||||
|
if (bspj.requiresTool) {
|
||||||
|
blockSettings.requiresTool();
|
||||||
|
|
||||||
|
}
|
||||||
|
if (bspj.breaksInstantly) {
|
||||||
|
blockSettings.breakInstantly();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!bspj.opaque) {
|
||||||
|
blockSettings.nonOpaque();
|
||||||
|
}
|
||||||
|
|
||||||
|
return blockSettings;
|
||||||
|
}
|
||||||
|
|
||||||
|
private NoteBlockInstrument getInstrument(String instrument) {
|
||||||
|
return switch (instrument.toUpperCase()) {
|
||||||
|
case "HARP" -> NoteBlockInstrument.HARP;
|
||||||
|
case "BASEDRUM" -> NoteBlockInstrument.BASEDRUM;
|
||||||
|
case "SNARE" -> NoteBlockInstrument.SNARE;
|
||||||
|
case "HAT" -> NoteBlockInstrument.HAT;
|
||||||
|
case "BASS" -> NoteBlockInstrument.BASS;
|
||||||
|
case "FLUTE" -> NoteBlockInstrument.FLUTE;
|
||||||
|
case "BELL" -> NoteBlockInstrument.BELL;
|
||||||
|
case "GUITAR" -> NoteBlockInstrument.GUITAR;
|
||||||
|
case "CHIME" -> NoteBlockInstrument.CHIME;
|
||||||
|
case "XYLOPHONE" -> NoteBlockInstrument.XYLOPHONE;
|
||||||
|
case "IRON_XYLOPHONE" -> NoteBlockInstrument.IRON_XYLOPHONE;
|
||||||
|
case "COW_BELL" -> NoteBlockInstrument.COW_BELL;
|
||||||
|
case "DIDGERIDOO" -> NoteBlockInstrument.DIDGERIDOO;
|
||||||
|
case "BIT" -> NoteBlockInstrument.BIT;
|
||||||
|
case "BANJO" -> NoteBlockInstrument.BANJO;
|
||||||
|
case "PLING" -> NoteBlockInstrument.PLING;
|
||||||
|
case "ZOMBIE" -> NoteBlockInstrument.ZOMBIE;
|
||||||
|
case "SKELETON" -> NoteBlockInstrument.SKELETON;
|
||||||
|
case "CREEPER" -> NoteBlockInstrument.CREEPER;
|
||||||
|
case "DRAGON" -> NoteBlockInstrument.DRAGON;
|
||||||
|
case "WITHER_SKELETON" -> NoteBlockInstrument.WITHER_SKELETON;
|
||||||
|
case "PIGLIN" -> NoteBlockInstrument.PIGLIN;
|
||||||
|
case "CUSTOM_HEAD" -> NoteBlockInstrument.CUSTOM_HEAD;
|
||||||
|
default -> {
|
||||||
|
log(Level.WARN, "Instrument " + instrument + " not found, using harp");
|
||||||
|
yield NoteBlockInstrument.HARP;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private AbstractBlock.OffsetType getOffset(String modelOffset) {
|
||||||
|
return switch (modelOffset.toUpperCase()) {
|
||||||
|
case "NONE" -> AbstractBlock.OffsetType.NONE;
|
||||||
|
case "XZ" -> AbstractBlock.OffsetType.XZ;
|
||||||
|
case "XYZ" -> AbstractBlock.OffsetType.XYZ;
|
||||||
|
default -> {
|
||||||
|
log(Level.WARN, "ModelOffset " + modelOffset + " not found, using none");
|
||||||
|
yield AbstractBlock.OffsetType.NONE;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean always(BlockState blockState, BlockView blockView, BlockPos blockPos) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean never(BlockState blockState, BlockView blockView, BlockPos blockPos) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A shortcut to always return {@code false} in a typed context predicate with an
|
||||||
|
* {@link EntityType}, used like {@code settings.allowSpawning(Blocks::never)}.
|
||||||
|
*/
|
||||||
|
private static Boolean never(BlockState state, BlockView world, BlockPos pos, EntityType<?> type) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A shortcut to always return {@code true} in a typed context predicate with an
|
||||||
|
* {@link EntityType}, used like {@code settings.allowSpawning(Blocks::always)}.
|
||||||
|
*/
|
||||||
|
private static Boolean always(BlockState state, BlockView world, BlockPos pos, EntityType<?> type) {
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private PistonBehavior getPistonBehavior(String pistonBehavior) {
|
private PistonBehavior getPistonBehavior(String pistonBehavior) {
|
||||||
switch (pistonBehavior.toUpperCase()) {
|
return switch (pistonBehavior.toUpperCase()) {
|
||||||
case "NORMAL":
|
case "NORMAL" -> PistonBehavior.NORMAL;
|
||||||
return PistonBehavior.NORMAL;
|
case "DESTROY" -> PistonBehavior.DESTROY;
|
||||||
case "DESTROY":
|
case "BLOCK" -> PistonBehavior.BLOCK;
|
||||||
return PistonBehavior.DESTROY;
|
case "IGNORE" -> PistonBehavior.IGNORE;
|
||||||
case "BLOCK":
|
case "PUSH_ONLY" -> PistonBehavior.PUSH_ONLY;
|
||||||
return PistonBehavior.BLOCK;
|
default -> {
|
||||||
case "IGNORE":
|
|
||||||
return PistonBehavior.IGNORE;
|
|
||||||
case "PUSH_ONLY":
|
|
||||||
return PistonBehavior.PUSH_ONLY;
|
|
||||||
default:
|
|
||||||
log(Level.WARN, "Piston Behavior " + pistonBehavior + " not found, using normal");
|
log(Level.WARN, "Piston Behavior " + pistonBehavior + " not found, using normal");
|
||||||
return PistonBehavior.NORMAL;
|
yield PistonBehavior.NORMAL;
|
||||||
|
}
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private MaterialColor getMaterialColor(String color) {
|
|
||||||
switch (color.toUpperCase()) {
|
private MapColor getMapColor(String color) {
|
||||||
case "AIR":
|
return switch (color.toUpperCase()) {
|
||||||
return MaterialColor.AIR;
|
case "CLEAR" -> MapColor.CLEAR;
|
||||||
case "GRASS":
|
case "PALE_GREEN" -> MapColor.PALE_GREEN;
|
||||||
return MaterialColor.GRASS;
|
case "PALE_YELLOW" -> MapColor.PALE_YELLOW;
|
||||||
case "SAND":
|
case "WHITE_GRAY" -> MapColor.WHITE_GRAY;
|
||||||
return MaterialColor.SAND;
|
case "BRIGHT_RED" -> MapColor.BRIGHT_RED;
|
||||||
case "WEB":
|
case "PALE_PURPLE" -> MapColor.PALE_PURPLE;
|
||||||
return MaterialColor.WEB;
|
case "IRON_GRAY" -> MapColor.IRON_GRAY;
|
||||||
case "LAVA":
|
case "DARK_GREEN" -> MapColor.DARK_GREEN;
|
||||||
return MaterialColor.LAVA;
|
case "WHITE" -> MapColor.WHITE;
|
||||||
case "ICE":
|
case "LIGHT_BLUE_GRAY" -> MapColor.LIGHT_BLUE_GRAY;
|
||||||
return MaterialColor.ICE;
|
case "DIRT_BROWN" -> MapColor.DIRT_BROWN;
|
||||||
case "IRON":
|
case "STONE_GRAY" -> MapColor.STONE_GRAY;
|
||||||
return MaterialColor.IRON;
|
case "WATER_BLUE" -> MapColor.WATER_BLUE;
|
||||||
case "FOLIAGE":
|
case "OAK_TAN" -> MapColor.OAK_TAN;
|
||||||
return MaterialColor.FOLIAGE;
|
case "OFF_WHITE" -> MapColor.OFF_WHITE;
|
||||||
case "WHITE":
|
case "ORANGE" -> MapColor.ORANGE;
|
||||||
return MaterialColor.WHITE;
|
case "MAGENTA" -> MapColor.MAGENTA;
|
||||||
case "CLAY":
|
case "LIGHT_BLUE" -> MapColor.LIGHT_BLUE;
|
||||||
return MaterialColor.CLAY;
|
case "YELLOW" -> MapColor.YELLOW;
|
||||||
case "DIRT":
|
case "LIME" -> MapColor.LIME;
|
||||||
return MaterialColor.DIRT;
|
case "PINK" -> MapColor.PINK;
|
||||||
case "STONE":
|
case "GRAY" -> MapColor.GRAY;
|
||||||
return MaterialColor.STONE;
|
case "LIGHT_GRAY" -> MapColor.LIGHT_GRAY;
|
||||||
case "WATER":
|
case "CYAN" -> MapColor.CYAN;
|
||||||
return MaterialColor.WATER;
|
case "PURPLE" -> MapColor.PURPLE;
|
||||||
case "WOOD":
|
case "BLUE" -> MapColor.BLUE;
|
||||||
return MaterialColor.WOOD;
|
case "BROWN" -> MapColor.BROWN;
|
||||||
case "QUARTZ":
|
case "GREEN" -> MapColor.GREEN;
|
||||||
return MaterialColor.QUARTZ;
|
case "RED" -> MapColor.RED;
|
||||||
case "ORANGE":
|
case "BLACK" -> MapColor.BLACK;
|
||||||
return MaterialColor.ORANGE;
|
case "GOLD" -> MapColor.GOLD;
|
||||||
case "MAGENTA":
|
case "DIAMOND_BLUE" -> MapColor.DIAMOND_BLUE;
|
||||||
return MaterialColor.MAGENTA;
|
case "LAPIS_BLUE" -> MapColor.LAPIS_BLUE;
|
||||||
case "LIGHT_BLUE":
|
case "EMERALD_GREEN" -> MapColor.EMERALD_GREEN;
|
||||||
return MaterialColor.LIGHT_BLUE;
|
case "SPRUCE_BROWN" -> MapColor.SPRUCE_BROWN;
|
||||||
case "YELLOW":
|
case "DARK_RED" -> MapColor.DARK_RED;
|
||||||
return MaterialColor.YELLOW;
|
case "TERRACOTTA_WHITE" -> MapColor.TERRACOTTA_WHITE;
|
||||||
case "LIME":
|
case "TERRACOTTA_ORANGE" -> MapColor.TERRACOTTA_ORANGE;
|
||||||
return MaterialColor.LIME;
|
case "TERRACOTTA_MAGENTA" -> MapColor.TERRACOTTA_MAGENTA;
|
||||||
case "PINK":
|
case "TERRACOTTA_LIGHT_BLUE" -> MapColor.TERRACOTTA_LIGHT_BLUE;
|
||||||
return MaterialColor.PINK;
|
case "TERRACOTTA_YELLOW" -> MapColor.TERRACOTTA_YELLOW;
|
||||||
case "GRAY":
|
case "TERRACOTTA_LIME" -> MapColor.TERRACOTTA_LIME;
|
||||||
return MaterialColor.GRAY;
|
case "TERRACOTTA_PINK" -> MapColor.TERRACOTTA_PINK;
|
||||||
case "LIGHT_GRAY":
|
case "TERRACOTTA_GRAY" -> MapColor.TERRACOTTA_GRAY;
|
||||||
return MaterialColor.LIGHT_GRAY;
|
case "TERRACOTTA_LIGHT_GRAY" -> MapColor.TERRACOTTA_LIGHT_GRAY;
|
||||||
case "CYAN":
|
case "TERRACOTTA_CYAN" -> MapColor.TERRACOTTA_CYAN;
|
||||||
return MaterialColor.CYAN;
|
case "TERRACOTTA_PURPLE" -> MapColor.TERRACOTTA_PURPLE;
|
||||||
case "PURPLE":
|
case "TERRACOTTA_BLUE" -> MapColor.TERRACOTTA_BLUE;
|
||||||
return MaterialColor.PURPLE;
|
case "TERRACOTTA_BROWN" -> MapColor.TERRACOTTA_BROWN;
|
||||||
case "BLUE":
|
case "TERRACOTTA_GREEN" -> MapColor.TERRACOTTA_GREEN;
|
||||||
return MaterialColor.BLUE;
|
case "TERRACOTTA_RED" -> MapColor.TERRACOTTA_RED;
|
||||||
case "BROWN":
|
case "TERRACOTTA_BLACK" -> MapColor.TERRACOTTA_BLACK;
|
||||||
return MaterialColor.BROWN;
|
case "DULL_RED" -> MapColor.DULL_RED;
|
||||||
case "GREEN":
|
case "DULL_PINK" -> MapColor.DULL_PINK;
|
||||||
return MaterialColor.GREEN;
|
case "DARK_CRIMSON" -> MapColor.DARK_CRIMSON;
|
||||||
case "RED":
|
case "TEAL" -> MapColor.TEAL;
|
||||||
return MaterialColor.RED;
|
case "DARK_AQUA" -> MapColor.DARK_AQUA;
|
||||||
case "BLACK":
|
case "DARK_DULL_PINK" -> MapColor.DARK_DULL_PINK;
|
||||||
return MaterialColor.BLACK;
|
case "BRIGHT_TEAL" -> MapColor.BRIGHT_TEAL;
|
||||||
case "GOLD":
|
case "DEEPSLATE_GRAY" -> MapColor.DEEPSLATE_GRAY;
|
||||||
return MaterialColor.GOLD;
|
case "RAW_IRON_PINK" -> MapColor.RAW_IRON_PINK;
|
||||||
case "DIAMOND":
|
case "LICHEN_GREEN" -> MapColor.LICHEN_GREEN;
|
||||||
return MaterialColor.DIAMOND;
|
default -> {
|
||||||
case "LAPIS":
|
|
||||||
return MaterialColor.LAPIS;
|
|
||||||
case "EMERALD":
|
|
||||||
return MaterialColor.EMERALD;
|
|
||||||
case "SPRUCE":
|
|
||||||
return MaterialColor.SPRUCE;
|
|
||||||
case "NETHER":
|
|
||||||
return MaterialColor.NETHER;
|
|
||||||
case "WHITE_TERRACOTTA":
|
|
||||||
return MaterialColor.WHITE_TERRACOTTA;
|
|
||||||
case "ORANGE_TERRACOTTA":
|
|
||||||
return MaterialColor.ORANGE_TERRACOTTA;
|
|
||||||
case "MAGENTA_TERRACOTTA":
|
|
||||||
return MaterialColor.MAGENTA_TERRACOTTA;
|
|
||||||
case "LIGHT_BLUE_TERRACOTTA":
|
|
||||||
return MaterialColor.LIGHT_BLUE_TERRACOTTA;
|
|
||||||
case "YELLOW_TERRACOTTA":
|
|
||||||
return MaterialColor.YELLOW_TERRACOTTA;
|
|
||||||
case "LIME_TERRACOTTA":
|
|
||||||
return MaterialColor.LIME_TERRACOTTA;
|
|
||||||
case "PINK_TERRACOTTA":
|
|
||||||
return MaterialColor.PINK_TERRACOTTA;
|
|
||||||
case "GRAY_TERRACOTTA":
|
|
||||||
return MaterialColor.GRAY_TERRACOTTA;
|
|
||||||
case "LIGHT_GRAY_TERRACOTTA":
|
|
||||||
return MaterialColor.LIGHT_GRAY_TERRACOTTA;
|
|
||||||
case "CYAN_TERRACOTTA":
|
|
||||||
return MaterialColor.CYAN_TERRACOTTA;
|
|
||||||
case "PURPLE_TERRACOTTA":
|
|
||||||
return MaterialColor.PURPLE_TERRACOTTA;
|
|
||||||
case "BLUE_TERRACOTTA":
|
|
||||||
return MaterialColor.BLUE_TERRACOTTA;
|
|
||||||
case "BROWN_TERRACOTTA":
|
|
||||||
return MaterialColor.BROWN_TERRACOTTA;
|
|
||||||
case "GREEN_TERRACOTTA":
|
|
||||||
return MaterialColor.GREEN_TERRACOTTA;
|
|
||||||
case "RED_TERRACOTTA":
|
|
||||||
return MaterialColor.RED_TERRACOTTA;
|
|
||||||
case "BLACK_TERRACOTTA":
|
|
||||||
return MaterialColor.BLACK_TERRACOTTA;
|
|
||||||
default:
|
|
||||||
log(Level.WARN, "MapColor " + color + " not found, using pink");
|
log(Level.WARN, "MapColor " + color + " not found, using pink");
|
||||||
return MaterialColor.PINK;
|
yield MapColor.PINK;
|
||||||
}
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private Block.Settings getSettings(Material material, BlockSettingsPojo bspj) {
|
private RegistryKey<LootTable> getDropTableId(String s) {
|
||||||
Block.Settings bs = Block.Settings.of(material, material.getColor());
|
|
||||||
Field[] fields = Block.Settings.class.getDeclaredFields();
|
|
||||||
try {
|
|
||||||
fields[0].setAccessible(true);
|
|
||||||
fields[0].set(bs, material);
|
|
||||||
fields[1].setAccessible(true);
|
|
||||||
fields[1].set(bs, getMaterialColor(bspj.mapColor));
|
|
||||||
fields[2].setAccessible(true);
|
|
||||||
fields[2].setBoolean(bs, bspj.collidable);
|
|
||||||
fields[3].setAccessible(true);
|
|
||||||
fields[3].set(bs, getSoundGroup(bspj.soundGroup));
|
|
||||||
fields[4].setAccessible(true);
|
|
||||||
fields[4].setInt(bs, bspj.lightLevel);
|
|
||||||
fields[5].setAccessible(true);
|
|
||||||
fields[5].setFloat(bs, bspj.explosionResistance);
|
|
||||||
fields[6].setAccessible(true);
|
|
||||||
fields[6].setFloat(bs, bspj.hardness);
|
|
||||||
fields[8].setAccessible(true);
|
|
||||||
fields[8].setFloat(bs, bspj.slipperiness);
|
|
||||||
fields[9].setAccessible(true);
|
|
||||||
fields[9].setFloat(bs, bspj.slowDownMultiplier);
|
|
||||||
fields[10].setAccessible(true);
|
|
||||||
fields[10].setFloat(bs, bspj.jumpVelocityMultiplier);
|
|
||||||
fields[11].setAccessible(true);
|
|
||||||
fields[11].set(bs, getDropTableId(bspj.dropTableId));
|
|
||||||
fields[12].setAccessible(true);
|
|
||||||
fields[12].setBoolean(bs, bspj.opaque);
|
|
||||||
} catch (IllegalAccessException ex) {
|
|
||||||
ex.printStackTrace();
|
|
||||||
}
|
|
||||||
return bs;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Identifier getDropTableId(String s) {
|
|
||||||
if (s == null)
|
if (s == null)
|
||||||
return null;
|
return null;
|
||||||
Identifier i = Identifier.tryParse(s);
|
Identifier i = Identifier.tryParse(s);
|
||||||
if (i == null) {
|
if (i == null) {
|
||||||
log(Level.WARN, "Drop table invalid " + s + ", using default");
|
log(Level.WARN, "Drop table invalid " + s + ", using default");
|
||||||
i = null;
|
|
||||||
}
|
}
|
||||||
return i;
|
return RegistryKey.of(RegistryKeys.LOOT_TABLE, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
private BlockSoundGroup getSoundGroup(String s) {
|
private BlockSoundGroup getSoundGroup(String s) {
|
||||||
switch (s.toUpperCase()) {
|
return switch (s.toUpperCase()) {
|
||||||
case "WOOD":
|
case "INTENTIONALLY_EMPTY" -> BlockSoundGroup.INTENTIONALLY_EMPTY;
|
||||||
return BlockSoundGroup.WOOD;
|
case "WOOD" -> BlockSoundGroup.WOOD;
|
||||||
case "GRAVEL":
|
case "GRAVEL" -> BlockSoundGroup.GRAVEL;
|
||||||
return BlockSoundGroup.GRAVEL;
|
case "GRASS" -> BlockSoundGroup.GRASS;
|
||||||
case "GRASS":
|
case "LILY_PAD" -> BlockSoundGroup.LILY_PAD;
|
||||||
return BlockSoundGroup.GRASS;
|
case "STONE" -> BlockSoundGroup.STONE;
|
||||||
case "STONE":
|
case "METAL" -> BlockSoundGroup.METAL;
|
||||||
return BlockSoundGroup.STONE;
|
case "GLASS" -> BlockSoundGroup.GLASS;
|
||||||
case "METAL":
|
case "WOOL" -> BlockSoundGroup.WOOL;
|
||||||
return BlockSoundGroup.METAL;
|
case "SAND" -> BlockSoundGroup.SAND;
|
||||||
case "GLASS":
|
case "SNOW" -> BlockSoundGroup.SNOW;
|
||||||
return BlockSoundGroup.GLASS;
|
case "POWDER_SNOW" -> BlockSoundGroup.POWDER_SNOW;
|
||||||
case "WOOL":
|
case "LADDER" -> BlockSoundGroup.LADDER;
|
||||||
return BlockSoundGroup.WOOL;
|
case "ANVIL" -> BlockSoundGroup.ANVIL;
|
||||||
case "SAND":
|
case "SLIME" -> BlockSoundGroup.SLIME;
|
||||||
return BlockSoundGroup.SAND;
|
case "HONEY" -> BlockSoundGroup.HONEY;
|
||||||
case "SNOW":
|
case "WET_GRASS" -> BlockSoundGroup.WET_GRASS;
|
||||||
return BlockSoundGroup.SNOW;
|
case "CORAL" -> BlockSoundGroup.CORAL;
|
||||||
case "LADDER":
|
case "BAMBOO" -> BlockSoundGroup.BAMBOO;
|
||||||
return BlockSoundGroup.LADDER;
|
case "BAMBOO_SAPLING" -> BlockSoundGroup.BAMBOO_SAPLING;
|
||||||
case "ANVIL":
|
case "SCAFFOLDING" -> BlockSoundGroup.SCAFFOLDING;
|
||||||
return BlockSoundGroup.ANVIL;
|
case "SWEET_BERRY_BUSH" -> BlockSoundGroup.SWEET_BERRY_BUSH;
|
||||||
case "SLIME":
|
case "CROP" -> BlockSoundGroup.CROP;
|
||||||
return BlockSoundGroup.SLIME;
|
case "STEM" -> BlockSoundGroup.STEM;
|
||||||
case "HONEY":
|
case "VINE" -> BlockSoundGroup.VINE;
|
||||||
return BlockSoundGroup.HONEY;
|
case "NETHER_WART" -> BlockSoundGroup.NETHER_WART;
|
||||||
case "WET_GRASS":
|
case "LANTERN" -> BlockSoundGroup.LANTERN;
|
||||||
return BlockSoundGroup.WET_GRASS;
|
case "NETHER_STEM" -> BlockSoundGroup.NETHER_STEM;
|
||||||
case "CORAL":
|
case "NYLIUM" -> BlockSoundGroup.NYLIUM;
|
||||||
return BlockSoundGroup.CORAL;
|
case "FUNGUS" -> BlockSoundGroup.FUNGUS;
|
||||||
case "BAMBOO":
|
case "ROOTS" -> BlockSoundGroup.ROOTS;
|
||||||
return BlockSoundGroup.BAMBOO;
|
case "SHROOMLIGHT" -> BlockSoundGroup.SHROOMLIGHT;
|
||||||
case "BAMBOO_SAPLING":
|
case "WEEPING_VINES" -> BlockSoundGroup.WEEPING_VINES;
|
||||||
return BlockSoundGroup.BAMBOO_SAPLING;
|
case "WEEPING_VINES_LOW_PITCH" -> BlockSoundGroup.WEEPING_VINES_LOW_PITCH;
|
||||||
case "SCAFFOLDING":
|
case "SOUL_SAND" -> BlockSoundGroup.SOUL_SAND;
|
||||||
return BlockSoundGroup.SCAFFOLDING;
|
case "SOUL_SOIL" -> BlockSoundGroup.SOUL_SOIL;
|
||||||
case "SWEET_BERRY_BUSH":
|
case "BASALT" -> BlockSoundGroup.BASALT;
|
||||||
return BlockSoundGroup.SWEET_BERRY_BUSH;
|
case "WART_BLOCK" -> BlockSoundGroup.WART_BLOCK;
|
||||||
case "CROP":
|
case "NETHERRACK" -> BlockSoundGroup.NETHERRACK;
|
||||||
return BlockSoundGroup.CROP;
|
case "NETHER_BRICKS" -> BlockSoundGroup.NETHER_BRICKS;
|
||||||
case "STEM":
|
case "NETHER_SPROUTS" -> BlockSoundGroup.NETHER_SPROUTS;
|
||||||
return BlockSoundGroup.STEM;
|
case "NETHER_ORE" -> BlockSoundGroup.NETHER_ORE;
|
||||||
case "NETHER_WART":
|
case "BONE" -> BlockSoundGroup.BONE;
|
||||||
return BlockSoundGroup.NETHER_WART;
|
case "NETHERITE" -> BlockSoundGroup.NETHERITE;
|
||||||
case "LANTERN":
|
case "ANCIENT_DEBRIS" -> BlockSoundGroup.ANCIENT_DEBRIS;
|
||||||
return BlockSoundGroup.LANTERN;
|
case "LODESTONE" -> BlockSoundGroup.LODESTONE;
|
||||||
default:
|
case "CHAIN" -> BlockSoundGroup.CHAIN;
|
||||||
|
case "NETHER_GOLD_ORE" -> BlockSoundGroup.NETHER_GOLD_ORE;
|
||||||
|
case "GILDED_BLACKSTONE" -> BlockSoundGroup.GILDED_BLACKSTONE;
|
||||||
|
case "CANDLE" -> BlockSoundGroup.CANDLE;
|
||||||
|
case "AMETHYST_BLOCK" -> BlockSoundGroup.AMETHYST_BLOCK;
|
||||||
|
case "AMETHYST_CLUSTER" -> BlockSoundGroup.AMETHYST_CLUSTER;
|
||||||
|
case "SMALL_AMETHYST_BUD" -> BlockSoundGroup.SMALL_AMETHYST_BUD;
|
||||||
|
case "MEDIUM_AMETHYST_BUD" -> BlockSoundGroup.MEDIUM_AMETHYST_BUD;
|
||||||
|
case "LARGE_AMETHYST_BUD" -> BlockSoundGroup.LARGE_AMETHYST_BUD;
|
||||||
|
case "TUFF" -> BlockSoundGroup.TUFF;
|
||||||
|
case "TUFF_BRICKS" -> BlockSoundGroup.TUFF_BRICKS;
|
||||||
|
case "POLISHED_TUFF" -> BlockSoundGroup.POLISHED_TUFF;
|
||||||
|
case "CALCITE" -> BlockSoundGroup.CALCITE;
|
||||||
|
case "DRIPSTONE_BLOCK" -> BlockSoundGroup.DRIPSTONE_BLOCK;
|
||||||
|
case "POINTED_DRIPSTONE" -> BlockSoundGroup.POINTED_DRIPSTONE;
|
||||||
|
case "COPPER" -> BlockSoundGroup.COPPER;
|
||||||
|
case "COPPER_BULB" -> BlockSoundGroup.COPPER_BULB;
|
||||||
|
case "COPPER_GRATE" -> BlockSoundGroup.COPPER_GRATE;
|
||||||
|
case "CAVE_VINES" -> BlockSoundGroup.CAVE_VINES;
|
||||||
|
case "SPORE_BLOSSOM" -> BlockSoundGroup.SPORE_BLOSSOM;
|
||||||
|
case "AZALEA" -> BlockSoundGroup.AZALEA;
|
||||||
|
case "FLOWERING_AZALEA" -> BlockSoundGroup.FLOWERING_AZALEA;
|
||||||
|
case "MOSS_CARPET" -> BlockSoundGroup.MOSS_CARPET;
|
||||||
|
case "PINK_PETALS" -> BlockSoundGroup.PINK_PETALS;
|
||||||
|
case "MOSS_BLOCK" -> BlockSoundGroup.MOSS_BLOCK;
|
||||||
|
case "BIG_DRIPLEAF" -> BlockSoundGroup.BIG_DRIPLEAF;
|
||||||
|
case "SMALL_DRIPLEAF" -> BlockSoundGroup.SMALL_DRIPLEAF;
|
||||||
|
case "ROOTED_DIRT" -> BlockSoundGroup.ROOTED_DIRT;
|
||||||
|
case "HANGING_ROOTS" -> BlockSoundGroup.HANGING_ROOTS;
|
||||||
|
case "AZALEA_LEAVES" -> BlockSoundGroup.AZALEA_LEAVES;
|
||||||
|
case "SCULK_SENSOR" -> BlockSoundGroup.SCULK_SENSOR;
|
||||||
|
case "SCULK_CATALYST" -> BlockSoundGroup.SCULK_CATALYST;
|
||||||
|
case "SCULK" -> BlockSoundGroup.SCULK;
|
||||||
|
case "SCULK_VEIN" -> BlockSoundGroup.SCULK_VEIN;
|
||||||
|
case "SCULK_SHRIEKER" -> BlockSoundGroup.SCULK_SHRIEKER;
|
||||||
|
case "GLOW_LICHEN" -> BlockSoundGroup.GLOW_LICHEN;
|
||||||
|
case "DEEPSLATE" -> BlockSoundGroup.DEEPSLATE;
|
||||||
|
case "DEEPSLATE_BRICKS" -> BlockSoundGroup.DEEPSLATE_BRICKS;
|
||||||
|
case "DEEPSLATE_TILES" -> BlockSoundGroup.DEEPSLATE_TILES;
|
||||||
|
case "POLISHED_DEEPSLATE" -> BlockSoundGroup.POLISHED_DEEPSLATE;
|
||||||
|
case "FROGLIGHT" -> BlockSoundGroup.FROGLIGHT;
|
||||||
|
case "FROGSPAWN" -> BlockSoundGroup.FROGSPAWN;
|
||||||
|
case "MANGROVE_ROOTS" -> BlockSoundGroup.MANGROVE_ROOTS;
|
||||||
|
case "MUDDY_MANGROVE_ROOTS" -> BlockSoundGroup.MUDDY_MANGROVE_ROOTS;
|
||||||
|
case "MUD" -> BlockSoundGroup.MUD;
|
||||||
|
case "MUD_BRICKS" -> BlockSoundGroup.MUD_BRICKS;
|
||||||
|
case "PACKED_MUD" -> BlockSoundGroup.PACKED_MUD;
|
||||||
|
case "HANGING_SIGN" -> BlockSoundGroup.HANGING_SIGN;
|
||||||
|
case "NETHER_WOOD_HANGING_SIGN" -> BlockSoundGroup.NETHER_WOOD_HANGING_SIGN;
|
||||||
|
case "BAMBOO_WOOD_HANGING_SIGN" -> BlockSoundGroup.BAMBOO_WOOD_HANGING_SIGN;
|
||||||
|
case "BAMBOO_WOOD" -> BlockSoundGroup.BAMBOO_WOOD;
|
||||||
|
case "NETHER_WOOD" -> BlockSoundGroup.NETHER_WOOD;
|
||||||
|
case "CHERRY_WOOD" -> BlockSoundGroup.CHERRY_WOOD;
|
||||||
|
case "CHERRY_SAPLING" -> BlockSoundGroup.CHERRY_SAPLING;
|
||||||
|
case "CHERRY_LEAVES" -> BlockSoundGroup.CHERRY_LEAVES;
|
||||||
|
case "CHERRY_WOOD_HANGING_SIGN" -> BlockSoundGroup.CHERRY_WOOD_HANGING_SIGN;
|
||||||
|
case "CHISELED_BOOKSHELF" -> BlockSoundGroup.CHISELED_BOOKSHELF;
|
||||||
|
case "SUSPICIOUS_SAND" -> BlockSoundGroup.SUSPICIOUS_SAND;
|
||||||
|
case "SUSPICIOUS_GRAVEL" -> BlockSoundGroup.SUSPICIOUS_GRAVEL;
|
||||||
|
case "DECORATED_POT" -> BlockSoundGroup.DECORATED_POT;
|
||||||
|
case "DECORATED_POT_SHATTER" -> BlockSoundGroup.DECORATED_POT_SHATTER;
|
||||||
|
case "TRIAL_SPAWNER" -> BlockSoundGroup.TRIAL_SPAWNER;
|
||||||
|
case "SPONGE" -> BlockSoundGroup.SPONGE;
|
||||||
|
case "WET_SPONGE" -> BlockSoundGroup.WET_SPONGE;
|
||||||
|
case "VAULT" -> BlockSoundGroup.VAULT;
|
||||||
|
case "HEAVY_CORE" -> BlockSoundGroup.HEAVY_CORE;
|
||||||
|
case "COBWEB" -> BlockSoundGroup.COBWEB;
|
||||||
|
default -> {
|
||||||
log(Level.WARN, "Sound group " + s + " not found, using stone");
|
log(Level.WARN, "Sound group " + s + " not found, using stone");
|
||||||
return BlockSoundGroup.STONE;
|
yield BlockSoundGroup.STONE;
|
||||||
}
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private Material getMaterial(String s) {
|
|
||||||
switch (s.toUpperCase()) {
|
|
||||||
case "AIR":
|
|
||||||
return Material.AIR;
|
|
||||||
case "STRUCTURE_VOID":
|
|
||||||
return Material.STRUCTURE_VOID;
|
|
||||||
case "PORTAL":
|
|
||||||
return Material.PORTAL;
|
|
||||||
case "CARPET":
|
|
||||||
return Material.CARPET;
|
|
||||||
case "PLANT":
|
|
||||||
return Material.PLANT;
|
|
||||||
case "UNDERWATER_PLANT":
|
|
||||||
return Material.UNDERWATER_PLANT;
|
|
||||||
case "REPLACEABLE_PLANT":
|
|
||||||
return Material.REPLACEABLE_PLANT;
|
|
||||||
case "SEAGRASS":
|
|
||||||
return Material.SEAGRASS;
|
|
||||||
case "WATER":
|
|
||||||
return Material.WATER;
|
|
||||||
case "BUBBLE_COLUMN":
|
|
||||||
return Material.BUBBLE_COLUMN;
|
|
||||||
case "LAVA":
|
|
||||||
return Material.LAVA;
|
|
||||||
case "SNOW":
|
|
||||||
return Material.SNOW;
|
|
||||||
case "FIRE":
|
|
||||||
return Material.FIRE;
|
|
||||||
case "PART":
|
|
||||||
return Material.PART;
|
|
||||||
case "COBWEB":
|
|
||||||
return Material.COBWEB;
|
|
||||||
case "REDSTONE_LAMP":
|
|
||||||
return Material.REDSTONE_LAMP;
|
|
||||||
case "CLAY":
|
|
||||||
return Material.CLAY;
|
|
||||||
case "EARTH":
|
|
||||||
return Material.EARTH;
|
|
||||||
case "ORGANIC":
|
|
||||||
return Material.ORGANIC;
|
|
||||||
case "PACKED_ICE":
|
|
||||||
return Material.PACKED_ICE;
|
|
||||||
case "SAND":
|
|
||||||
return Material.SAND;
|
|
||||||
case "SPONGE":
|
|
||||||
return Material.SPONGE;
|
|
||||||
case "SHULKER_BOX":
|
|
||||||
return Material.SHULKER_BOX;
|
|
||||||
case "WOOD":
|
|
||||||
return Material.WOOD;
|
|
||||||
case "BAMBOO_SAPLING":
|
|
||||||
return Material.BAMBOO_SAPLING;
|
|
||||||
case "BAMBOO":
|
|
||||||
return Material.BAMBOO;
|
|
||||||
case "WOOL":
|
|
||||||
return Material.WOOL;
|
|
||||||
case "TNT":
|
|
||||||
return Material.TNT;
|
|
||||||
case "LEAVES":
|
|
||||||
return Material.LEAVES;
|
|
||||||
case "GLASS":
|
|
||||||
return Material.GLASS;
|
|
||||||
case "ICE":
|
|
||||||
return Material.ICE;
|
|
||||||
case "CACTUS":
|
|
||||||
return Material.CACTUS;
|
|
||||||
case "STONE":
|
|
||||||
return Material.STONE;
|
|
||||||
case "METAL":
|
|
||||||
return Material.METAL;
|
|
||||||
case "SNOW_BLOCK":
|
|
||||||
return Material.SNOW_BLOCK;
|
|
||||||
case "ANVIL":
|
|
||||||
return Material.ANVIL;
|
|
||||||
case "BARRIER":
|
|
||||||
return Material.BARRIER;
|
|
||||||
case "PISTON":
|
|
||||||
return Material.PISTON;
|
|
||||||
case "UNUSED_PLANT":
|
|
||||||
return Material.UNUSED_PLANT;
|
|
||||||
case "PUMPKIN":
|
|
||||||
return Material.PUMPKIN;
|
|
||||||
case "EGG":
|
|
||||||
return Material.EGG;
|
|
||||||
case "CAKE":
|
|
||||||
return Material.CAKE;
|
|
||||||
default:
|
|
||||||
log(Level.WARN, "Material " + s + " not found, using stone");
|
|
||||||
return Material.STONE;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package quimufu.simple_creator;
|
package quimufu.simple_creator;
|
||||||
|
|
||||||
public class BlockSettingsPojo {
|
public class BlockSettingsPojo {
|
||||||
|
|
||||||
|
public String itemGroup = "minecraft:building_blocks";
|
||||||
public String soundGroup = "stone";
|
public String soundGroup = "stone";
|
||||||
public String dropTableId = null;
|
public String dropTableId = null;
|
||||||
public boolean collidable = true;
|
public boolean collidable = true;
|
||||||
@ -8,8 +10,25 @@ public class BlockSettingsPojo {
|
|||||||
public float explosionResistance = 6.0F;
|
public float explosionResistance = 6.0F;
|
||||||
public float hardness = 1.5F;
|
public float hardness = 1.5F;
|
||||||
public float slipperiness = 0.6F;
|
public float slipperiness = 0.6F;
|
||||||
public float slowDownMultiplier = 1.0F;
|
public float movementVelocityMultiplier = 1.0F;
|
||||||
public float jumpVelocityMultiplier = 1.0F;
|
public float jumpVelocityMultiplier = 1.0F;
|
||||||
public boolean opaque = true;
|
public boolean opaque = true;
|
||||||
String mapColor = "stone";
|
public boolean allowsSpawning = true;
|
||||||
|
public boolean solidBlock = true;
|
||||||
|
public boolean suffocates = true;
|
||||||
|
public boolean blockVision = true;
|
||||||
|
public boolean postProcess = false;
|
||||||
|
public boolean emissiveLighting = false;
|
||||||
|
public String modelOffset = "none";
|
||||||
|
public String pistonBehavior = "normal";
|
||||||
|
public String instrument = "harp";
|
||||||
|
public boolean burnable = false;
|
||||||
|
public int burnChance = -1;
|
||||||
|
public int spreadChance = -1;
|
||||||
|
public boolean replaceable = false;
|
||||||
|
public boolean noBlockBreakParticles = false;
|
||||||
|
public boolean requiresTool = false;
|
||||||
|
public boolean breaksInstantly = false;
|
||||||
|
public String renderLayer = "solid";
|
||||||
|
public String mapColor = "stone";
|
||||||
}
|
}
|
||||||
|
@ -1,31 +1,28 @@
|
|||||||
package quimufu.simple_creator;
|
package quimufu.simple_creator;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import com.google.common.collect.Maps;
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import com.google.gson.JsonParseException;
|
import net.fabricmc.loader.api.FabricLoader;
|
||||||
import me.sargunvohra.mcmods.autoconfig1u.AutoConfig;
|
import net.fabricmc.loader.api.ModContainer;
|
||||||
import net.fabricmc.fabric.impl.resource.loader.ModResourcePackCreator;
|
|
||||||
import net.minecraft.resource.*;
|
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.JsonHelper;
|
|
||||||
import net.minecraft.util.Pair;
|
import net.minecraft.util.Pair;
|
||||||
import org.apache.logging.log4j.Level;
|
import org.apache.logging.log4j.Level;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.file.Files;
|
||||||
import java.util.*;
|
import java.nio.file.Path;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import static quimufu.simple_creator.SimpleCreatorMod.MOD_ID;
|
||||||
import static quimufu.simple_creator.SimpleCreatorMod.log;
|
import static quimufu.simple_creator.SimpleCreatorMod.log;
|
||||||
|
|
||||||
public abstract class GenericManualResourceLoader<T> {
|
public abstract class GenericManualResourceLoader<T> {
|
||||||
private Gson GSON;
|
private final Gson gson;
|
||||||
private String dataType;
|
private final String dataType;
|
||||||
private SimpleCreatorConfig config;
|
|
||||||
|
|
||||||
GenericManualResourceLoader(Gson gson, String dt) {
|
GenericManualResourceLoader(Gson gson, String dt) {
|
||||||
GSON = gson;
|
this.gson = gson;
|
||||||
dataType = dt;
|
dataType = dt;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,66 +46,102 @@ public abstract class GenericManualResourceLoader<T> {
|
|||||||
protected abstract void save(Identifier id, T item);
|
protected abstract void save(Identifier id, T item);
|
||||||
|
|
||||||
public void load() {
|
public void load() {
|
||||||
config = AutoConfig.getConfigHolder(SimpleCreatorConfig.class).getConfig();
|
|
||||||
ResourcePackManager<ResourcePackProfile> resourcePackManager = new ResourcePackManager<>(ResourcePackProfile::new);
|
if (SimpleCreatorConfig.enableTestThings) {
|
||||||
resourcePackManager.registerProvider(new VanillaDataPackProvider());
|
createFromResource("simple_creator/blocks/test_block.json");
|
||||||
resourcePackManager.registerProvider(new FileResourcePackProvider(new File("./datapacks")));
|
createFromResource("simple_creator/items/test_item.json");
|
||||||
if (config.enableTestThings)
|
|
||||||
resourcePackManager.registerProvider(new ModResourcePackCreator(ResourceType.SERVER_DATA));
|
|
||||||
resourcePackManager.scanPacks();
|
|
||||||
List<ResourcePackProfile> ep = Lists.newArrayList(resourcePackManager.getEnabledProfiles());
|
|
||||||
for (ResourcePackProfile rpp : resourcePackManager.getProfiles()) {
|
|
||||||
if (!ep.contains(rpp)) {
|
|
||||||
rpp.getInitialPosition().insert(ep, rpp, resourcePackProfile -> resourcePackProfile, false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
resourcePackManager.setEnabledProfiles(ep);
|
File location = new File("./simplyCreated");
|
||||||
|
|
||||||
|
if (!location.exists() && !location.mkdirs()) {
|
||||||
|
throw new IllegalStateException("Couldn't create dir: " + location);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!location.isDirectory()) {
|
||||||
|
throw new IllegalStateException("Not a dir: " + location);
|
||||||
|
}
|
||||||
|
|
||||||
|
File[] modIds = location.listFiles();
|
||||||
ArrayList<Pair<Identifier, JsonObject>> itemJsonList = new ArrayList<>();
|
ArrayList<Pair<Identifier, JsonObject>> itemJsonList = new ArrayList<>();
|
||||||
HashMap<Identifier, JsonObject> itemJsonMap = Maps.newHashMap();
|
if(modIds == null){
|
||||||
for (ResourcePackProfile rpp : resourcePackManager.getEnabledProfiles()) {
|
log(Level.INFO, "No files found at " + location + " quitting!");
|
||||||
ResourcePack rp = rpp.createResourcePack();
|
return;
|
||||||
log(Level.INFO, "Loading ResourcePack " + rp.getName());
|
}
|
||||||
for (String ns : rp.getNamespaces(ResourceType.SERVER_DATA)) {
|
for (File mod : modIds) {
|
||||||
log(Level.INFO, "Loading namespace " + ns);
|
if (!mod.isDirectory()) {
|
||||||
Collection<Identifier> resources = rp.findResources(ResourceType.SERVER_DATA, ns, dataType, 5, s -> s.endsWith(".json"));
|
continue;
|
||||||
for (Identifier id : resources) {
|
}
|
||||||
if (config.extendedLogging)
|
String modId = mod.getName();
|
||||||
log(Level.INFO, "found: " + id.toString() + " in Pack: " + rp.getName());
|
|
||||||
Identifier idNice = new Identifier(id.getNamespace(), getName(id));
|
File entryDir = new File(mod + "/" + dataType);
|
||||||
try {
|
if (entryDir.isDirectory()) {
|
||||||
InputStream is = rp.open(ResourceType.SERVER_DATA, id);
|
File[] entries = entryDir.listFiles();
|
||||||
Reader r = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8));
|
if(entries == null){
|
||||||
JsonObject jo = JsonHelper.deserialize(GSON, r, JsonObject.class);
|
log(Level.INFO, "No files found at " + entryDir + " skipping!");
|
||||||
if (jo != null)
|
continue;
|
||||||
if (jo.entrySet().isEmpty()) {
|
}
|
||||||
itemJsonMap.remove(idNice);
|
|
||||||
if (config.extendedLogging)
|
for (File entryJson : entries) {
|
||||||
log(Level.INFO, "deleting " + idNice + " because of an empty override in " + rp.getName());
|
String blockJsonName = entryJson.getName();
|
||||||
} else {
|
if(!blockJsonName.endsWith(".json")){
|
||||||
itemJsonMap.put(idNice, jo);
|
log(Level.INFO, "Non json found at " + entryJson + " ignoring!");
|
||||||
if (config.extendedLogging)
|
continue;
|
||||||
log(Level.INFO, "adding " + idNice + " from " + rp.getName());
|
}
|
||||||
}
|
String entryName = blockJsonName.substring(0,blockJsonName.length()-5);
|
||||||
|
Identifier identifier = Identifier.of(modId, entryName);
|
||||||
|
|
||||||
|
try (Reader reader = new FileReader(entryJson)) {
|
||||||
|
JsonObject jsonObject = gson.fromJson(reader, JsonObject.class);
|
||||||
|
itemJsonList.add(new Pair<>(identifier, jsonObject));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log(Level.ERROR, "error loading " + id + " " + e.getMessage());
|
log(Level.INFO, "Could not parse " + entryJson + " ignoring!");
|
||||||
} catch (JsonParseException e) {
|
e.printStackTrace();
|
||||||
log(Level.ERROR, "error parsing json for " + id + " " + e.getMessage());
|
log(Level.INFO, e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (Map.Entry<Identifier, JsonObject> e : itemJsonMap.entrySet()) {
|
|
||||||
itemJsonList.add(new Pair<>(e.getKey(), e.getValue()));
|
|
||||||
}
|
|
||||||
loadItems(itemJsonList);
|
loadItems(itemJsonList);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getName(Identifier id) {
|
private static void createFromResource(String path) {
|
||||||
String path = id.getPath();
|
Optional<ModContainer> modContainerOp = FabricLoader.getInstance().getModContainer(MOD_ID);
|
||||||
int startLength = dataType.length() + 1;
|
if(modContainerOp.isEmpty()){
|
||||||
int endLength = ".json".length();
|
log(Level.ERROR,"ModContainer " + MOD_ID + " not Found" );
|
||||||
return path.substring(startLength, path.length() - endLength);
|
return;
|
||||||
|
}
|
||||||
|
Optional<Path> nioPath = modContainerOp
|
||||||
|
.flatMap(modContainer -> modContainer.findPath("data/" + path));
|
||||||
|
if(nioPath.isEmpty()){
|
||||||
|
log(Level.ERROR,"data/" + path + " Not Found" );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try (InputStream blocks = Files.newInputStream(nioPath.get())) {
|
||||||
|
|
||||||
|
File file = new File("./simplyCreated/" + path);
|
||||||
|
if (!file.exists()) {
|
||||||
|
|
||||||
|
File parent = file.getParentFile();
|
||||||
|
if (parent != null && !parent.exists() && !parent.mkdirs()) {
|
||||||
|
throw new IllegalStateException("Couldn't create dir: " + parent);
|
||||||
|
}
|
||||||
|
if (!file.createNewFile()) {
|
||||||
|
throw new IllegalStateException("Couldn't create file: " + file);
|
||||||
|
}
|
||||||
|
|
||||||
|
try (FileOutputStream out = new FileOutputStream(file)) {
|
||||||
|
//copy stream
|
||||||
|
byte[] buffer = new byte[1024];
|
||||||
|
int bytesRead;
|
||||||
|
while ((bytesRead = blocks.read(buffer)) != -1) {
|
||||||
|
out.write(buffer, 0, bytesRead);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,20 +2,31 @@ package quimufu.simple_creator;
|
|||||||
|
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.google.gson.*;
|
import com.google.gson.*;
|
||||||
|
import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents;
|
||||||
|
import net.minecraft.component.type.ConsumableComponent;
|
||||||
|
import net.minecraft.component.type.ConsumableComponents;
|
||||||
|
import net.minecraft.component.type.FoodComponent;
|
||||||
import net.minecraft.entity.effect.StatusEffect;
|
import net.minecraft.entity.effect.StatusEffect;
|
||||||
import net.minecraft.entity.effect.StatusEffectInstance;
|
import net.minecraft.entity.effect.StatusEffectInstance;
|
||||||
import net.minecraft.item.FoodComponent;
|
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemGroup;
|
import net.minecraft.item.ItemGroup;
|
||||||
|
import net.minecraft.item.ItemGroups;
|
||||||
|
import net.minecraft.item.Items;
|
||||||
|
import net.minecraft.item.consume.ApplyEffectsConsumeEffect;
|
||||||
|
import net.minecraft.registry.Registries;
|
||||||
|
import net.minecraft.registry.Registry;
|
||||||
|
import net.minecraft.registry.RegistryKey;
|
||||||
|
import net.minecraft.registry.entry.RegistryEntry;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.JsonHelper;
|
import net.minecraft.util.JsonHelper;
|
||||||
import net.minecraft.util.Pair;
|
import net.minecraft.util.Pair;
|
||||||
import net.minecraft.util.Rarity;
|
import net.minecraft.util.Rarity;
|
||||||
import net.minecraft.util.registry.Registry;
|
|
||||||
import org.apache.logging.log4j.Level;
|
import org.apache.logging.log4j.Level;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static quimufu.simple_creator.SimpleCreatorMod.log;
|
import static quimufu.simple_creator.SimpleCreatorMod.log;
|
||||||
|
|
||||||
@ -30,13 +41,13 @@ public class ItemResourceLoader extends GenericManualResourceLoader<Item> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void register(Identifier id, Item thing) {
|
protected void register(Identifier id, Item thing) {
|
||||||
Registry.register(Registry.ITEM, id, thing);
|
Registry.register(Registries.ITEM, id, thing);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Item deserialize(Pair<Identifier, JsonObject> e) {
|
public Item deserialize(Pair<Identifier, JsonObject> e) {
|
||||||
JsonObject jo = e.getRight();
|
JsonObject jo = e.getRight();
|
||||||
String group = JsonHelper.getString(jo, "group", "misc");
|
String group = JsonHelper.getString(jo, "group", "misc");
|
||||||
ItemGroup g = findGroup(group);
|
RegistryKey<ItemGroup> g = findGroup(group);
|
||||||
int durability = JsonHelper.getInt(jo, "durability", 0);
|
int durability = JsonHelper.getInt(jo, "durability", 0);
|
||||||
byte stackSize = JsonHelper.getByte(jo, "stackSize", (byte) 1);
|
byte stackSize = JsonHelper.getByte(jo, "stackSize", (byte) 1);
|
||||||
boolean isFood = JsonHelper.hasElement(jo, "food");
|
boolean isFood = JsonHelper.hasElement(jo, "food");
|
||||||
@ -44,7 +55,6 @@ public class ItemResourceLoader extends GenericManualResourceLoader<Item> {
|
|||||||
|
|
||||||
|
|
||||||
Item.Settings settings = new Item.Settings();
|
Item.Settings settings = new Item.Settings();
|
||||||
settings.group(g);
|
|
||||||
if (isFood) {
|
if (isFood) {
|
||||||
if (durability != 0) {
|
if (durability != 0) {
|
||||||
log(Level.WARN, "durability does not work with food");
|
log(Level.WARN, "durability does not work with food");
|
||||||
@ -52,7 +62,7 @@ public class ItemResourceLoader extends GenericManualResourceLoader<Item> {
|
|||||||
}
|
}
|
||||||
settings.maxCount(stackSize);
|
settings.maxCount(stackSize);
|
||||||
JsonObject jsonFoodObject = JsonHelper.getObject(jo, "food");
|
JsonObject jsonFoodObject = JsonHelper.getObject(jo, "food");
|
||||||
settings.food(deserializeFoodComponent(jsonFoodObject));
|
settings.food(deserializeFoodComponent(jsonFoodObject), deserializeEffectComponent(jsonFoodObject));
|
||||||
} else if (durability != 0 && stackSize != 1) {
|
} else if (durability != 0 && stackSize != 1) {
|
||||||
log(Level.WARN, "durability and stackSize do not work together");
|
log(Level.WARN, "durability and stackSize do not work together");
|
||||||
log(Level.WARN, "ignoring stackSize");
|
log(Level.WARN, "ignoring stackSize");
|
||||||
@ -65,7 +75,24 @@ public class ItemResourceLoader extends GenericManualResourceLoader<Item> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
settings.rarity(findRarity(rarity));
|
settings.rarity(findRarity(rarity));
|
||||||
return new Item(settings);
|
settings.registryKey(RegistryKey.of(Registries.ITEM.getKey(), e.getLeft()));
|
||||||
|
|
||||||
|
|
||||||
|
Item item = new Item(settings);
|
||||||
|
ItemGroupEvents.modifyEntriesEvent(g).register(content -> content.add(item));
|
||||||
|
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ConsumableComponent deserializeEffectComponent(JsonObject jo) {
|
||||||
|
ConsumableComponent.Builder ccb = ConsumableComponents.food();
|
||||||
|
if (JsonHelper.getBoolean(jo, "isFast", false))
|
||||||
|
ccb.consumeSeconds(0.8f);
|
||||||
|
if (JsonHelper.hasArray(jo, "effects")) {
|
||||||
|
JsonArray jsonEffectsArray = JsonHelper.getArray(jo, "effects");
|
||||||
|
deserializeEffects(ccb, jsonEffectsArray);
|
||||||
|
}
|
||||||
|
return ccb.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -76,25 +103,17 @@ public class ItemResourceLoader extends GenericManualResourceLoader<Item> {
|
|||||||
private static FoodComponent deserializeFoodComponent(JsonObject jo) {
|
private static FoodComponent deserializeFoodComponent(JsonObject jo) {
|
||||||
FoodComponent fc;
|
FoodComponent fc;
|
||||||
FoodComponent.Builder fcb = new FoodComponent.Builder();
|
FoodComponent.Builder fcb = new FoodComponent.Builder();
|
||||||
fcb.hunger(JsonHelper.getInt(jo, "hunger", 4));
|
fcb.nutrition(JsonHelper.getInt(jo, "hunger", 4));
|
||||||
fcb.saturationModifier(JsonHelper.getFloat(jo, "saturationModifier", 0.3F));
|
fcb.saturationModifier(JsonHelper.getFloat(jo, "saturationModifier", 0.3F));
|
||||||
if (JsonHelper.getBoolean(jo, "isAlwaysEdible", false))
|
if (JsonHelper.getBoolean(jo, "isAlwaysEdible", false))
|
||||||
fcb.alwaysEdible();
|
fcb.alwaysEdible();
|
||||||
if (JsonHelper.getBoolean(jo, "isWolfFood", false))
|
|
||||||
fcb.meat();
|
|
||||||
if (JsonHelper.getBoolean(jo, "isFast", false))
|
|
||||||
fcb.snack();
|
|
||||||
if (JsonHelper.hasArray(jo, "effects")) {
|
|
||||||
JsonArray jsonEffectsArray = JsonHelper.getArray(jo, "effects");
|
|
||||||
deserializeEffects(fcb, jsonEffectsArray);
|
|
||||||
}
|
|
||||||
fc = fcb.build();
|
fc = fcb.build();
|
||||||
return fc;
|
return fc;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void deserializeEffects(FoodComponent.Builder fcb, JsonArray ja) {
|
private static void deserializeEffects(ConsumableComponent.Builder ccb, JsonArray ja) {
|
||||||
for (JsonElement e : ja) {
|
for (JsonElement e : ja) {
|
||||||
StatusEffect type;
|
RegistryEntry<StatusEffect> type;
|
||||||
int duration = 0;
|
int duration = 0;
|
||||||
int amplifier = 0;
|
int amplifier = 0;
|
||||||
boolean ambient = false;
|
boolean ambient = false;
|
||||||
@ -104,9 +123,9 @@ public class ItemResourceLoader extends GenericManualResourceLoader<Item> {
|
|||||||
String effect = JsonHelper.getString(jo, "effect");
|
String effect = JsonHelper.getString(jo, "effect");
|
||||||
Identifier ei = Identifier.tryParse(effect);
|
Identifier ei = Identifier.tryParse(effect);
|
||||||
if (ei != null) {
|
if (ei != null) {
|
||||||
StatusEffect se = Registry.STATUS_EFFECT.get(ei);
|
Optional<RegistryEntry.Reference<StatusEffect>> se = Registries.STATUS_EFFECT.getEntry(ei);
|
||||||
if (se != null) {
|
if (se.isPresent()) {
|
||||||
type = se;
|
type = se.get();
|
||||||
} else {
|
} else {
|
||||||
log(Level.WARN, "Effect " + ei + " not found, skipping");
|
log(Level.WARN, "Effect " + ei + " not found, skipping");
|
||||||
continue;
|
continue;
|
||||||
@ -120,13 +139,13 @@ public class ItemResourceLoader extends GenericManualResourceLoader<Item> {
|
|||||||
ambient = JsonHelper.getBoolean(jo, "ambient", ambient);
|
ambient = JsonHelper.getBoolean(jo, "ambient", ambient);
|
||||||
visible = JsonHelper.getBoolean(jo, "visible", visible);
|
visible = JsonHelper.getBoolean(jo, "visible", visible);
|
||||||
chance = JsonHelper.getFloat(jo, "chance", chance);
|
chance = JsonHelper.getFloat(jo, "chance", chance);
|
||||||
fcb.statusEffect(new StatusEffectInstance(type, duration, amplifier, ambient, visible), chance);
|
ccb.consumeEffect(new ApplyEffectsConsumeEffect(new StatusEffectInstance(type, duration, amplifier, ambient, visible), chance));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Rarity findRarity(String filter) {
|
private static Rarity findRarity(String filter) {
|
||||||
for (Rarity r : Rarity.values()) {
|
for (Rarity r : Rarity.values()) {
|
||||||
if (r.name().toLowerCase().equals(filter.toLowerCase()))
|
if (r.name().equalsIgnoreCase(filter))
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
log(Level.WARN, "Rarity " + filter + " not found, using common");
|
log(Level.WARN, "Rarity " + filter + " not found, using common");
|
||||||
@ -134,15 +153,21 @@ public class ItemResourceLoader extends GenericManualResourceLoader<Item> {
|
|||||||
return Rarity.COMMON;
|
return Rarity.COMMON;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ItemGroup findGroup(String filter) {
|
public static RegistryKey<ItemGroup> findGroup(String filter) {
|
||||||
for (ItemGroup g : ItemGroup.GROUPS) {
|
Identifier identifier = Identifier.tryParse(filter);
|
||||||
if (g.getName().toLowerCase().equals(filter.toLowerCase())) {
|
ItemGroup itemGroup = Registries.ITEM_GROUP.get(identifier);
|
||||||
return g;
|
Optional<RegistryKey<ItemGroup>> optionalRegistryKey = Registries.ITEM_GROUP.getKey(itemGroup);
|
||||||
}
|
if (optionalRegistryKey.isPresent()) {
|
||||||
|
return optionalRegistryKey.get();
|
||||||
}
|
}
|
||||||
log(Level.WARN, "Item Group " + filter + " not found, using misc");
|
log(Level.WARN, "Item Group " + filter + " not found, using minecraft:building_blocks");
|
||||||
log(Level.INFO, "Valid groups:" + Arrays.stream(ItemGroup.GROUPS).map(ItemGroup::getId));
|
|
||||||
return ItemGroup.MISC;
|
log(Level.INFO, "Valid groups:" + Registries.ITEM_GROUP.getKeys()
|
||||||
|
.stream()
|
||||||
|
.map(RegistryKey::getValue)
|
||||||
|
.map(Identifier::toString)
|
||||||
|
.collect(Collectors.joining(",")));
|
||||||
|
return ItemGroups.BUILDING_BLOCKS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
package quimufu.simple_creator;
|
|
||||||
|
|
||||||
import net.minecraft.block.MaterialColor;
|
|
||||||
import net.minecraft.block.piston.PistonBehavior;
|
|
||||||
|
|
||||||
public class MaterialSettingsPojo {
|
|
||||||
String pistonBehavior = "normal";
|
|
||||||
boolean blocksMovement = true;
|
|
||||||
boolean burnable = false;
|
|
||||||
boolean breakByHand = true;
|
|
||||||
boolean liquid = false;
|
|
||||||
boolean replaceable = false;
|
|
||||||
boolean solid = true;
|
|
||||||
boolean blocksLight = true;
|
|
||||||
}
|
|
@ -1,10 +1,12 @@
|
|||||||
package quimufu.simple_creator;
|
package quimufu.simple_creator;
|
||||||
|
|
||||||
import me.sargunvohra.mcmods.autoconfig1u.ConfigData;
|
import eu.midnightdust.lib.config.MidnightConfig;
|
||||||
import me.sargunvohra.mcmods.autoconfig1u.annotation.Config;
|
|
||||||
|
|
||||||
@Config(name = "simple_creator")
|
public class SimpleCreatorConfig extends MidnightConfig {
|
||||||
public class SimpleCreatorConfig implements ConfigData {
|
|
||||||
public boolean enableTestThings = false;
|
@Comment(category = "text")
|
||||||
public boolean extendedLogging = false;
|
public static Comment explanation;
|
||||||
|
|
||||||
|
@Entry(category = "text", name = "Enables included test Blocks and Items")
|
||||||
|
public static boolean enableTestThings = false;
|
||||||
}
|
}
|
||||||
|
@ -1,19 +1,21 @@
|
|||||||
package quimufu.simple_creator;
|
package quimufu.simple_creator;
|
||||||
|
|
||||||
import me.sargunvohra.mcmods.autoconfig1u.AutoConfig;
|
import eu.midnightdust.lib.config.MidnightConfig;
|
||||||
import me.sargunvohra.mcmods.autoconfig1u.ConfigHolder;
|
import net.fabricmc.api.EnvType;
|
||||||
import me.sargunvohra.mcmods.autoconfig1u.serializer.GsonConfigSerializer;
|
|
||||||
import net.fabricmc.api.ModInitializer;
|
import net.fabricmc.api.ModInitializer;
|
||||||
|
import net.fabricmc.loader.api.FabricLoader;
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.util.Pair;
|
||||||
import org.apache.logging.log4j.Level;
|
import org.apache.logging.log4j.Level;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
//import net.minecraft.block.Material;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
//import java.lang.reflect.Field;
|
|
||||||
|
|
||||||
public class SimpleCreatorMod implements ModInitializer {
|
public class SimpleCreatorMod implements ModInitializer {
|
||||||
|
|
||||||
|
public static List<Pair<Block, String>> BLOCKS_RENDER_LAYER = new ArrayList<>();
|
||||||
public static Logger LOGGER = LogManager.getLogger();
|
public static Logger LOGGER = LogManager.getLogger();
|
||||||
public static ItemResourceLoader irl = new ItemResourceLoader();
|
public static ItemResourceLoader irl = new ItemResourceLoader();
|
||||||
public static BlockResourceLoader brl = new BlockResourceLoader();
|
public static BlockResourceLoader brl = new BlockResourceLoader();
|
||||||
@ -23,31 +25,12 @@ public class SimpleCreatorMod implements ModInitializer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInitialize() {
|
public void onInitialize() {
|
||||||
log(Level.INFO, "Initializing");
|
log(Level.INFO, "Simply creating Blocks and Items");
|
||||||
AutoConfig.register(SimpleCreatorConfig.class, GsonConfigSerializer::new);
|
MidnightConfig.init(MOD_ID, SimpleCreatorConfig.class);
|
||||||
// for(Material m : Material.class.getEnumConstants()){
|
|
||||||
// log(Level.INFO, String.valueOf(m.getColor().color));
|
|
||||||
// }
|
|
||||||
// for (Field f : Material.class.getDeclaredFields()) {
|
|
||||||
// log(Level.INFO, f.getName());
|
|
||||||
// try {
|
|
||||||
// Material m = ((Material) f.get(Material.class));
|
|
||||||
// log(Level.INFO, "pistonBehavior: " + m.getPistonBehavior().name());
|
|
||||||
// log(Level.INFO, "blocksMovement: " + m.blocksMovement());
|
|
||||||
// log(Level.INFO, "burnable: " + m.isBurnable());
|
|
||||||
// log(Level.INFO, "breakByHand: " + m.canBreakByHand());
|
|
||||||
// log(Level.INFO, "liquid: " + m.isLiquid());
|
|
||||||
// log(Level.INFO, "replaceable: " + m.isReplaceable());
|
|
||||||
// log(Level.INFO, "solid: " + m.isSolid());
|
|
||||||
// log(Level.INFO, "blocksLight: " + m.blocksLight());
|
|
||||||
// log(Level.INFO, "");
|
|
||||||
// log(Level.INFO, "");
|
|
||||||
//
|
|
||||||
// } catch (IllegalAccessException ignored) {
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
irl.load();
|
irl.load();
|
||||||
brl.load();
|
brl.load();
|
||||||
|
log(Level.INFO, "Simply created!");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void log(Level level, String message) {
|
public static void log(Level level, String message) {
|
||||||
|
@ -0,0 +1,61 @@
|
|||||||
|
package quimufu.simple_creator;
|
||||||
|
|
||||||
|
import net.fabricmc.api.ClientModInitializer;
|
||||||
|
import net.fabricmc.api.EnvType;
|
||||||
|
import net.fabricmc.api.Environment;
|
||||||
|
import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap;
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.client.render.RenderLayer;
|
||||||
|
import net.minecraft.util.Pair;
|
||||||
|
import org.apache.logging.log4j.Level;
|
||||||
|
|
||||||
|
@Environment(EnvType.CLIENT)
|
||||||
|
public class SimpleCreatorModClient implements ClientModInitializer {
|
||||||
|
@Override
|
||||||
|
public void onInitializeClient() {
|
||||||
|
SimpleCreatorMod.log(Level.INFO, "Client init");
|
||||||
|
for (Pair<Block, String> blockRenderLayerPair : SimpleCreatorMod.BLOCKS_RENDER_LAYER) {
|
||||||
|
BlockRenderLayerMap.INSTANCE.putBlock(blockRenderLayerPair.getLeft(), getRenderLayer(blockRenderLayerPair.getRight()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private net.minecraft.client.render.RenderLayer getRenderLayer(String renderLayer) {
|
||||||
|
return switch (renderLayer.toUpperCase()) {
|
||||||
|
case "SOLID" -> RenderLayer.getSolid();
|
||||||
|
case "CUTOUT_MIPPED" -> RenderLayer.getCutoutMipped();
|
||||||
|
case "CUTOUT" -> RenderLayer.getCutout();
|
||||||
|
case "TRANSLUCENT" -> RenderLayer.getTranslucent();
|
||||||
|
case "TRANSLUCENT_MOVING_BLOCK" -> RenderLayer.getTranslucentMovingBlock();
|
||||||
|
case "LEASH" -> RenderLayer.getLeash();
|
||||||
|
case "WATER_MASK" -> RenderLayer.getWaterMask();
|
||||||
|
case "ARMOR_ENTITY_GLINT" -> RenderLayer.getArmorEntityGlint();
|
||||||
|
case "GLINT_TRANSLUCENT" -> RenderLayer.getGlintTranslucent();
|
||||||
|
case "GLINT" -> RenderLayer.getGlint();
|
||||||
|
case "ENTITY_GLINT" -> RenderLayer.getEntityGlint();
|
||||||
|
case "TEXT_BACKGROUND" -> RenderLayer.getTextBackground();
|
||||||
|
case "TEXT_BACKGROUND_SEE_THROUGH" -> RenderLayer.getTextBackgroundSeeThrough();
|
||||||
|
case "LIGHTNING" -> RenderLayer.getLightning();
|
||||||
|
case "DRAGON_RAYS" -> RenderLayer.getDragonRays();
|
||||||
|
case "DRAGON_RAYS_DEPTH" -> RenderLayer.getDragonRaysDepth();
|
||||||
|
case "TRIPWIRE" -> RenderLayer.getTripwire();
|
||||||
|
case "END_PORTAL" -> RenderLayer.getEndPortal();
|
||||||
|
case "END_GATEWAY" -> RenderLayer.getEndGateway();
|
||||||
|
case "FAST_CLOUDS" -> RenderLayer.getFastClouds();
|
||||||
|
case "FANCY_CLOUDS" -> RenderLayer.getFancyClouds();
|
||||||
|
case "LINES" -> RenderLayer.getLines();
|
||||||
|
case "LINE_STRIP" -> RenderLayer.getLineStrip();
|
||||||
|
case "DEBUG_FILLED_BOX" -> RenderLayer.getDebugFilledBox();
|
||||||
|
case "DEBUG_QUADS" -> RenderLayer.getDebugQuads();
|
||||||
|
case "DEBUG_STRUCTURE_QUADS" -> RenderLayer.getDebugStructureQuads();
|
||||||
|
case "DEBUG_SECTION_QUADS" -> RenderLayer.getDebugSectionQuads();
|
||||||
|
case "GUI" -> RenderLayer.getGui();
|
||||||
|
case "GUI_OVERLAY" -> RenderLayer.getGuiOverlay();
|
||||||
|
case "GUI_TEXT_HIGHLIGHT" -> RenderLayer.getGuiTextHighlight();
|
||||||
|
case "GUI_GHOST_RECIPE_OVERLAY" -> RenderLayer.getGuiGhostRecipeOverlay();
|
||||||
|
default -> {
|
||||||
|
SimpleCreatorMod.log(Level.INFO, "Could not find renderLayer " + renderLayer + " using solid");
|
||||||
|
yield RenderLayer.getSolid();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@ -1,24 +0,0 @@
|
|||||||
package quimufu.simple_creator;
|
|
||||||
|
|
||||||
import io.github.prospector.modmenu.api.ConfigScreenFactory;
|
|
||||||
import io.github.prospector.modmenu.api.ModMenuApi;
|
|
||||||
import me.sargunvohra.mcmods.autoconfig1u.AutoConfig;
|
|
||||||
import net.minecraft.client.gui.screen.Screen;
|
|
||||||
|
|
||||||
public class SimpleCreatorModMenuIntegration implements ModMenuApi {
|
|
||||||
@Override
|
|
||||||
public String getModId() {
|
|
||||||
return SimpleCreatorMod.MOD_ID;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ConfigScreenFactory<?> getModConfigScreenFactory() {
|
|
||||||
return this::getScreen;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Screen getScreen(Screen parent) {
|
|
||||||
return AutoConfig.getConfigScreen(SimpleCreatorConfig.class, parent).get();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -0,0 +1,11 @@
|
|||||||
|
package quimufu.simple_creator.mixin;
|
||||||
|
|
||||||
|
import net.minecraft.block.AbstractBlock;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||||
|
|
||||||
|
@Mixin(AbstractBlock.Settings.class)
|
||||||
|
public interface BlockSettingsAccessor {
|
||||||
|
@Accessor
|
||||||
|
void setCollidable(boolean collidable);
|
||||||
|
}
|
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"model": {
|
||||||
|
"type": "minecraft:model",
|
||||||
|
"model": "simple_creator:item/test_block"
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"model": {
|
||||||
|
"type": "minecraft:model",
|
||||||
|
"model": "simple_creator:item/test_item"
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
"text.autoconfig.simple_creator.title": "Simple Item/Block Creator Settings",
|
"simple_creator.midnightconfig.title": "Simple Item/Block Creator Settings",
|
||||||
"text.autoconfig.simple_creator.option.enableTestThings": "Enable a test item and block",
|
"simple_creator.midnightconfig.explanation": "Simple Item/Block Creator Settings",
|
||||||
|
"simple_creator.midnightconfig.enableTestThings": "Enable a test item and block",
|
||||||
"item.simple_creator.test_item": "Forbidden Fruit",
|
"item.simple_creator.test_item": "Forbidden Fruit",
|
||||||
"block.simple_creator.test_block": "Fast jumpy wooly diamond-dropping block of Eternal Fire"
|
"block.simple_creator.test_block": "Fast jumpy wooly diamond-dropping block of Eternal Fire"
|
||||||
}
|
}
|
@ -1,5 +1,4 @@
|
|||||||
{
|
{
|
||||||
"material": "ice",
|
|
||||||
"mapColor": "yellow",
|
"mapColor": "yellow",
|
||||||
"collidable": true,
|
"collidable": true,
|
||||||
"soundGroup": "wool",
|
"soundGroup": "wool",
|
||||||
@ -10,8 +9,23 @@
|
|||||||
"explosionResistance": 5.0,
|
"explosionResistance": 5.0,
|
||||||
"hardness": 0.5,
|
"hardness": 0.5,
|
||||||
"slipperiness": 0.6,
|
"slipperiness": 0.6,
|
||||||
"slowDownMultiplier": 2.0,
|
"movementVelocityMultiplier": 2.0,
|
||||||
"jumpVelocityMultiplier": 2.0,
|
"jumpVelocityMultiplier": 2.0,
|
||||||
"opaque": true,
|
"opaque": true,
|
||||||
"itemGroup": "food"
|
"itemGroup": "minecraft:building_blocks",
|
||||||
|
"allowsSpawning": true,
|
||||||
|
"solidBlock": true,
|
||||||
|
"suffocates": true,
|
||||||
|
"blockVision": true,
|
||||||
|
"postProcess": false,
|
||||||
|
"emissiveLighting": false,
|
||||||
|
"modelOffset": "none",
|
||||||
|
"pistonBehavior": "normal",
|
||||||
|
"instrument": "harp",
|
||||||
|
"burnable": false,
|
||||||
|
"replaceable": false,
|
||||||
|
"noBlockBreakParticles": false,
|
||||||
|
"requiresTool": false,
|
||||||
|
"breaksInstantly": false,
|
||||||
|
"renderLayer": "solid"
|
||||||
}
|
}
|
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"group" :"food",
|
"group" :"minecraft:food_and_drinks",
|
||||||
"durability" : 15,
|
"durability" : 15,
|
||||||
"stackSize": 25,
|
"stackSize": 25,
|
||||||
"rarity" :"rare",
|
"rarity" :"rare",
|
||||||
|
@ -16,15 +16,18 @@
|
|||||||
"main": [
|
"main": [
|
||||||
"quimufu.simple_creator.SimpleCreatorMod"
|
"quimufu.simple_creator.SimpleCreatorMod"
|
||||||
],
|
],
|
||||||
"client": [],
|
"client": [
|
||||||
"server": [],
|
"quimufu.simple_creator.SimpleCreatorModClient"
|
||||||
"modmenu": [
|
],
|
||||||
"quimufu.simple_creator.SimpleCreatorModMenuIntegration"
|
"tweed4:config": [
|
||||||
|
"quimufu.simple_creator.SimpleCreatorConfig"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"mixins": [],
|
"mixins": [
|
||||||
|
"simple_creator.mixins.json"
|
||||||
|
],
|
||||||
"depends": {
|
"depends": {
|
||||||
"fabricloader": ">=0.4.0",
|
"fabricloader": ">=0.14.21",
|
||||||
"fabric": "*"
|
"fabric": "*"
|
||||||
}
|
}
|
||||||
}
|
}
|
14
src/main/resources/simple_creator.mixins.json
Normal file
14
src/main/resources/simple_creator.mixins.json
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"required": true,
|
||||||
|
"minVersion": "0.8",
|
||||||
|
"package": "quimufu.simple_creator.mixin",
|
||||||
|
"compatibilityLevel": "JAVA_17",
|
||||||
|
"mixins": [
|
||||||
|
"BlockSettingsAccessor"
|
||||||
|
],
|
||||||
|
"client": [],
|
||||||
|
"server": [],
|
||||||
|
"injectors": {
|
||||||
|
"defaultRequire": 1
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user