Skip to content
This repository has been archived by the owner on May 4, 2024. It is now read-only.

Commit

Permalink
Update to Neo Vanilla, 20.6
Browse files Browse the repository at this point in the history
  • Loading branch information
robotgryphon committed May 4, 2024
1 parent 780abb6 commit 41531dc
Show file tree
Hide file tree
Showing 26 changed files with 119 additions and 564 deletions.
13 changes: 13 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

plugins {
alias(neoforged.plugins.vanilla).apply(false)
}

subprojects {
afterEvaluate {
extensions.configure<JavaPluginExtension> {
// toolchain.vendor.set(JvmVendorSpec)
toolchain.languageVersion.set(JavaLanguageVersion.of(21))
}
}
}
12 changes: 6 additions & 6 deletions core-api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@ val versionMain: String = System.getenv("VERSION") ?: "0.0.0"
plugins {
id("java-library")
id("maven-publish")
id("org.spongepowered.gradle.vanilla") version "0.2.1-SNAPSHOT"
}

minecraft {
version(libraries.versions.minecraft.get())
alias(neoforged.plugins.vanilla)
}

sourceSets {
Expand All @@ -29,10 +25,14 @@ base {
}

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

dependencies {
api(mojang.minecraft)
}

tasks.withType<JavaCompile> {
options.encoding = "UTF-8"
options.compilerArgs.add("-proc:none")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,12 @@
import net.minecraft.nbt.NbtOps;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.phys.Vec2;
import net.minecraft.world.phys.Vec3;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.util.List;
import java.util.stream.DoubleStream;
import java.util.stream.IntStream;

public abstract class CodecExtensions {

private static final Logger CODEC_LOG = LogManager.getLogger(CodecExtensions.class);

public static final Codec<Vec3> VECTOR3D = DoubleStreamExtensions.CODEC
.comapFlatMap(i -> DoubleStreamExtensions.fixedDoubleSize(i, 3)
.map(out -> new Vec3(out[0], out[1], out[2])), vec -> DoubleStream.of(vec.x, vec.y, vec.z));

public static final Codec<Vec2> VEC2 = Codec.FLOAT.listOf()
.comapFlatMap((vec) -> Util.fixedSize(vec, 2).map(
(res) -> new Vec2(res.get(0), res.get(1))),
Expand All @@ -35,7 +25,7 @@ public static <T> CompoundTag writeIntoTag(Codec<T> codec, T instance, CompoundT

final var encoded = codec
.encodeStart(NbtOps.INSTANCE, instance)
.getOrThrow(false, CODEC_LOG::fatal);
.getOrThrow();

if (encoded instanceof CompoundTag ect)
tag.merge(ect);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package dev.compactmods.machines.api.dimension;

import net.minecraft.core.HolderLookup;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
Expand Down Expand Up @@ -44,10 +45,10 @@ public static Path getDataDirectory(@NotNull LevelStorageSource.LevelDirectory l
}

@NotNull
public static DimensionDataStorage getDataStorage(@NotNull LevelStorageSource.LevelDirectory levelDir) {
public static DimensionDataStorage getDataStorage(@NotNull LevelStorageSource.LevelDirectory levelDir, HolderLookup.Provider holderLookup) {
final var dimPath = DimensionType.getStorageFolder(CompactDimension.LEVEL_KEY, levelDir.path());
final var fixer = DataFixers.getDataFixer();
return new DimensionDataStorage(dimPath.resolve("data").toFile(), fixer);
return new DimensionDataStorage(dimPath.resolve("data").toFile(), fixer, holderLookup);
}

public static boolean isLevelCompact(Level level) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package dev.compactmods.machines.api.item.component;

import com.mojang.serialization.Codec;
import net.minecraft.core.component.DataComponentType;
import net.minecraft.network.codec.ByteBufCodecs;
import net.minecraft.resources.ResourceLocation;

import java.util.function.UnaryOperator;

public interface MachineComponents {

/**
* Only on bound room items - given by a crafting process or when a bound machine block is broken
*/
UnaryOperator<DataComponentType.Builder<String>> BOUND_ROOM_CODE = (builder) -> builder
.persistent(Codec.STRING)
.networkSynchronized(ByteBufCodecs.STRING_UTF8);

/**
* Only on new room items - IUnboundMachineItem
*/
UnaryOperator<DataComponentType.Builder<ResourceLocation>> NEW_ROOM_TEMPLATE = (builder) -> builder
.persistent(ResourceLocation.CODEC)
.networkSynchronized(ResourceLocation.STREAM_CODEC);

UnaryOperator<DataComponentType.Builder<Integer>> MACHINE_COLOR = (builder) -> builder
.persistent(Codec.INT)
.networkSynchronized(ByteBufCodecs.INT);
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public record GlobalPosWithRotation(ResourceKey<Level> dimension, Vec3 position,
*/
public static final Codec<GlobalPosWithRotation> CODEC = RecordCodecBuilder.create(i -> i.group(
ResourceKey.codec(Registries.DIMENSION).fieldOf("dimension").forGetter(GlobalPosWithRotation::dimension),
CodecExtensions.VECTOR3D.fieldOf("pos").forGetter(GlobalPosWithRotation::position),
Vec3.CODEC.fieldOf("pos").forGetter(GlobalPosWithRotation::position),
CodecExtensions.VEC2.optionalFieldOf("rot", Vec2.ZERO).forGetter(x -> x.rotation)
).apply(i, GlobalPosWithRotation::new));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,8 @@ public interface MachineConstants {
TagKey<Block> MACHINE_BLOCK = KeyHelper.blockTag("machine");
TagKey<Item> MACHINE_ITEM = KeyHelper.itemTagKey("machine");

TagKey<Item> BOUND_MACHINE_ITEM = KeyHelper.itemTagKey("bound_machine");
TagKey<Item> NEW_MACHINE_ITEM = KeyHelper.itemTagKey("new_machine");


}

This file was deleted.

This file was deleted.

This file was deleted.

7 changes: 2 additions & 5 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,13 @@ var cmModules = listOf(coreApi, roomApi, roomUpgradeApi)
plugins {
java
id("maven-publish")
id("org.spongepowered.gradle.vanilla") version "0.2.1-SNAPSHOT"
alias(neoforged.plugins.vanilla)
}

cmModules.forEach {
project.evaluationDependsOn(it.path)
}

minecraft {
version(libraries.versions.minecraft.get())
}

base {
group = "dev.compactmods.compactmachines"
version = versionMain
Expand Down Expand Up @@ -63,6 +59,7 @@ repositories {
}

dependencies {
compileOnly(mojang.minecraft)
cmModules.forEach {
compileOnly(it)
}
Expand Down

This file was deleted.

Loading

0 comments on commit 41531dc

Please sign in to comment.