Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,75 @@ forge:
modApi "dev.tocraft:craftedcore-forge:1.20.2-2.0"
```

## Building and installing locally

This fork targets **Minecraft 26.1.2** and publishes to Maven Local (`~/.m2`).

**Requirements:** JDK 21+, internet access for the first Gradle run (downloads MC assets).

```bash
# Compile and publish all three artifacts (common, fabric, neoforge) to ~/.m2
./gradlew publishToMavenLocal
```

To use the locally published artifacts in a dependent mod, add `mavenLocal()` to its repository list before any remote repos:

```kotlin
repositories {
mavenLocal()
// ... other repos
}
```

Then depend on the artifacts as normal:

```kotlin
// common
modApi("dev.tocraft:craftedcore:8.0")
// fabric
modApi("dev.tocraft:craftedcore-fabric:8.0")
// neoforge
modApi("dev.tocraft:craftedcore-neoforge:8.0")
```

To launch the Fabric test client:

```bash
./gradlew :fabric:runClient
```

## Fork notes (MC 26.1.2)

This is a fork of [ToCraft/craftedcore](https://github.com/ToCraft/craftedcore) updated to be compatible with **Minecraft Java Edition 26.1.2**, the first unobfuscated MC release (April 2026). The upstream library targets 1.21.x and below.

### What changed

**Minecraft API renames (global)**
- `net.minecraft.resources.ResourceLocation` → `net.minecraft.resources.Identifier`
- `net.minecraft.client.gui.GuiGraphics` → `net.minecraft.client.gui.GuiGraphicsExtractor`
- `GuiGraphics.renderItem()` → `GuiGraphicsExtractor.item()`
- `AbstractScrollArea` constructor requires a `ScrollbarSettings` argument; use `AbstractScrollArea.defaultSettings(width)`
- `MultiLineTextWidget.setColor()` removed; apply via `Component.copy().withStyle(s -> s.withColor(TextColor.fromRgb(...)))`
- `ServerLevel.getDayTime()` → `ServerLevel.getOverworldClockTime()`
- `player.hasPermissions(int)` → `player.permissions().hasPermission(Permissions.COMMANDS_GAMEMASTER)`
- `Player.interactOn(Entity, InteractionHand)` gained a `Vec3` parameter
- `MultiPlayerGameMode.interact(Player, Entity, InteractionHand)` gained an `EntityHitResult` parameter
- `Minecraft.disconnect(Screen, boolean)` now delegates to a new 3-param overload; the actual disconnect logic (including the `GameNarrator.clear()` call site) moved to `disconnect(Screen, boolean, boolean)`

**Fabric API renames (fabric-api 0.147.0+26.1.2)**
- `KeyBindingHelper` / `registerKeyBinding` → `KeyMappingHelper` / `registerKeyMapping` (package `keymapping.v1`)
- `ResourceLoader.registerReloader` → `registerReloadListener`
- `HudRenderCallback` removed; replaced by `HudElementRegistry.addLast(id, HudElement)` with `extractRenderState(GuiGraphicsExtractor, DeltaTracker)` method
- `ServerWorldEvents` → `ServerLevelEvents` (now matches craftedcore's own class name; use FQN to disambiguate)
- `EntitySleepEvents.ALLOW_SLEEP_TIME` removed; replaced by `ALLOW_SLEEPING` with `(Player, BlockPos) → BedSleepingProblem` callback (return `null` to allow, `OTHER_PROBLEM` to deny)
- `PayloadTypeRegistry.playC2S()` / `playS2C()` → `serverboundPlay()` / `clientboundPlay()`
- `FabricRegistryBuilder.createSimple` → `FabricRegistryBuilder.create`

**NeoForge API renames**
- `SleepFinishedTimeEvent.getNewTime()` / `setTimeAddition(long)` removed; replaced by `getAdjustment()` / `setAdjustment(ClockAdjustment)`. Use `new ClockAdjustment.Absolute(time)` — `ClockAdjustment` is not a functional interface so lambdas do not work.

**Build**
- Added `maven-publish` plugin to all subprojects for `publishToMavenLocal` support
- `processResources` `expand()` blocks: capture `project.property(...)` into local vals before the `filesMatching` block (inside the block `this` is `FileCopyDetails`, not `Project`)
- Added `compileOnly("net.fabricmc:fabric-loader:...")` to the neoforge subproject so common `@Environment(EnvType.CLIENT)` annotations compile

20 changes: 10 additions & 10 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
plugins {
id("dev.tocraft.modmaster.root") version ("single-1.10.1")
id("dev.tocraft.modmaster.root") version ("2.1")
}

val clothConfigVersion: String? = properties["cloth_config_version"] as String

ext {
val modMeta = mutableMapOf<String, Any>()
modMeta["minecraft"] = project.properties["minecraft"] as String
modMeta["version"] = version
if (clothConfigVersion != null) {
modMeta["clothConfig"] = clothConfigVersion
subprojects {
repositories {
maven("https://maven.fabricmc.net/") // fabric api
maven("https://maven.terraformersmc.com/releases/") // mod menu mod
maven("https://maven.shedaniel.me/") // cloth config
maven {
name = "Minecraft Libraries"
url = uri("https://libraries.minecraft.net")
}
}
set("mod_meta", modMeta)
}
19 changes: 8 additions & 11 deletions common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,15 @@ plugins {
id("dev.tocraft.modmaster.common")
}

val clothConfigVersion: String = parent!!.properties["cloth_config_version"] as String

repositories {
maven("https://maven.terraformersmc.com/releases/")
maven("https://maven.shedaniel.me/")
}
val clothConfigVersion: String? = parent!!.properties["cloth_config_version"] as String?

dependencies {
// mixin extras
implementation(annotationProcessor("io.github.llamalad7:mixinextras-common:${rootProject.properties["mixinextras_version"]}")!!)
// Cloth Config
modCompileOnly("me.shedaniel.cloth:cloth-config:${clothConfigVersion}") {
exclude("net.fabricmc.fabric-api")
compileOnly("org.spongepowered:mixin:0.8.5")
compileOnly("io.github.llamalad7:mixinextras-common:${property("mixinextras_version")}")
annotationProcessor("io.github.llamalad7:mixinextras-common:${property("mixinextras_version")}")
if (clothConfigVersion != null) {
compileOnly("me.shedaniel.cloth:cloth-config:${clothConfigVersion}") {
exclude("net.fabricmc.fabric-api")
}
}
}
11 changes: 5 additions & 6 deletions common/src/main/java/dev/tocraft/craftedcore/CraftedCore.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@
import dev.tocraft.craftedcore.platform.PlayerProfile;
import dev.tocraft.craftedcore.platform.VersionChecker;
import dev.tocraft.craftedcore.registration.SynchronizedReloadListenerRegistry;
import net.fabricmc.api.EnvType;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.resources.Identifier;
import net.minecraft.server.level.ServerPlayer;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Contract;
Expand All @@ -28,7 +27,7 @@ public class CraftedCore {
@ApiStatus.Internal
public final static Path CACHE_DIR = PlatformData.getConfigPath().resolve(CraftedCore.MODID + File.separatorChar + "cache");
@ApiStatus.Internal
public static final ResourceLocation CLEAR_CACHE_PACKET = id("clear_cache");
public static final Identifier CLEAR_CACHE_PACKET = id("clear_cache");
public static final String MODID = "craftedcore";

public void initialize() {
Expand Down Expand Up @@ -60,7 +59,7 @@ public void initialize() {
CraftedCoreCommand.initialize();

// register config screen
if (PlatformData.getEnv() == EnvType.CLIENT) {
if (PlatformData.getEnv() == PlatformData.Env.CLIENT) {
PlatformData.registerConfigScreen(CraftedCoreConfig.INSTANCE.getName());
}
}
Expand All @@ -76,8 +75,8 @@ public static void reportMissingInternet(Throwable cause) {

@Contract("_ -> new")
@ApiStatus.Internal
public static @NotNull ResourceLocation id(String name) {
return ResourceLocation.fromNamespaceAndPath(MODID, name);
public static @NotNull Identifier id(String name) {
return Identifier.fromNamespaceAndPath(MODID, name);
}

@ApiStatus.Internal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.nbt.CompoundTag;

import net.minecraft.nbt.ListTag;
import net.minecraft.nbt.Tag;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.resources.Identifier;
import net.minecraft.server.level.ServerPlayer;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
Expand All @@ -32,7 +33,7 @@

// heavily based on the work of Draylar - https://github.com/Draylar/omega-config/ and therefore this class is licensed under MIT
public class ConfigLoader {
public static final ResourceLocation CONFIG_SYNC = CraftedCore.id("config_sync");
public static final Identifier CONFIG_SYNC = CraftedCore.id("config_sync");
private static final Map<String, Config> LOADED_CONFIGS = new ConcurrentHashMap<>();
private static final List<Config> CLIENT_CONFIGS = new ArrayList<>();
private static final Gson GSON = new GsonBuilder().setPrettyPrinting().setStrictness(Strictness.LENIENT).create();
Expand Down Expand Up @@ -75,7 +76,7 @@ public static <C extends Config> C register(String name, C @NotNull ... typeGett

C config = read(name, clazz);

if (PlatformData.getEnv() == EnvType.CLIENT) {
if (PlatformData.getEnv() == PlatformData.Env.CLIENT) {
PlatformData.registerConfigScreen(name);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import dev.tocraft.craftedcore.registration.PlayerDataRegistry;
import net.minecraft.core.UUIDUtil;
import net.minecraft.nbt.*;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.resources.Identifier;
import net.minecraft.server.level.ServerPlayer;
import org.jetbrains.annotations.NotNull;

Expand All @@ -18,7 +18,7 @@

public class PlayerDataSynchronizer {
private static final String PLAYER_DATA_SYNC = "player_data_sync";
public static final ResourceLocation PLAYER_DATA_SYNC_ID = CraftedCore.id(PLAYER_DATA_SYNC);
public static final Identifier PLAYER_DATA_SYNC_ID = CraftedCore.id(PLAYER_DATA_SYNC);

public static void registerPacketHandler() {
ModernNetworking.registerReceiver(ModernNetworking.Side.S2C, PLAYER_DATA_SYNC_ID, (context, tag) -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
import dev.tocraft.craftedcore.platform.PlatformData;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;

import net.minecraft.nbt.CompoundTag;
import net.minecraft.resources.FileToIdConverter;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.resources.Identifier;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.packs.resources.Resource;
import net.minecraft.server.packs.resources.ResourceManager;
Expand All @@ -31,34 +32,34 @@
*/
@SuppressWarnings("unused")
public abstract class SynchronizedJsonReloadListener extends
SimplePreparableReloadListener<Map<ResourceLocation, JsonElement>> {
public final ResourceLocation RELOAD_SYNC;
SimplePreparableReloadListener<Map<Identifier, JsonElement>> {
public final Identifier RELOAD_SYNC;
protected final String directory;
protected final Gson gson;
private final Map<ResourceLocation, JsonElement> map = new HashMap<>();
private final Map<Identifier, JsonElement> map = new HashMap<>();

public SynchronizedJsonReloadListener(Gson gson, String directory) {
this.gson = gson;
this.directory = directory;
this.RELOAD_SYNC = CraftedCore.id("data_sync_" + directory);
}

protected @NotNull Map<ResourceLocation, JsonElement> prepare(ResourceManager resourceManager, ProfilerFiller profilerFiller) {
Map<ResourceLocation, JsonElement> map = new HashMap<>();
protected @NotNull Map<Identifier, JsonElement> prepare(ResourceManager resourceManager, ProfilerFiller profilerFiller) {
Map<Identifier, JsonElement> map = new HashMap<>();
scanDirectory(resourceManager, map);
return map;
}

@Override
protected void apply(Map<ResourceLocation, JsonElement> map, ResourceManager resourceManager, ProfilerFiller profiler) {
protected void apply(Map<Identifier, JsonElement> map, ResourceManager resourceManager, ProfilerFiller profiler) {
this.map.clear();
this.map.putAll(map);
if (PlatformData.getEnv() == EnvType.SERVER) {
if (PlatformData.getEnv() == PlatformData.Env.SERVER) {
this.onApply(this.map);
}
}

protected abstract void onApply(Map<ResourceLocation, JsonElement> map);
protected abstract void onApply(Map<Identifier, JsonElement> map);

public void sendSyncPacket(ServerPlayer player) {
// Serialize unlocked to tag
Expand All @@ -71,11 +72,11 @@ public void sendSyncPacket(ServerPlayer player) {

@Environment(EnvType.CLIENT)
private void onPacketReceive(ModernNetworking.Context context, CompoundTag compound) {
Map<ResourceLocation, JsonElement> map = new HashMap<>();
Map<Identifier, JsonElement> map = new HashMap<>();
if (compound != null) {
for (String key : compound.keySet()) {
String json = compound.getString(key).orElseThrow();
map.put(ResourceLocation.parse(key), JsonParser.parseString(json));
map.put(Identifier.parse(key), JsonParser.parseString(json));
}
}
this.onApply(map);
Expand All @@ -86,12 +87,12 @@ public void registerPacketReceiver() {
ModernNetworking.registerReceiver(ModernNetworking.Side.S2C, RELOAD_SYNC, this::onPacketReceive);
}

private void scanDirectory(ResourceManager resourceManager, Map<ResourceLocation, JsonElement> map) {
private void scanDirectory(ResourceManager resourceManager, Map<Identifier, JsonElement> map) {
FileToIdConverter var4 = FileToIdConverter.json(directory);
Iterable<Map.Entry<ResourceLocation, Resource>> entrySet = var4.listMatchingResources(resourceManager).entrySet();
for (Map.Entry<ResourceLocation, Resource> entry : entrySet) {
ResourceLocation var7 = entry.getKey();
ResourceLocation var8 = var4.fileToId(var7);
Iterable<Map.Entry<Identifier, Resource>> entrySet = var4.listMatchingResources(resourceManager).entrySet();
for (Map.Entry<Identifier, Resource> entry : entrySet) {
Identifier var7 = entry.getKey();
Identifier var8 = var4.fileToId(var7);
try {
BufferedReader reader = entry.getValue().openAsReader();
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.DeltaTracker;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.GuiGraphicsExtractor;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player;
import org.jetbrains.annotations.Nullable;
Expand All @@ -22,12 +22,12 @@ public final class RenderEvents {
@Environment(EnvType.CLIENT)
@FunctionalInterface
public interface HUDRendering {
void render(GuiGraphics graphics, DeltaTracker tickCounter);
void extractRenderState(GuiGraphicsExtractor graphics, DeltaTracker tickCounter);
}

@Environment(EnvType.CLIENT)
@FunctionalInterface
public interface OverlayRendering {
InteractionResult render(@Nullable GuiGraphics graphics, Player player);
InteractionResult render(@Nullable GuiGraphicsExtractor graphics, Player player);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public final class PlayerEvents {
long newNewTime = 0;
for (SleepFinishedTime callback : callbacks) {
long newTimeIn = callback.setTimeAddition(level, newTime);
if (level.getDayTime() <= newTime) {
if (level.getOverworldClockTime() <= newTime) {
newNewTime = newTimeIn;
}
}
Expand Down
Loading