diff --git a/build.gradle b/build.gradle index c2435ba..1797bad 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,6 @@ plugins { id "com.modrinth.minotaur" version "2.+" - id 'fabric-loom' version '1.7-SNAPSHOT' + id 'fabric-loom' version '1.9-SNAPSHOT' id 'maven-publish' } diff --git a/gradle.properties b/gradle.properties index 6de4e42..0aee03f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,16 +1,16 @@ org.gradle.jvmargs = -Xmx1G #Fabric properties -minecraft_version=1.21.1 -yarn_mappings=1.21.1+build.3 -loader_version=0.16.7 +minecraft_version=1.21.4 +yarn_mappings=1.21.4+build.7 +loader_version=0.16.9 # Fabric API -fabric_version=0.105.0+1.21.1 +fabric_version=0.114.0+1.21.4 #Mod properties -mod_version = 0.10.2 +mod_version = 0.10.3 maven_group = quimufu.simple_creator archives_base_name = simple_creator -midnightlib_version=1.6.3-fabric \ No newline at end of file +midnightlib_version=1.6.6-fabric \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index e644113..a4b76b9 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index df97d72..cea7a79 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew b/gradlew index b740cf1..f5feea6 100755 --- a/gradlew +++ b/gradlew @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -84,7 +86,8 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +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. MAX_FD=maximum diff --git a/gradlew.bat b/gradlew.bat index 7101f8e..9b42019 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## diff --git a/src/main/java/quimufu/simple_creator/BlockResourceLoader.java b/src/main/java/quimufu/simple_creator/BlockResourceLoader.java index 24f7274..ddf9ef4 100644 --- a/src/main/java/quimufu/simple_creator/BlockResourceLoader.java +++ b/src/main/java/quimufu/simple_creator/BlockResourceLoader.java @@ -5,7 +5,6 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.JsonObject; import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents; -import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.registry.FlammableBlockRegistry; import net.minecraft.block.AbstractBlock; import net.minecraft.block.Block; @@ -17,6 +16,7 @@ import net.minecraft.entity.EntityType; import net.minecraft.item.BlockItem; import net.minecraft.item.Item; 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; @@ -28,8 +28,10 @@ import net.minecraft.util.Pair; import net.minecraft.util.math.BlockPos; import net.minecraft.world.BlockView; import org.apache.logging.log4j.Level; +import quimufu.simple_creator.mixin.BlockSettingsAccessor; import java.util.Map; +import java.util.Optional; import static quimufu.simple_creator.SimpleCreatorMod.log; @@ -70,9 +72,17 @@ public class BlockResourceLoader extends GenericManualResourceLoader g = ItemResourceLoader.findGroup(group); + + bs.registryKey(RegistryKey.of(Registries.BLOCK.getKey(), e.getLeft())); + //create block and corresponding item Block resB = new Block(bs); - Item resI = new BlockItem(resB, new Item.Settings()); + + Item.Settings is = new Item.Settings(); + is.useBlockPrefixedTranslationKey(); + is.registryKey(RegistryKey.of(Registries.ITEM.getKey(), e.getLeft())); + Item resI = new BlockItem(resB, is); + ItemGroupEvents.modifyEntriesEvent(g).register(content -> content.add(resI)); int burnChance = bspj.burnChance; @@ -86,15 +96,14 @@ public class BlockResourceLoader extends GenericManualResourceLoader bspj.lightLevel); + + ((BlockSettingsAccessor) blockSettings) + .setCollidable(bspj.collidable); + if (bspj.burnable) { - fabricBlockSettings.burnable(); + blockSettings.burnable(); } //not supported for now - //fabricBlockSettings.liquid() + //blockSettings.liquid() if (bspj.solidBlock) { - fabricBlockSettings.solid(); + blockSettings.solid(); } else { - fabricBlockSettings.notSolid(); + blockSettings.notSolid(); } if (bspj.replaceable) { - fabricBlockSettings.replaceable(); + blockSettings.replaceable(); } //not supported for now - //fabricBlockSettings.air() + //blockSettings.air() if (bspj.noBlockBreakParticles) { - fabricBlockSettings.noBlockBreakParticles(); + blockSettings.noBlockBreakParticles(); } if (bspj.requiresTool) { - fabricBlockSettings.requiresTool(); + blockSettings.requiresTool(); } if (bspj.breaksInstantly) { - fabricBlockSettings.breakInstantly(); + blockSettings.breakInstantly(); } if (!bspj.opaque) { - fabricBlockSettings.nonOpaque(); + blockSettings.nonOpaque(); } - return fabricBlockSettings; + return blockSettings; } private NoteBlockInstrument getInstrument(String instrument) { diff --git a/src/main/java/quimufu/simple_creator/ItemResourceLoader.java b/src/main/java/quimufu/simple_creator/ItemResourceLoader.java index 3747dae..19c3357 100644 --- a/src/main/java/quimufu/simple_creator/ItemResourceLoader.java +++ b/src/main/java/quimufu/simple_creator/ItemResourceLoader.java @@ -3,12 +3,16 @@ package quimufu.simple_creator; import com.google.common.collect.Maps; 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.StatusEffectInstance; import net.minecraft.item.Item; 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; @@ -58,7 +62,7 @@ public class ItemResourceLoader extends GenericManualResourceLoader { } settings.maxCount(stackSize); JsonObject jsonFoodObject = JsonHelper.getObject(jo, "food"); - settings.food(deserializeFoodComponent(jsonFoodObject)); + settings.food(deserializeFoodComponent(jsonFoodObject), deserializeEffectComponent(jsonFoodObject)); } else if (durability != 0 && stackSize != 1) { log(Level.WARN, "durability and stackSize do not work together"); log(Level.WARN, "ignoring stackSize"); @@ -71,6 +75,7 @@ public class ItemResourceLoader extends GenericManualResourceLoader { } } settings.rarity(findRarity(rarity)); + settings.registryKey(RegistryKey.of(Registries.ITEM.getKey(), e.getLeft())); Item item = new Item(settings); @@ -79,6 +84,17 @@ public class ItemResourceLoader extends GenericManualResourceLoader { 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 protected void save(Identifier id, Item item) { items.put(id, item); @@ -91,17 +107,11 @@ public class ItemResourceLoader extends GenericManualResourceLoader { fcb.saturationModifier(JsonHelper.getFloat(jo, "saturationModifier", 0.3F)); if (JsonHelper.getBoolean(jo, "isAlwaysEdible", false)) fcb.alwaysEdible(); - 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(); return fc; } - private static void deserializeEffects(FoodComponent.Builder fcb, JsonArray ja) { + private static void deserializeEffects(ConsumableComponent.Builder ccb, JsonArray ja) { for (JsonElement e : ja) { RegistryEntry type; int duration = 0; @@ -129,7 +139,7 @@ public class ItemResourceLoader extends GenericManualResourceLoader { ambient = JsonHelper.getBoolean(jo, "ambient", ambient); visible = JsonHelper.getBoolean(jo, "visible", visible); 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)); } } diff --git a/src/main/java/quimufu/simple_creator/SimpleCreatorModClient.java b/src/main/java/quimufu/simple_creator/SimpleCreatorModClient.java index 85c8aa4..1e82b13 100644 --- a/src/main/java/quimufu/simple_creator/SimpleCreatorModClient.java +++ b/src/main/java/quimufu/simple_creator/SimpleCreatorModClient.java @@ -32,7 +32,6 @@ public class SimpleCreatorModClient implements ClientModInitializer { case "GLINT_TRANSLUCENT" -> RenderLayer.getGlintTranslucent(); case "GLINT" -> RenderLayer.getGlint(); case "ENTITY_GLINT" -> RenderLayer.getEntityGlint(); - case "DIRECT_ENTITY_GLINT" -> RenderLayer.getDirectEntityGlint(); case "TEXT_BACKGROUND" -> RenderLayer.getTextBackground(); case "TEXT_BACKGROUND_SEE_THROUGH" -> RenderLayer.getTextBackgroundSeeThrough(); case "LIGHTNING" -> RenderLayer.getLightning(); diff --git a/src/main/java/quimufu/simple_creator/mixin/BlockSettingsAccessor.java b/src/main/java/quimufu/simple_creator/mixin/BlockSettingsAccessor.java new file mode 100644 index 0000000..a3b0f82 --- /dev/null +++ b/src/main/java/quimufu/simple_creator/mixin/BlockSettingsAccessor.java @@ -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); +} diff --git a/src/main/resources/assets/simple_creator/items/test_block.json b/src/main/resources/assets/simple_creator/items/test_block.json new file mode 100644 index 0000000..c7bbbf6 --- /dev/null +++ b/src/main/resources/assets/simple_creator/items/test_block.json @@ -0,0 +1,6 @@ +{ + "model": { + "type": "minecraft:model", + "model": "simple_creator:item/test_block" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/simple_creator/items/test_item.json b/src/main/resources/assets/simple_creator/items/test_item.json new file mode 100644 index 0000000..e9639a4 --- /dev/null +++ b/src/main/resources/assets/simple_creator/items/test_item.json @@ -0,0 +1,6 @@ +{ + "model": { + "type": "minecraft:model", + "model": "simple_creator:item/test_item" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/simple_creator/lang/en_us.json b/src/main/resources/assets/simple_creator/lang/en_us.json index 3093e84..e1916b5 100644 --- a/src/main/resources/assets/simple_creator/lang/en_us.json +++ b/src/main/resources/assets/simple_creator/lang/en_us.json @@ -1,5 +1,6 @@ { "simple_creator.midnightconfig.title": "Simple Item/Block Creator Settings", + "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", "block.simple_creator.test_block": "Fast jumpy wooly diamond-dropping block of Eternal Fire" diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 32ada9d..14c44ba 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -23,7 +23,9 @@ "quimufu.simple_creator.SimpleCreatorConfig" ] }, - "mixins": [], + "mixins": [ + "simple_creator.mixins.json" + ], "depends": { "fabricloader": ">=0.14.21", "fabric": "*" diff --git a/src/main/resources/simple_creator.mixins.json b/src/main/resources/simple_creator.mixins.json new file mode 100644 index 0000000..5e687b0 --- /dev/null +++ b/src/main/resources/simple_creator.mixins.json @@ -0,0 +1,14 @@ +{ + "required": true, + "minVersion": "0.8", + "package": "quimufu.simple_creator.mixin", + "compatibilityLevel": "JAVA_17", + "mixins": [ + "BlockSettingsAccessor" + ], + "client": [], + "server": [], + "injectors": { + "defaultRequire": 1 + } +} \ No newline at end of file