Skip to content

Commit

Permalink
Port to MC 20.6
Browse files Browse the repository at this point in the history
  • Loading branch information
robotgryphon committed May 11, 2024
1 parent 446c6b5 commit ff909ec
Show file tree
Hide file tree
Showing 18 changed files with 93 additions and 184 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ run
runs
run-data

repo
repo
neoforge/src/generated/
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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
Expand Down
8 changes: 4 additions & 4 deletions neoforge/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}

Expand All @@ -28,7 +28,7 @@ base {
}

java {
toolchain.languageVersion.set(JavaLanguageVersion.of(17))
toolchain.languageVersion.set(JavaLanguageVersion.of(21))
}

jarJar.enable()
Expand Down Expand Up @@ -70,7 +70,7 @@ runs {

if (!System.getenv().containsKey("CI")) {
// JetBrains Runtime Hotswap
jvmArgument("-XX:+AllowEnhancedClassRedefinition")
// jvmArgument("-XX:+AllowEnhancedClassRedefinition")
}

modSource(sourceSets.main.get())
Expand Down Expand Up @@ -193,7 +193,7 @@ tasks.withType<ProcessResources>().configureEach {
)

inputs.properties(replaceProperties)
filesMatching("META-INF/mods.toml") {
filesMatching("META-INF/neoforge.mods.toml") {
expand(replaceProperties)
}
}
Expand Down
8 changes: 4 additions & 4 deletions neoforge/gradle.properties
Original file line number Diff line number Diff line change
@@ -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
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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()
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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<HolderLookup.Provider> holder) {
super(packOutput, holder);
}

@Override
Expand All @@ -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);
}
}
100 changes: 0 additions & 100 deletions neoforge/src/main/resources/META-INF/mods.toml

This file was deleted.

Loading

0 comments on commit ff909ec

Please sign in to comment.