diff --git a/.gitignore b/.gitignore index 31d2550..fbed340 100644 --- a/.gitignore +++ b/.gitignore @@ -23,4 +23,5 @@ run runs run-data -repo \ No newline at end of file +repo +neoforge/src/generated/ diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index d64cd49..e644113 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 a80b22c..b82aa23 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.6-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/neoforge/build.gradle.kts b/neoforge/build.gradle.kts index 51f7719..a0eb740 100644 --- a/neoforge/build.gradle.kts +++ b/neoforge/build.gradle.kts @@ -17,7 +17,7 @@ plugins { id("eclipse") id("maven-publish") id("java-library") - id("net.neoforged.gradle.userdev") version ("7.0.93") + id("net.neoforged.gradle.userdev") version ("7.0.119") id("org.ajoberstar.grgit") version ("5.2.1") } @@ -28,7 +28,7 @@ base { } java { - toolchain.languageVersion.set(JavaLanguageVersion.of(17)) + toolchain.languageVersion.set(JavaLanguageVersion.of(21)) } jarJar.enable() @@ -70,7 +70,7 @@ runs { if (!System.getenv().containsKey("CI")) { // JetBrains Runtime Hotswap - jvmArgument("-XX:+AllowEnhancedClassRedefinition") + // jvmArgument("-XX:+AllowEnhancedClassRedefinition") } modSource(sourceSets.main.get()) @@ -193,7 +193,7 @@ tasks.withType().configureEach { ) inputs.properties(replaceProperties) - filesMatching("META-INF/mods.toml") { + filesMatching("META-INF/neoforge.mods.toml") { expand(replaceProperties) } } diff --git a/neoforge/gradle.properties b/neoforge/gradle.properties index 8358ff5..ec4209b 100644 --- a/neoforge/gradle.properties +++ b/neoforge/gradle.properties @@ -1,11 +1,11 @@ #read more on this at https://github.com/neoforged/NeoGradle/blob/NG_7.0/README.md#apply-parchment-mappings # you can also find the latest versions at: https://parchmentmc.org/docs/getting-started -neogradle.subsystems.parchment.minecraftVersion=1.20.3 -neogradle.subsystems.parchment.mappingsVersion=2023.12.31 +neogradle.subsystems.parchment.minecraftVersion=1.20.6 +neogradle.subsystems.parchment.mappingsVersion=2024.05.01 # Environment Properties -minecraft_version_range=[1.20.4,1.21) -neo_version_range=[20.4,) +minecraft_version_range=[1.20.6,1.21) +neo_version_range=[20.6,) loader_version_range=[2,) ## Mod Properties diff --git a/neoforge/src/generated/resources/.cache/07bf9105638f118a7f833ea78d65af55a26a2848 b/neoforge/src/generated/resources/.cache/07bf9105638f118a7f833ea78d65af55a26a2848 deleted file mode 100644 index e0b4ebb..0000000 --- a/neoforge/src/generated/resources/.cache/07bf9105638f118a7f833ea78d65af55a26a2848 +++ /dev/null @@ -1,2 +0,0 @@ -// 1.20.4 2024-04-01T00:42:40.29185 Item Models: simplehoney -038e9a47f1a09f5e4eb8657ee72239569b0175d6 assets/simplehoney/models/item/honey_drop.json diff --git a/neoforge/src/generated/resources/.cache/17cbc9f360411514ea3e53ea0c2e91ccd52e9704 b/neoforge/src/generated/resources/.cache/17cbc9f360411514ea3e53ea0c2e91ccd52e9704 deleted file mode 100644 index b1c15a0..0000000 --- a/neoforge/src/generated/resources/.cache/17cbc9f360411514ea3e53ea0c2e91ccd52e9704 +++ /dev/null @@ -1,2 +0,0 @@ -// 1.20.4 2024-04-01T00:42:40.2928558 Languages: en_us for mod: simplehoney -97d62e7f265af4a4861a9c0806478508824df9b0 assets/simplehoney/lang/en_us.json diff --git a/neoforge/src/generated/resources/.cache/9fb1092f32d4fcbf9e061ffd718d4ec689c6c95e b/neoforge/src/generated/resources/.cache/9fb1092f32d4fcbf9e061ffd718d4ec689c6c95e deleted file mode 100644 index 94489cf..0000000 --- a/neoforge/src/generated/resources/.cache/9fb1092f32d4fcbf9e061ffd718d4ec689c6c95e +++ /dev/null @@ -1,3 +0,0 @@ -// 1.20.4 2024-04-01T00:42:40.2893418 Recipes -6a792a076c18aaa2412204d89346841ac765694e data/minecraft/advancements/recipes/food/honey_bottle.json -c44e3da0bc22b46e9a2a87d586825c1534984f4f data/minecraft/recipes/honey_bottle.json diff --git a/neoforge/src/generated/resources/assets/simplehoney/lang/en_us.json b/neoforge/src/generated/resources/assets/simplehoney/lang/en_us.json deleted file mode 100644 index d21d5ea..0000000 --- a/neoforge/src/generated/resources/assets/simplehoney/lang/en_us.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "item.simplehoney.honey_drop": "Honey Drop" -} \ No newline at end of file diff --git a/neoforge/src/generated/resources/assets/simplehoney/models/item/honey_drop.json b/neoforge/src/generated/resources/assets/simplehoney/models/item/honey_drop.json deleted file mode 100644 index fd2b560..0000000 --- a/neoforge/src/generated/resources/assets/simplehoney/models/item/honey_drop.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "parent": "minecraft:item/generated", - "textures": { - "layer0": "simplehoney:item/honey_drop" - } -} \ No newline at end of file diff --git a/neoforge/src/generated/resources/data/minecraft/advancements/recipes/food/honey_bottle.json b/neoforge/src/generated/resources/data/minecraft/advancements/recipes/food/honey_bottle.json deleted file mode 100644 index 04308fa..0000000 --- a/neoforge/src/generated/resources/data/minecraft/advancements/recipes/food/honey_bottle.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "parent": "minecraft:recipes/root", - "criteria": { - "has_the_recipe": { - "conditions": { - "recipe": "minecraft:honey_bottle" - }, - "trigger": "minecraft:recipe_unlocked" - }, - "honey_drop": { - "conditions": { - "items": [ - { - "items": [ - "simplehoney:honey_drop" - ] - } - ] - }, - "trigger": "minecraft:inventory_changed" - } - }, - "requirements": [ - [ - "has_the_recipe", - "honey_drop" - ] - ], - "rewards": { - "recipes": [ - "minecraft:honey_bottle" - ] - } -} \ No newline at end of file diff --git a/neoforge/src/generated/resources/data/minecraft/recipes/honey_bottle.json b/neoforge/src/generated/resources/data/minecraft/recipes/honey_bottle.json deleted file mode 100644 index b588667..0000000 --- a/neoforge/src/generated/resources/data/minecraft/recipes/honey_bottle.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "type": "minecraft:crafting_shapeless", - "category": "misc", - "ingredients": [ - { - "item": "simplehoney:honey_drop" - }, - { - "item": "minecraft:glass_bottle" - } - ], - "result": { - "item": "minecraft:honey_bottle" - } -} \ No newline at end of file diff --git a/neoforge/src/main/java/dev/compactmods/simplehoney/SimpleHoney.java b/neoforge/src/main/java/dev/compactmods/simplehoney/SimpleHoney.java index c9d7c1b..22ec495 100644 --- a/neoforge/src/main/java/dev/compactmods/simplehoney/SimpleHoney.java +++ b/neoforge/src/main/java/dev/compactmods/simplehoney/SimpleHoney.java @@ -1,21 +1,35 @@ package dev.compactmods.simplehoney; +import cpw.mods.modlauncher.Environment; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.util.Tuple; +import net.minecraft.world.entity.player.Player; import net.minecraft.world.food.FoodProperties; import net.minecraft.world.item.Item; +import net.minecraft.world.item.Items; import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.BeehiveBlock; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.entity.BeehiveBlockEntity; import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.entity.FurnaceBlockEntity; import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.phys.AABB; +import net.neoforged.bus.EventBus; +import net.neoforged.bus.api.Event; import net.neoforged.bus.api.IEventBus; import net.neoforged.fml.common.Mod; +import net.neoforged.fml.loading.FMLEnvironment; import net.neoforged.neoforge.capabilities.Capabilities; import net.neoforged.neoforge.capabilities.RegisterCapabilitiesEvent; +import net.neoforged.neoforge.common.NeoForge; +import net.neoforged.neoforge.common.Tags; +import net.neoforged.neoforge.event.tick.LevelTickEvent; import net.neoforged.neoforge.items.IItemHandler; import net.neoforged.neoforge.registries.DeferredItem; import net.neoforged.neoforge.registries.DeferredRegister; +import org.jetbrains.annotations.NotNull; @Mod(SimpleHoney.MOD_ID) public class SimpleHoney { @@ -24,9 +38,9 @@ public class SimpleHoney { private static final DeferredRegister.Items ITEMS = DeferredRegister.createItems(MOD_ID); public static final FoodProperties HONEY_DROP_FOOD_PROPS = new FoodProperties.Builder() - .alwaysEat() + .alwaysEdible() .nutrition(2) - .saturationMod(0.1f) + .saturationModifier(0.1f) .build(); public static final Item.Properties HONEY_DROP_ITEM_PROPS = new Item.Properties() @@ -37,6 +51,33 @@ public class SimpleHoney { public SimpleHoney(IEventBus modEventBus) { ITEMS.register(modEventBus); modEventBus.addListener(this::registerCaps); + + // NeoForge.EVENT_BUS.addListener(this::debugTickListener); + } + + private void debugTickListener(LevelTickEvent.Pre event) { + final var level = event.getLevel(); + + if(level.tickRateManager().runsNormally() && level.getGameTime() % 10 == 0) { + final var allPlayers = level.players(); + allPlayers.stream() + .filter(player -> player.isCreative() && player.getMainHandItem().is(HONEY_DROP)) + .forEach(this::tickNearbyHives); + } + } + + + private void tickNearbyHives(Player player) { + final var level = player.level(); + final var nearbyStates = BlockPos.betweenClosedStream(AABB.ofSize(player.position(), 10, 10, 10)); + nearbyStates + .map(pos -> new Tuple<>(pos, level.getBlockState(pos))) + .filter(posAndState -> posAndState.getB().is(Blocks.BEEHIVE) || posAndState.getB().is(Blocks.BEE_NEST)) + .filter(posAndHive -> posAndHive.getB().getValue(BeehiveBlock.HONEY_LEVEL) < BeehiveBlock.MAX_HONEY_LEVELS) + .forEach(posAndHive -> { + var newState = posAndHive.getB().setValue(BeehiveBlock.HONEY_LEVEL, posAndHive.getB().getValue(BeehiveBlock.HONEY_LEVEL) + 1); + level.setBlock(posAndHive.getA(), newState, BeehiveBlock.UPDATE_ALL); + }); } private void registerCaps(final RegisterCapabilitiesEvent event) { diff --git a/neoforge/src/main/java/dev/compactmods/simplehoney/datagen/DataGeneration.java b/neoforge/src/main/java/dev/compactmods/simplehoney/datagen/DataGeneration.java index 9b9ee67..be9f40f 100644 --- a/neoforge/src/main/java/dev/compactmods/simplehoney/datagen/DataGeneration.java +++ b/neoforge/src/main/java/dev/compactmods/simplehoney/datagen/DataGeneration.java @@ -3,10 +3,10 @@ import dev.compactmods.simplehoney.SimpleHoney; import dev.compactmods.simplehoney.datagen.lang.EnglishLangGenerator; import net.neoforged.bus.api.SubscribeEvent; -import net.neoforged.fml.common.Mod; +import net.neoforged.fml.common.EventBusSubscriber; import net.neoforged.neoforge.data.event.GatherDataEvent; -@Mod.EventBusSubscriber(modid = SimpleHoney.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD) +@EventBusSubscriber(modid = SimpleHoney.MOD_ID, bus = EventBusSubscriber.Bus.MOD) public class DataGeneration { @SubscribeEvent @@ -18,7 +18,7 @@ public static void gatherData(GatherDataEvent event) { // Server boolean server = event.includeServer(); - generator.addProvider(server, new RecipeGenerator(packOut)); + generator.addProvider(server, new RecipeGenerator(packOut, event.getLookupProvider())); // Client boolean client = event.includeClient(); diff --git a/neoforge/src/main/java/dev/compactmods/simplehoney/datagen/RecipeGenerator.java b/neoforge/src/main/java/dev/compactmods/simplehoney/datagen/RecipeGenerator.java index 618a83b..86feb2f 100644 --- a/neoforge/src/main/java/dev/compactmods/simplehoney/datagen/RecipeGenerator.java +++ b/neoforge/src/main/java/dev/compactmods/simplehoney/datagen/RecipeGenerator.java @@ -1,6 +1,7 @@ package dev.compactmods.simplehoney.datagen; import dev.compactmods.simplehoney.SimpleHoney; +import net.minecraft.core.HolderLookup; import net.minecraft.data.PackOutput; import net.minecraft.data.recipes.RecipeCategory; import net.minecraft.data.recipes.RecipeOutput; @@ -10,10 +11,12 @@ import net.minecraft.world.item.Items; import org.jetbrains.annotations.NotNull; +import java.util.concurrent.CompletableFuture; + public class RecipeGenerator extends RecipeProvider { - public RecipeGenerator(PackOutput packOutput) { - super(packOutput); + public RecipeGenerator(PackOutput packOutput, CompletableFuture holder) { + super(packOutput, holder); } @Override @@ -23,5 +26,10 @@ protected void buildRecipes(@NotNull RecipeOutput recipeOutput) { .requires(Items.GLASS_BOTTLE) .unlockedBy("honey_drop", has(SimpleHoney.HONEY_DROP)) .save(recipeOutput); + + ShapelessRecipeBuilder.shapeless(RecipeCategory.FOOD, new ItemStack(Items.HONEYCOMB)) + .requires(SimpleHoney.HONEY_DROP) + .unlockedBy("honey_drop", has(SimpleHoney.HONEY_DROP)) + .save(recipeOutput); } } diff --git a/neoforge/src/main/resources/META-INF/mods.toml b/neoforge/src/main/resources/META-INF/mods.toml deleted file mode 100644 index 587cef0..0000000 --- a/neoforge/src/main/resources/META-INF/mods.toml +++ /dev/null @@ -1,100 +0,0 @@ -# This is an example mods.toml file. It contains the data relating to the loading mods. -# There are several mandatory fields (#mandatory), and many more that are optional (#optional). -# The overall format is standard TOML format, v0.5.0. -# Note that there are a couple of TOML lists in this file. -# Find more information on toml format here: https://github.com/toml-lang/toml -# The name of the mod loader type to load - for regular FML @Mod mods it should be javafml -modLoader="javafml" #mandatory - -# A version range to match for said mod loader - for regular FML @Mod it will be the the FML version. This is currently 47. -loaderVersion="${loader_version_range}" #mandatory - -# The license for you mod. This is mandatory metadata and allows for easier comprehension of your redistributive properties. -# Review your options at https://choosealicense.com/. All rights reserved is the default copyright stance, and is thus the default here. -license="${mod_license}" - -# A URL to refer people to when problems occur with this mod -#issueTrackerURL="https://change.me.to.your.issue.tracker.example.invalid/" #optional - -# A list of mods - how many allowed here is determined by the individual mod loader -[[mods]] #mandatory - -# The modid of the mod -modId="${mod_id}" #mandatory - -# The version number of the mod -version="${mod_version}" #mandatory - -# A display name for the mod -displayName="${mod_name}" #mandatory - -# A URL to query for updates for this mod. See the JSON update specification https://docs.neoforged.net/docs/misc/updatechecker/ -#updateJSONURL="https://change.me.example.invalid/updates.json" #optional - -# A URL for the "homepage" for this mod, displayed in the mod UI -#displayURL="https://change.me.to.your.mods.homepage.example.invalid/" #optional - -# A file name (in the root of the mod JAR) containing a logo for display -#logoFile="examplemod.png" #optional - -# A text field displayed in the mod UI -#credits="" #optional - -# A text field displayed in the mod UI -authors="${mod_authors}" #optional - -# Display Test controls the display for your mod in the server connection screen -# MATCH_VERSION means that your mod will cause a red X if the versions on client and server differ. This is the default behaviour and should be what you choose if you have server and client elements to your mod. -# IGNORE_SERVER_VERSION means that your mod will not cause a red X if it's present on the server but not on the client. This is what you should use if you're a server only mod. -# IGNORE_ALL_VERSION means that your mod will not cause a red X if it's present on the client or the server. This is a special case and should only be used if your mod has no server component. -# NONE means that no display test is set on your mod. You need to do this yourself, see IExtensionPoint.DisplayTest for more information. You can define any scheme you wish with this value. -# IMPORTANT NOTE: this is NOT an instruction as to which environments (CLIENT or DEDICATED SERVER) your mod loads on. Your mod should load (and maybe do nothing!) whereever it finds itself. -#displayTest="MATCH_VERSION" # MATCH_VERSION is the default if nothing is specified (#optional) - -# The description text for the mod (multi line!) (#mandatory) -description='''${mod_description}''' - -# The [[mixins]] block allows you to declare your mixin config to FML so that it gets loaded. -#[[mixins]] -#config="${mod_id}.mixins.json" - -# The [[accessTransformers]] block allows you to declare where your AT file is. -# If this block is omitted, a fallback attempt will be made to load an AT from META-INF/accesstransformer.cfg -#[[accessTransformers]] -#file="META-INF/accesstransformer.cfg" - -# The coremods config file path is not configurable and is always loaded from META-INF/coremods.json - -# A dependency - use the . to indicate dependency for a specific modid. Dependencies are optional. -[[dependencies.${mod_id}]] #optional - # the modid of the dependency - modId="neoforge" #mandatory - # The type of the dependency. Can be one of "required", "optional", "incompatible" or "discouraged" (case insensitive). - # 'required' requires the mod to exist, 'optional' does not - # 'incompatible' will prevent the game from loading when the mod exists, and 'discouraged' will show a warning - type="required" #mandatory - # Optional field describing why the dependency is required or why it is incompatible - # reason="..." - # The version range of the dependency - versionRange="${neo_version_range}" #mandatory - # An ordering relationship for the dependency. - # BEFORE - This mod is loaded BEFORE the dependency - # AFTER - This mod is loaded AFTER the dependency - ordering="NONE" - # Side this dependency is applied on - BOTH, CLIENT, or SERVER - side="BOTH" - -# Here's another dependency -[[dependencies.${mod_id}]] - modId="minecraft" - type="required" - # This version range declares a minimum of the current minecraft version up to but not including the next major version - versionRange="${minecraft_version_range}" - ordering="NONE" - side="BOTH" - -# Features are specific properties of the game environment, that you may want to declare you require. This example declares -# that your mod requires GL version 3.2 or higher. Other features will be added. They are side aware so declaring this won't -# stop your mod loading on the server for example. -#[features.${mod_id}] -#openGLVersion="[3.2,)" diff --git a/neoforge/src/main/resources/META-INF/neoforge.mods.toml b/neoforge/src/main/resources/META-INF/neoforge.mods.toml new file mode 100644 index 0000000..6a3fc0b --- /dev/null +++ b/neoforge/src/main/resources/META-INF/neoforge.mods.toml @@ -0,0 +1,24 @@ +modLoader = "javafml" #mandatory +loaderVersion = "${loader_version_range}" +license = "${mod_license}" + +[[mods]] +modId = "simplehoney" +version = "${mod_version}" +displayName = "${mod_name}" +authors = "${mod_authors}" +description = '''${mod_description}''' + +[[dependencies.simplehoney]] +modId = "neoforge" +type = "required" +versionRange = "${neo_version_range}" +ordering = "NONE" +side = "BOTH" + +[[dependencies.simplehoney]] +modId = "minecraft" +type = "required" +versionRange = "${minecraft_version_range}" +ordering = "NONE" +side = "BOTH" diff --git a/settings.gradle.kts b/settings.gradle.kts index 56d08e1..1d578d0 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -3,8 +3,8 @@ dependencyResolutionManagement { library("neoforge", "net.neoforged", "neoforge") .versionRef("neoforge") - version("minecraft", "1.20.4") - version("neoforge", "20.4.216") + version("minecraft", "1.20.6") + version("neoforge", "20.6.57-beta") } versionCatalogs.create("mods") {