Skip to content

Commit

Permalink
feat: Update to Minecraft 1.21-1.21.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Steveplays28 committed Aug 22, 2024
1 parent a938ea9 commit 506fe76
Show file tree
Hide file tree
Showing 10 changed files with 56 additions and 35 deletions.
6 changes: 5 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//file:noinspection GroovyAccessibility
//file:noinspection GroovyAssignabilityCheck
//file:noinspection DependencyNotationArgument

plugins {
id "architectury-plugin" version "${architectury_plugin_version}"
Expand All @@ -15,7 +16,10 @@ subprojects {

dependencies {
minecraft "com.mojang:minecraft:${rootProject.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
mappings loom.layered {
it.mappings("net.fabricmc:yarn:${project.yarn_mappings}:v2")
it.mappings("dev.architectury:yarn-mappings-patch-neoforge:1.21+build.4")
}
}
}

Expand Down
4 changes: 1 addition & 3 deletions common/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//file:noinspection GroovyAccessibility
//file:noinspection GroovyAssignabilityCheck
//file:noinspection DependencyNotationArgument

def archivesNameCommon = "${rootProject.mod_id}-common"

Expand All @@ -20,9 +21,6 @@ dependencies {
// Do NOT use other classes from fabric loader
modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"

// Mixin Extras
compileOnly(annotationProcessor("io.github.llamalad7:mixinextras-common:${rootProject.mixin_extras_version}"))

// Architectury API
modApi("dev.architectury:architectury:${rootProject.architectury_api_version}") {
exclude group: 'net.fabricmc', module: 'fabric-loader'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import io.github.steveplays28.stevesrealisticsleep.api.StevesRealisticSleepApi;
import io.github.steveplays28.stevesrealisticsleep.extension.ServerWorldExtension;
import io.github.steveplays28.stevesrealisticsleep.mixin.accessor.AbstractCauldronBlockAccessor;
import io.github.steveplays28.stevesrealisticsleep.util.SleepMathUtil;
import net.minecraft.block.*;
import net.minecraft.entity.EntityType;
Expand Down Expand Up @@ -376,7 +377,6 @@ private void tickChunkInject(WorldChunk chunk, int randomTickSpeed, CallbackInfo
var randomPosInChunk = this.getRandomPosInChunk(chunkStartPosX, chunkSectionYOffset, chunkStartPosZ, 15);
var biome = this.getBiome(randomPosInChunk).value();
var precipitation = biome.getPrecipitation(randomPosInChunk);

if (precipitation == Biome.Precipitation.NONE) {
continue;
}
Expand All @@ -385,10 +385,9 @@ private void tickChunkInject(WorldChunk chunk, int randomTickSpeed, CallbackInfo
randomPosInChunk.getY() - chunkSectionYOffset, randomPosInChunk.getZ() - chunkStartPosZ
);
var randomBlockInChunk = randomBlockStateInChunk.getBlock();

if (randomBlockInChunk instanceof AbstractCauldronBlock cauldronBlock) {
cauldronBlock.precipitationTick(randomBlockStateInChunk, this, randomPosInChunk, precipitation);
cauldronBlock.scheduledTick(randomBlockStateInChunk, this.toServerWorld(), randomPosInChunk, random);
((AbstractCauldronBlockAccessor) cauldronBlock).invokeScheduledTick(randomBlockStateInChunk, this.toServerWorld(), randomPosInChunk, random);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package io.github.steveplays28.stevesrealisticsleep.mixin.accessor;

import net.minecraft.block.AbstractCauldronBlock;
import net.minecraft.block.BlockState;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.random.Random;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Invoker;

@Mixin(AbstractCauldronBlock.class)
public interface AbstractCauldronBlockAccessor {
@Invoker
void invokeScheduledTick(BlockState blockState, ServerWorld serverWorld, BlockPos blockPosition, Random random);
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"ServerPlayerEntityMixin",
"ServerWorldMixin",
"SleepManagerMixin",
"accessor.AbstractCauldronBlockAccessor",
"accessor.ServerWorldAccessor"
],
"injectors": {
Expand Down
5 changes: 2 additions & 3 deletions fabric/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//file:noinspection GroovyAccessibility
//file:noinspection GroovyAssignabilityCheck
//file:noinspection DependencyNotationArgument
//file:noinspection DependencyNotationArgument

plugins {
id "com.github.johnrengelman.shadow" version "${shadow_plugin_version}"
Expand Down Expand Up @@ -31,9 +33,6 @@ configurations {
dependencies {
modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"

// Mixin Extras
include(implementation(annotationProcessor("io.github.llamalad7:mixinextras-fabric:${rootProject.mixin_extras_version}")))

// Architectury API
modRuntimeOnly("dev.architectury:architectury-fabric:${rootProject.architectury_api_version}")

Expand Down
27 changes: 13 additions & 14 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ mod_name=Steve's Realistic Sleep
mod_description=Makes sleeping speed up time instead of skipping to day.
mod_license=LGPL-3.0
mod_version=1.10.2
supported_minecraft_version=1.20.4
supported_minecraft_version_name=1.20.4
supported_minecraft_version=>=1.21 <=1.21.1
supported_minecraft_version_name=1.21-1.21.1

# Multiloader properties
architectury_plugin_version=3.4-SNAPSHOT
architectury_loom_version=1.6-SNAPSHOT
architectury_loom_version=1.7-SNAPSHOT
shadow_plugin_version=7.1.2
minecraft_version=1.20.4
java_version=17
minecraft_version=1.21
java_version=21
enabled_platforms=fabric,neoforge

# mc-publish properties
Expand All @@ -30,16 +30,15 @@ modrinth_project_id=KuNKN7d2

# Fabric properties
# Check these on https://modmuss50.me/fabric.html
yarn_mappings=1.20.4+build.3
fabric_loader_version=0.14.25
yarn_mappings=1.21+build.9
fabric_loader_version=0.15.11

# NeoForge properties
neoforge_version=20.4.237
neoforge_version=21.0.167

# Dependencies
mixin_extras_version=0.3.5
architectury_api_version=11.1.17
fabric_api_version=0.97.1+1.20.4
cloth_config_version=13.0.121
mod_menu_version=9.0.0
server_translation_api_version=2.2.0+1.20.3-rc1
architectury_api_version=13.0.6
fabric_api_version=0.100.3+1.21
cloth_config_version=15.0.127
mod_menu_version=11.0.0-beta.2
server_translation_api_version=2.3.1+1.21-pre2
6 changes: 2 additions & 4 deletions neoforge/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//file:noinspection GroovyAccessibility
//file:noinspection GroovyAssignabilityCheck
//file:noinspection DependencyNotationArgument

plugins {
id "com.github.johnrengelman.shadow" version "${shadow_plugin_version}"
Expand Down Expand Up @@ -31,9 +32,6 @@ configurations {
dependencies {
neoForge "net.neoforged:neoforge:${rootProject.neoforge_version}"

// Mixin Extras
implementation(annotationProcessor("io.github.llamalad7:mixinextras-neoforge:${rootProject.mixin_extras_version}"))

// Architectury API
modRuntimeOnly("dev.architectury:architectury-neoforge:${rootProject.architectury_api_version}")

Expand All @@ -47,7 +45,7 @@ dependencies {
processResources {
inputs.property "version", "${project.version}-neoforge"

filesMatching("META-INF/mods.toml") {
filesMatching("META-INF/neoforge.mods.toml") {
expand "version": project.version,
"mod_id": rootProject.mod_id,
"mod_namespace": rootProject.mod_namespace,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,28 @@
package io.github.steveplays28.stevesrealisticsleep.neoforge.event;

import io.github.steveplays28.stevesrealisticsleep.StevesRealisticSleep;
import net.neoforged.bus.api.Event;
import net.minecraft.entity.player.PlayerEntity;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.common.Mod;
import net.neoforged.neoforge.event.entity.player.SleepingTimeCheckEvent;
import net.neoforged.fml.common.EventBusSubscriber;
import net.neoforged.neoforge.event.entity.player.CanPlayerSleepEvent;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import static io.github.steveplays28.stevesrealisticsleep.StevesRealisticSleep.config;

@Mod.EventBusSubscriber(modid = StevesRealisticSleep.MOD_ID)
@EventBusSubscriber(modid = StevesRealisticSleep.MOD_ID)
public class StevesRealisticSleepNeoForgeEventHandler {
@SubscribeEvent
public static void onSleepingTimeCheck(@NotNull SleepingTimeCheckEvent event) {
if (config.allowDaySleeping) {
event.setResult(Event.Result.ALLOW);
public static void onCanPlayerSleep(@NotNull CanPlayerSleepEvent event) {
if (!config.allowDaySleeping) {
return;
}

@Nullable var vanillaProblem = event.getVanillaProblem();
if (vanillaProblem == null || !vanillaProblem.equals(PlayerEntity.SleepFailureReason.NOT_POSSIBLE_NOW)) {
return;
}

event.setProblem(null);
}
}

0 comments on commit 506fe76

Please sign in to comment.