Compare commits
No commits in common. "1.21.1" and "1.20.1" have entirely different histories.
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,8 +1,7 @@
|
|||||||
build/
|
build/
|
||||||
bin/
|
|
||||||
run/
|
run/
|
||||||
.idea/
|
.idea/
|
||||||
.c*
|
.c*
|
||||||
.gradle/
|
.gradle/
|
||||||
gradle/
|
gradle/
|
||||||
.architectury-transformer/
|
.architectury-transformer/
|
||||||
16
build.gradle
16
build.gradle
@ -1,7 +1,7 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id 'dev.architectury.loom' version '1.11-SNAPSHOT' apply false
|
id 'dev.architectury.loom' version '1.11-SNAPSHOT' apply false
|
||||||
id 'com.github.johnrengelman.shadow' version '8.1.1' apply false
|
|
||||||
id 'architectury-plugin' version '3.4-SNAPSHOT'
|
id 'architectury-plugin' version '3.4-SNAPSHOT'
|
||||||
|
id 'com.github.johnrengelman.shadow' version '8.1.1' apply false
|
||||||
}
|
}
|
||||||
|
|
||||||
architectury {
|
architectury {
|
||||||
@ -23,7 +23,13 @@ subprojects {
|
|||||||
archivesName = "$rootProject.archives_name-$project.name"
|
archivesName = "$rootProject.archives_name-$project.name"
|
||||||
}
|
}
|
||||||
|
|
||||||
// repositories are declared in settings.gradle
|
repositories {
|
||||||
|
// Add repositories to retrieve artifacts from in here.
|
||||||
|
// You should only use this when depending on other mods because
|
||||||
|
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
|
||||||
|
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
|
||||||
|
// for more information about repositories.
|
||||||
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
minecraft "net.minecraft:minecraft:$rootProject.minecraft_version"
|
minecraft "net.minecraft:minecraft:$rootProject.minecraft_version"
|
||||||
@ -36,12 +42,12 @@ subprojects {
|
|||||||
// If you remove this line, sources will not be generated.
|
// If you remove this line, sources will not be generated.
|
||||||
withSourcesJar()
|
withSourcesJar()
|
||||||
|
|
||||||
sourceCompatibility = JavaVersion.VERSION_21
|
sourceCompatibility = JavaVersion.VERSION_17
|
||||||
targetCompatibility = JavaVersion.VERSION_21
|
targetCompatibility = JavaVersion.VERSION_17
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.withType(JavaCompile).configureEach {
|
tasks.withType(JavaCompile).configureEach {
|
||||||
it.options.release = 21
|
it.options.release = 17
|
||||||
}
|
}
|
||||||
|
|
||||||
// Configure Maven publishing.
|
// Configure Maven publishing.
|
||||||
|
|||||||
@ -3,9 +3,7 @@ architectury {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
// We depend on fabric loader here to use the fabric @Environment annotations and get the mixin dependencies
|
|
||||||
// Do NOT use other classes from fabric loader
|
|
||||||
modImplementation "net.fabricmc:fabric-loader:$rootProject.fabric_loader_version"
|
modImplementation "net.fabricmc:fabric-loader:$rootProject.fabric_loader_version"
|
||||||
|
|
||||||
modApi "dev.architectury:architectury:$rootProject.architectury_api_version"
|
modImplementation "dev.architectury:architectury:$rootProject.architectury_api_version"
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
package io.lampnet.betterlodestones;
|
package io.lampnet.betterlodestones;
|
||||||
|
|
||||||
import io.lampnet.betterlodestones.component.BetterLodestonesComponents;
|
|
||||||
import io.lampnet.betterlodestones.config.ConfigManager;
|
import io.lampnet.betterlodestones.config.ConfigManager;
|
||||||
import io.lampnet.betterlodestones.registry.BetterLodestonesRegistry;
|
import io.lampnet.betterlodestones.registry.BetterLodestonesRegistry;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@ -11,7 +10,6 @@ public final class BetterLodestones {
|
|||||||
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
|
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
|
||||||
|
|
||||||
public static void init() {
|
public static void init() {
|
||||||
BetterLodestonesComponents.init();
|
|
||||||
BetterLodestonesRegistry.init();
|
BetterLodestonesRegistry.init();
|
||||||
|
|
||||||
LOGGER.info("Better Lodestones initialized.");
|
LOGGER.info("Better Lodestones initialized.");
|
||||||
|
|||||||
@ -1,71 +1,125 @@
|
|||||||
package io.lampnet.betterlodestones;
|
package io.lampnet.betterlodestones;
|
||||||
|
|
||||||
import io.lampnet.betterlodestones.component.BetterLodestonesComponents;
|
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.GlobalPos;
|
import net.minecraft.core.GlobalPos;
|
||||||
import net.minecraft.core.component.DataComponents;
|
import net.minecraft.core.registries.Registries;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.world.item.CompassItem;
|
import net.minecraft.nbt.ListTag;
|
||||||
|
import net.minecraft.nbt.Tag;
|
||||||
|
import net.minecraft.resources.ResourceKey;
|
||||||
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.item.component.LodestoneTracker;
|
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.block.Blocks;
|
import net.minecraft.world.level.block.Blocks;
|
||||||
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
import net.minecraft.world.item.CompassItem;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
public class CompassDataHandler {
|
public class CompassDataHandler {
|
||||||
public static List<GlobalPos> getLodestones(ItemStack compass) {
|
private static final String LODESTONES_KEY = "BetterLodestones";
|
||||||
List<GlobalPos> lodestones = compass.get(BetterLodestonesComponents.LODESTONES.get());
|
private static final String CURRENT_INDEX_KEY = "CurrentLodestoneIndex";
|
||||||
return lodestones != null ? lodestones : Collections.emptyList();
|
private static final String POS_X_KEY = "PosX";
|
||||||
}
|
private static final String POS_Y_KEY = "PosY";
|
||||||
|
private static final String POS_Z_KEY = "PosZ";
|
||||||
|
private static final String DIMENSION_KEY = "Dimension";
|
||||||
|
private static final String BROKEN_LODESTONE_FLAG = "BrokenLodestone";
|
||||||
|
|
||||||
public static void syncVanillaLodestoneTracker(ItemStack compass) {
|
public static List<GlobalPos> getLodestones(ItemStack compass) {
|
||||||
Optional<GlobalPos> currentLodestone = getCurrentLodestone(compass);
|
List<GlobalPos> lodestones = new ArrayList<>();
|
||||||
if (currentLodestone.isPresent()) {
|
CompoundTag tag = compass.getTag();
|
||||||
boolean tracked = !hasBrokenLodestone(compass);
|
if (tag == null || !tag.contains(LODESTONES_KEY)) {
|
||||||
compass.set(DataComponents.LODESTONE_TRACKER, new LodestoneTracker(currentLodestone, tracked));
|
return lodestones;
|
||||||
} else {
|
|
||||||
compass.remove(DataComponents.LODESTONE_TRACKER);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ListTag lodestoneList = tag.getList(LODESTONES_KEY, Tag.TAG_COMPOUND);
|
||||||
|
for (int i = 0; i < lodestoneList.size(); i++) {
|
||||||
|
CompoundTag lodestoneTag = lodestoneList.getCompound(i);
|
||||||
|
|
||||||
|
int x = lodestoneTag.getInt(POS_X_KEY);
|
||||||
|
int y = lodestoneTag.getInt(POS_Y_KEY);
|
||||||
|
int z = lodestoneTag.getInt(POS_Z_KEY);
|
||||||
|
String dimensionString = lodestoneTag.getString(DIMENSION_KEY);
|
||||||
|
|
||||||
|
try {
|
||||||
|
ResourceKey<Level> dimension = ResourceKey.create(Registries.DIMENSION,
|
||||||
|
new ResourceLocation(dimensionString));
|
||||||
|
BlockPos pos = new BlockPos(x, y, z);
|
||||||
|
lodestones.add(GlobalPos.of(dimension, pos));
|
||||||
|
} catch (Exception e) {
|
||||||
|
// Skip invalid lodestone entries
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return lodestones;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void addLodestone(ItemStack compass, GlobalPos lodestone) {
|
public static void addLodestone(ItemStack compass, GlobalPos lodestone) {
|
||||||
List<GlobalPos> lodestones = new ArrayList<>(getLodestones(compass));
|
CompoundTag tag = compass.getOrCreateTag();
|
||||||
if (!lodestones.contains(lodestone)) {
|
ListTag lodestoneList = tag.getList(LODESTONES_KEY, Tag.TAG_COMPOUND);
|
||||||
lodestones.add(lodestone);
|
|
||||||
compass.set(BetterLodestonesComponents.LODESTONES.get(), lodestones);
|
for (int i = 0; i < lodestoneList.size(); i++) {
|
||||||
if (lodestones.size() == 1) {
|
CompoundTag existing = lodestoneList.getCompound(i);
|
||||||
compass.set(BetterLodestonesComponents.CURRENT_LODESTONE_INDEX.get(), 0);
|
if (isSameLodestone(existing, lodestone)) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
syncVanillaLodestoneTracker(compass);
|
}
|
||||||
|
|
||||||
|
CompoundTag lodestoneTag = new CompoundTag();
|
||||||
|
lodestoneTag.putInt(POS_X_KEY, lodestone.pos().getX());
|
||||||
|
lodestoneTag.putInt(POS_Y_KEY, lodestone.pos().getY());
|
||||||
|
lodestoneTag.putInt(POS_Z_KEY, lodestone.pos().getZ());
|
||||||
|
lodestoneTag.putString(DIMENSION_KEY, lodestone.dimension().location().toString());
|
||||||
|
|
||||||
|
lodestoneList.add(lodestoneTag);
|
||||||
|
tag.put(LODESTONES_KEY, lodestoneList);
|
||||||
|
|
||||||
|
if (lodestoneList.size() == 1) {
|
||||||
|
tag.putInt(CURRENT_INDEX_KEY, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void removeLodestone(ItemStack compass, GlobalPos lodestone) {
|
public static void removeLodestone(ItemStack compass, GlobalPos lodestone) {
|
||||||
List<GlobalPos> lodestones = new ArrayList<>(getLodestones(compass));
|
CompoundTag tag = compass.getTag();
|
||||||
|
if (tag == null || !tag.contains(LODESTONES_KEY)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ListTag lodestoneList = tag.getList(LODESTONES_KEY, Tag.TAG_COMPOUND);
|
||||||
int currentIndex = getCurrentLodestoneIndex(compass);
|
int currentIndex = getCurrentLodestoneIndex(compass);
|
||||||
if (lodestones.remove(lodestone)) {
|
|
||||||
if (lodestones.isEmpty()) {
|
for (int i = lodestoneList.size() - 1; i >= 0; i--) {
|
||||||
compass.remove(BetterLodestonesComponents.LODESTONES.get());
|
CompoundTag existing = lodestoneList.getCompound(i);
|
||||||
compass.remove(BetterLodestonesComponents.CURRENT_LODESTONE_INDEX.get());
|
if (isSameLodestone(existing, lodestone)) {
|
||||||
} else {
|
lodestoneList.remove(i);
|
||||||
if (currentIndex >= lodestones.size()) {
|
|
||||||
currentIndex = lodestones.size() - 1;
|
if (i < currentIndex) {
|
||||||
|
currentIndex--;
|
||||||
|
} else if (i == currentIndex && currentIndex >= lodestoneList.size()) {
|
||||||
|
currentIndex = lodestoneList.size() - 1;
|
||||||
}
|
}
|
||||||
compass.set(BetterLodestonesComponents.LODESTONES.get(), lodestones);
|
break;
|
||||||
compass.set(BetterLodestonesComponents.CURRENT_LODESTONE_INDEX.get(), Math.max(0, currentIndex));
|
|
||||||
}
|
}
|
||||||
syncVanillaLodestoneTracker(compass);
|
}
|
||||||
|
|
||||||
|
if (lodestoneList.isEmpty()) {
|
||||||
|
tag.remove(CURRENT_INDEX_KEY);
|
||||||
|
tag.remove(LODESTONES_KEY);
|
||||||
|
} else {
|
||||||
|
tag.putInt(CURRENT_INDEX_KEY, Math.max(0, currentIndex));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getCurrentLodestoneIndex(ItemStack compass) {
|
public static int getCurrentLodestoneIndex(ItemStack compass) {
|
||||||
return compass.getOrDefault(BetterLodestonesComponents.CURRENT_LODESTONE_INDEX.get(), 0);
|
CompoundTag tag = compass.getTag();
|
||||||
|
if (tag == null) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return tag.getInt(CURRENT_INDEX_KEY);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Optional<GlobalPos> getCurrentLodestone(ItemStack compass) {
|
public static Optional<GlobalPos> getCurrentLodestone(ItemStack compass) {
|
||||||
@ -73,10 +127,12 @@ public class CompassDataHandler {
|
|||||||
if (lodestones.isEmpty()) {
|
if (lodestones.isEmpty()) {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
int index = getCurrentLodestoneIndex(compass);
|
int index = getCurrentLodestoneIndex(compass);
|
||||||
if (index < 0 || index >= lodestones.size()) {
|
if (index < 0 || index >= lodestones.size()) {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
return Optional.of(lodestones.get(index));
|
return Optional.of(lodestones.get(index));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,9 +142,12 @@ public class CompassDataHandler {
|
|||||||
validateCurrentLodestone(compass, level);
|
validateCurrentLodestone(compass, level);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int currentIndex = getCurrentLodestoneIndex(compass);
|
int currentIndex = getCurrentLodestoneIndex(compass);
|
||||||
int nextIndex = (currentIndex + 1) % lodestones.size();
|
int nextIndex = (currentIndex + 1) % lodestones.size();
|
||||||
compass.set(BetterLodestonesComponents.CURRENT_LODESTONE_INDEX.get(), nextIndex);
|
|
||||||
|
CompoundTag tag = compass.getOrCreateTag();
|
||||||
|
tag.putInt(CURRENT_INDEX_KEY, nextIndex);
|
||||||
|
|
||||||
GlobalPos newLodestone = lodestones.get(nextIndex);
|
GlobalPos newLodestone = lodestones.get(nextIndex);
|
||||||
if (isLodestoneValid(level, newLodestone)) {
|
if (isLodestoneValid(level, newLodestone)) {
|
||||||
@ -105,10 +164,12 @@ public class CompassDataHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void clearAllLodestones(ItemStack compass) {
|
public static void clearAllLodestones(ItemStack compass) {
|
||||||
compass.remove(BetterLodestonesComponents.LODESTONES.get());
|
CompoundTag tag = compass.getTag();
|
||||||
compass.remove(BetterLodestonesComponents.CURRENT_LODESTONE_INDEX.get());
|
if (tag != null) {
|
||||||
compass.remove(BetterLodestonesComponents.BROKEN_LODESTONE.get());
|
tag.remove(LODESTONES_KEY);
|
||||||
syncVanillaLodestoneTracker(compass);
|
tag.remove(CURRENT_INDEX_KEY);
|
||||||
|
tag.remove(BROKEN_LODESTONE_FLAG);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void removeCurrentLodestone(ItemStack compass) {
|
public static void removeCurrentLodestone(ItemStack compass) {
|
||||||
@ -117,7 +178,19 @@ public class CompassDataHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isLodestoneAlreadyBound(ItemStack compass, GlobalPos lodestone) {
|
public static boolean isLodestoneAlreadyBound(ItemStack compass, GlobalPos lodestone) {
|
||||||
return getLodestones(compass).contains(lodestone);
|
CompoundTag tag = compass.getTag();
|
||||||
|
if (tag == null || !tag.contains(LODESTONES_KEY)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
ListTag lodestoneList = tag.getList(LODESTONES_KEY, Tag.TAG_COMPOUND);
|
||||||
|
for (int i = 0; i < lodestoneList.size(); i++) {
|
||||||
|
CompoundTag existing = lodestoneList.getCompound(i);
|
||||||
|
if (isSameLodestone(existing, lodestone)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isLodestoneValid(Level level, GlobalPos lodestone) {
|
public static boolean isLodestoneValid(Level level, GlobalPos lodestone) {
|
||||||
@ -186,17 +259,20 @@ public class CompassDataHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void markLodestoneAsBroken(ItemStack compass) {
|
public static void markLodestoneAsBroken(ItemStack compass) {
|
||||||
compass.set(BetterLodestonesComponents.BROKEN_LODESTONE.get(), true);
|
CompoundTag tag = compass.getOrCreateTag();
|
||||||
syncVanillaLodestoneTracker(compass);
|
tag.putBoolean(BROKEN_LODESTONE_FLAG, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean hasBrokenLodestone(ItemStack compass) {
|
public static boolean hasBrokenLodestone(ItemStack compass) {
|
||||||
return compass.getOrDefault(BetterLodestonesComponents.BROKEN_LODESTONE.get(), false);
|
CompoundTag tag = compass.getTag();
|
||||||
|
return tag != null && tag.getBoolean(BROKEN_LODESTONE_FLAG);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void clearBrokenLodestoneFlag(ItemStack compass) {
|
public static void clearBrokenLodestoneFlag(ItemStack compass) {
|
||||||
compass.remove(BetterLodestonesComponents.BROKEN_LODESTONE.get());
|
CompoundTag tag = compass.getTag();
|
||||||
syncVanillaLodestoneTracker(compass);
|
if (tag != null) {
|
||||||
|
tag.remove(BROKEN_LODESTONE_FLAG);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void onLodestoneRemoved(Level level, BlockPos removedPos) {
|
public static void onLodestoneRemoved(Level level, BlockPos removedPos) {
|
||||||
@ -251,21 +327,57 @@ public class CompassDataHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean isSameLodestone(CompoundTag tag, GlobalPos lodestone) {
|
||||||
|
int x = tag.getInt(POS_X_KEY);
|
||||||
|
int y = tag.getInt(POS_Y_KEY);
|
||||||
|
int z = tag.getInt(POS_Z_KEY);
|
||||||
|
String dimension = tag.getString(DIMENSION_KEY);
|
||||||
|
|
||||||
|
return x == lodestone.pos().getX() &&
|
||||||
|
y == lodestone.pos().getY() &&
|
||||||
|
z == lodestone.pos().getZ() &&
|
||||||
|
dimension.equals(lodestone.dimension().location().toString());
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean convertVanillaLodestoneCompass(ItemStack compass) {
|
public static boolean convertVanillaLodestoneCompass(ItemStack compass) {
|
||||||
if (compass == null || !(compass.getItem() instanceof CompassItem)) {
|
if (compass == null || !(compass.getItem() instanceof CompassItem)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var lodestoneTarget = compass.get(DataComponents.LODESTONE_TRACKER);
|
CompoundTag tag = compass.getTag();
|
||||||
if (lodestoneTarget == null) {
|
if (tag == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean hasVanillaLodestone = tag.contains("LodestonePos") && tag.contains("LodestoneDimension");
|
||||||
|
if (!hasVanillaLodestone) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
CompoundTag lodestonePos = tag.getCompound("LodestonePos");
|
||||||
|
String dimensionString = tag.getString("LodestoneDimension");
|
||||||
|
|
||||||
|
int x = lodestonePos.getInt("X");
|
||||||
|
int y = lodestonePos.getInt("Y");
|
||||||
|
int z = lodestonePos.getInt("Z");
|
||||||
|
|
||||||
|
ResourceKey<Level> dimension = ResourceKey.create(Registries.DIMENSION,
|
||||||
|
new ResourceLocation(dimensionString));
|
||||||
|
BlockPos pos = new BlockPos(x, y, z);
|
||||||
|
GlobalPos vanillaLodestone = GlobalPos.of(dimension, pos);
|
||||||
|
|
||||||
|
addLodestone(compass, vanillaLodestone);
|
||||||
|
|
||||||
|
tag.remove("LodestonePos");
|
||||||
|
tag.remove("LodestoneDimension");
|
||||||
|
tag.remove("LodestoneTracked");
|
||||||
|
|
||||||
|
return true;
|
||||||
|
} catch (Exception e) {
|
||||||
|
// If conversion fails, skip this compass
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
lodestoneTarget.target().ifPresent(globalPos -> {
|
|
||||||
addLodestone(compass, globalPos);
|
|
||||||
});
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int convertPlayerLodestoneCompasses(Player player) {
|
public static int convertPlayerLodestoneCompasses(Player player) {
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
package io.lampnet.betterlodestones.advancement;
|
package io.lampnet.betterlodestones.advancement;
|
||||||
|
|
||||||
import com.mojang.serialization.Codec;
|
import com.google.gson.JsonObject;
|
||||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
|
||||||
import io.lampnet.betterlodestones.BetterLodestones;
|
import io.lampnet.betterlodestones.BetterLodestones;
|
||||||
import io.lampnet.betterlodestones.CompassDataHandler;
|
import io.lampnet.betterlodestones.CompassDataHandler;
|
||||||
import net.minecraft.advancements.critereon.*;
|
import net.minecraft.advancements.critereon.*;
|
||||||
@ -9,31 +8,40 @@ import net.minecraft.core.GlobalPos;
|
|||||||
import net.minecraft.resources.ResourceKey;
|
import net.minecraft.resources.ResourceKey;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
|
import net.minecraft.util.GsonHelper;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public final class DimensionalCompassBindingTrigger extends SimpleCriterionTrigger<DimensionalCompassBindingTrigger.TriggerInstance> {
|
public final class DimensionalCompassBindingTrigger extends SimpleCriterionTrigger<DimensionalCompassBindingTrigger.TriggerInstance> {
|
||||||
static final ResourceLocation ID = ResourceLocation.fromNamespaceAndPath(BetterLodestones.MOD_ID, "dimensional_compass_binding");
|
static final ResourceLocation ID = new ResourceLocation(BetterLodestones.MOD_ID, "dimensional_compass_binding");
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Codec<TriggerInstance> codec() {
|
public @NotNull ResourceLocation getId() {
|
||||||
return TriggerInstance.CODEC;
|
return ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull TriggerInstance createInstance(JsonObject json, ContextAwarePredicate player, DeserializationContext context) {
|
||||||
|
int minDimensions = GsonHelper.getAsInt(json, "min_dimensions", 1);
|
||||||
|
return new TriggerInstance(player, minDimensions);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void trigger(ServerPlayer player, ItemStack compass) {
|
public void trigger(ServerPlayer player, ItemStack compass) {
|
||||||
this.trigger(player, (triggerInstance) -> triggerInstance.matches(compass));
|
this.trigger(player, (triggerInstance) -> triggerInstance.matches(compass));
|
||||||
}
|
}
|
||||||
|
|
||||||
public record TriggerInstance(Optional<ContextAwarePredicate> player, int minDimensions) implements SimpleCriterionTrigger.SimpleInstance {
|
public static class TriggerInstance extends AbstractCriterionTriggerInstance {
|
||||||
public static final Codec<TriggerInstance> CODEC = RecordCodecBuilder.create(instance -> instance.group(
|
private final int minDimensions;
|
||||||
ContextAwarePredicate.CODEC.optionalFieldOf("player").forGetter(TriggerInstance::player),
|
|
||||||
Codec.INT.fieldOf("min_dimensions").forGetter(TriggerInstance::minDimensions)
|
public TriggerInstance(ContextAwarePredicate player, int minDimensions) {
|
||||||
).apply(instance, TriggerInstance::new));
|
super(ID, player);
|
||||||
|
this.minDimensions = minDimensions;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean matches(ItemStack compass) {
|
public boolean matches(ItemStack compass) {
|
||||||
List<GlobalPos> lodestones = CompassDataHandler.getLodestones(compass);
|
List<GlobalPos> lodestones = CompassDataHandler.getLodestones(compass);
|
||||||
@ -47,5 +55,12 @@ public final class DimensionalCompassBindingTrigger extends SimpleCriterionTrigg
|
|||||||
|
|
||||||
return uniqueDimensions.size() >= this.minDimensions;
|
return uniqueDimensions.size() >= this.minDimensions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull JsonObject serializeToJson(SerializationContext context) {
|
||||||
|
JsonObject json = super.serializeToJson(context);
|
||||||
|
json.addProperty("min_dimensions", this.minDimensions);
|
||||||
|
return json;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +0,0 @@
|
|||||||
package io.lampnet.betterlodestones.client;
|
|
||||||
|
|
||||||
public class BetterLodestonesClient {
|
|
||||||
public static void initClient() {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,34 +0,0 @@
|
|||||||
package io.lampnet.betterlodestones.component;
|
|
||||||
|
|
||||||
import com.mojang.serialization.Codec;
|
|
||||||
import dev.architectury.registry.registries.DeferredRegister;
|
|
||||||
import dev.architectury.registry.registries.RegistrySupplier;
|
|
||||||
import io.lampnet.betterlodestones.BetterLodestones;
|
|
||||||
import net.minecraft.core.GlobalPos;
|
|
||||||
import net.minecraft.core.component.DataComponentType;
|
|
||||||
import net.minecraft.core.registries.Registries;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.function.UnaryOperator;
|
|
||||||
|
|
||||||
public class BetterLodestonesComponents {
|
|
||||||
public static final DeferredRegister<DataComponentType<?>> DATA_COMPONENTS =
|
|
||||||
DeferredRegister.create(BetterLodestones.MOD_ID, Registries.DATA_COMPONENT_TYPE);
|
|
||||||
|
|
||||||
public static final RegistrySupplier<DataComponentType<List<GlobalPos>>> LODESTONES =
|
|
||||||
register("lodestones", builder -> builder.persistent(Codec.list(GlobalPos.CODEC)).cacheEncoding());
|
|
||||||
|
|
||||||
public static final RegistrySupplier<DataComponentType<Integer>> CURRENT_LODESTONE_INDEX =
|
|
||||||
register("current_lodestone_index", builder -> builder.persistent(Codec.INT).cacheEncoding());
|
|
||||||
|
|
||||||
public static final RegistrySupplier<DataComponentType<Boolean>> BROKEN_LODESTONE =
|
|
||||||
register("broken_lodestone", builder -> builder.persistent(Codec.BOOL).cacheEncoding());
|
|
||||||
|
|
||||||
private static <T> RegistrySupplier<DataComponentType<T>> register(String name, UnaryOperator<DataComponentType.Builder<T>> builder) {
|
|
||||||
return DATA_COMPONENTS.register(name, () -> builder.apply(DataComponentType.builder()).build());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void init() {
|
|
||||||
DATA_COMPONENTS.register();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,7 +1,6 @@
|
|||||||
package io.lampnet.betterlodestones.mixin;
|
package io.lampnet.betterlodestones.mixin;
|
||||||
|
|
||||||
import io.lampnet.betterlodestones.CompassDataHandler;
|
import io.lampnet.betterlodestones.CompassDataHandler;
|
||||||
import io.lampnet.betterlodestones.advancement.DimensionalCompassBindingTrigger;
|
|
||||||
import io.lampnet.betterlodestones.config.ConfigManager;
|
import io.lampnet.betterlodestones.config.ConfigManager;
|
||||||
import io.lampnet.betterlodestones.registry.BetterLodestonesRegistry;
|
import io.lampnet.betterlodestones.registry.BetterLodestonesRegistry;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
@ -73,7 +72,7 @@ public class CompassItemMixin {
|
|||||||
level.playSound(null, pos, SoundEvents.LODESTONE_COMPASS_LOCK, SoundSource.PLAYERS, 1.0F, 1.0F);
|
level.playSound(null, pos, SoundEvents.LODESTONE_COMPASS_LOCK, SoundSource.PLAYERS, 1.0F, 1.0F);
|
||||||
|
|
||||||
if (player instanceof ServerPlayer serverPlayer) {
|
if (player instanceof ServerPlayer serverPlayer) {
|
||||||
((DimensionalCompassBindingTrigger) BetterLodestonesRegistry.DIMENSIONAL_COMPASS_BINDING.get()).trigger(serverPlayer, compass);
|
BetterLodestonesRegistry.DIMENSIONAL_COMPASS_BINDING.trigger(serverPlayer, compass);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
|
|||||||
@ -0,0 +1,41 @@
|
|||||||
|
package io.lampnet.betterlodestones.mixin;
|
||||||
|
|
||||||
|
import io.lampnet.betterlodestones.CompassDataHandler;
|
||||||
|
import net.minecraft.core.GlobalPos;
|
||||||
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
import net.minecraft.world.item.CompassItem;
|
||||||
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
import net.minecraft.world.item.Items;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@Mixin(CompassItem.class)
|
||||||
|
public class CompassItemMixinPointing {
|
||||||
|
|
||||||
|
@Inject(method = "getLodestonePosition", at = @At("HEAD"), cancellable = true)
|
||||||
|
private static void getCustomLodestonePosition(CompoundTag tag,
|
||||||
|
CallbackInfoReturnable<GlobalPos> cir) {
|
||||||
|
ItemStack tempStack = new ItemStack(Items.COMPASS);
|
||||||
|
tempStack.setTag(tag);
|
||||||
|
|
||||||
|
if (CompassDataHandler.hasBrokenLodestone(tempStack)) {
|
||||||
|
cir.setReturnValue(null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Optional<GlobalPos> currentLodestone = CompassDataHandler.getCurrentLodestone(tempStack);
|
||||||
|
currentLodestone.ifPresent(cir::setReturnValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject(method = "isLodestoneCompass", at = @At("HEAD"), cancellable = true)
|
||||||
|
private static void isCustomLodestoneCompass(ItemStack stack,
|
||||||
|
CallbackInfoReturnable<Boolean> cir) {
|
||||||
|
if (CompassDataHandler.getLodestoneCount(stack) > 0) {
|
||||||
|
cir.setReturnValue(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -29,12 +29,19 @@ public class CompassTooltipMixin {
|
|||||||
private static final int UNSELECTED_TICK_INTERVAL = 40;
|
private static final int UNSELECTED_TICK_INTERVAL = 40;
|
||||||
|
|
||||||
@Inject(method = "appendHoverText", at = @At("TAIL"))
|
@Inject(method = "appendHoverText", at = @At("TAIL"))
|
||||||
private void addCustomTooltip(ItemStack stack, Item.TooltipContext context, List<Component> tooltip, TooltipFlag flag, CallbackInfo ci) {
|
private void addCustomTooltip(ItemStack stack, Level level, List<Component> tooltip, TooltipFlag flag, CallbackInfo ci) {
|
||||||
if (!(stack.getItem() instanceof CompassItem)) {
|
if (!(stack.getItem() instanceof CompassItem)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tooltip is client-side, so we don't do server-side validation here
|
if (level != null && !level.isClientSide()) {
|
||||||
|
CompassDataHandler.convertVanillaLodestoneCompass(stack);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (level != null) {
|
||||||
|
CompassDataHandler.validateCurrentLodestone(stack, level);
|
||||||
|
}
|
||||||
|
|
||||||
int lodestoneCount = CompassDataHandler.getLodestoneCount(stack);
|
int lodestoneCount = CompassDataHandler.getLodestoneCount(stack);
|
||||||
|
|
||||||
if (lodestoneCount > 0) {
|
if (lodestoneCount > 0) {
|
||||||
@ -54,7 +61,9 @@ public class CompassTooltipMixin {
|
|||||||
tooltip.add(Component.literal("§7Current: §f" + currentIndex + "/" + lodestoneCount +
|
tooltip.add(Component.literal("§7Current: §f" + currentIndex + "/" + lodestoneCount +
|
||||||
" §7at §f" + pos.getX() + ", " + pos.getY() + ", " + pos.getZ()));
|
" §7at §f" + pos.getX() + ", " + pos.getY() + ", " + pos.getZ()));
|
||||||
|
|
||||||
if (CompassDataHandler.hasBrokenLodestone(stack)) {
|
if (CompassDataHandler.isLodestoneInDifferentDimension(level, lodestone)) {
|
||||||
|
tooltip.add(Component.literal("§7Dimension: §c" + better_lodestones$formatDimensionName(dimensionName)));
|
||||||
|
} else if (CompassDataHandler.hasBrokenLodestone(stack)) {
|
||||||
tooltip.add(Component.literal("§cLodestone destroyed!"));
|
tooltip.add(Component.literal("§cLodestone destroyed!"));
|
||||||
} else {
|
} else {
|
||||||
tooltip.add(Component.literal("§7Dimension: §f" + better_lodestones$formatDimensionName(dimensionName)));
|
tooltip.add(Component.literal("§7Dimension: §f" + better_lodestones$formatDimensionName(dimensionName)));
|
||||||
|
|||||||
@ -4,7 +4,6 @@ import io.lampnet.betterlodestones.CompassDataHandler;
|
|||||||
import io.lampnet.betterlodestones.BetterLodestones;
|
import io.lampnet.betterlodestones.BetterLodestones;
|
||||||
import net.minecraft.network.Connection;
|
import net.minecraft.network.Connection;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.server.network.CommonListenerCookie;
|
|
||||||
import net.minecraft.server.players.PlayerList;
|
import net.minecraft.server.players.PlayerList;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
@ -15,7 +14,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|||||||
public class PlayerJoinMixin {
|
public class PlayerJoinMixin {
|
||||||
|
|
||||||
@Inject(method = "placeNewPlayer", at = @At("TAIL"))
|
@Inject(method = "placeNewPlayer", at = @At("TAIL"))
|
||||||
private void onPlayerJoin(Connection connection, ServerPlayer player, CommonListenerCookie commonListenerCookie, CallbackInfo ci) {
|
private void onPlayerJoin(Connection connection, ServerPlayer player, CallbackInfo ci) {
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
int convertedCount = CompassDataHandler.convertPlayerLodestoneCompasses(player);
|
int convertedCount = CompassDataHandler.convertPlayerLodestoneCompasses(player);
|
||||||
if (convertedCount > 0) {
|
if (convertedCount > 0) {
|
||||||
|
|||||||
@ -1,12 +1,12 @@
|
|||||||
package io.lampnet.betterlodestones.recipe;
|
package io.lampnet.betterlodestones.recipe;
|
||||||
|
|
||||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
import com.google.gson.JsonObject;
|
||||||
import io.lampnet.betterlodestones.CompassDataHandler;
|
import io.lampnet.betterlodestones.CompassDataHandler;
|
||||||
import io.lampnet.betterlodestones.component.BetterLodestonesComponents;
|
import net.minecraft.core.RegistryAccess;
|
||||||
import net.minecraft.core.HolderLookup;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.network.RegistryFriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraft.network.codec.StreamCodec;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.world.item.crafting.CraftingInput;
|
import net.minecraft.world.inventory.CraftingContainer;
|
||||||
import net.minecraft.world.item.CompassItem;
|
import net.minecraft.world.item.CompassItem;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.item.Items;
|
import net.minecraft.world.item.Items;
|
||||||
@ -17,16 +17,16 @@ import net.minecraft.world.level.Level;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class CompassUnbindingRecipe extends CustomRecipe {
|
public class CompassUnbindingRecipe extends CustomRecipe {
|
||||||
public CompassUnbindingRecipe(CraftingBookCategory category) {
|
public CompassUnbindingRecipe(ResourceLocation id, CraftingBookCategory category) {
|
||||||
super(category);
|
super(id, category);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(CraftingInput craftingInput, Level level) {
|
public boolean matches(CraftingContainer craftingContainer, Level level) {
|
||||||
ItemStack compass = ItemStack.EMPTY;
|
ItemStack compass = ItemStack.EMPTY;
|
||||||
|
|
||||||
for (int i = 0; i < craftingInput.size(); ++i) {
|
for (int i = 0; i < craftingContainer.getContainerSize(); ++i) {
|
||||||
ItemStack currentStack = craftingInput.getItem(i);
|
ItemStack currentStack = craftingContainer.getItem(i);
|
||||||
if (!currentStack.isEmpty()) {
|
if (!currentStack.isEmpty()) {
|
||||||
if (currentStack.getItem() instanceof CompassItem) {
|
if (currentStack.getItem() instanceof CompassItem) {
|
||||||
if (!compass.isEmpty()) {
|
if (!compass.isEmpty()) {
|
||||||
@ -39,15 +39,20 @@ public class CompassUnbindingRecipe extends CustomRecipe {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return !compass.isEmpty() && (compass.has(BetterLodestonesComponents.LODESTONES.get()) || compass.has(net.minecraft.core.component.DataComponents.LODESTONE_TRACKER));
|
if (compass.isEmpty() || !compass.hasTag()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
CompoundTag tag = compass.getTag();
|
||||||
|
return tag != null && (tag.contains("LodestonePos") || tag.contains("BetterLodestones"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull ItemStack assemble(@NotNull CraftingInput craftingInput, @NotNull HolderLookup.Provider provider) {
|
public @NotNull ItemStack assemble(CraftingContainer craftingContainer, RegistryAccess registryAccess) {
|
||||||
ItemStack compass = ItemStack.EMPTY;
|
ItemStack compass = ItemStack.EMPTY;
|
||||||
|
|
||||||
for (int i = 0; i < craftingInput.size(); i++) {
|
for (int i = 0; i < craftingContainer.getContainerSize(); i++) {
|
||||||
ItemStack currentStack = craftingInput.getItem(i);
|
ItemStack currentStack = craftingContainer.getItem(i);
|
||||||
if (!currentStack.isEmpty() && currentStack.getItem() instanceof CompassItem) {
|
if (!currentStack.isEmpty() && currentStack.getItem() instanceof CompassItem) {
|
||||||
compass = currentStack.copy();
|
compass = currentStack.copy();
|
||||||
compass.setCount(1);
|
compass.setCount(1);
|
||||||
@ -76,30 +81,24 @@ public class CompassUnbindingRecipe extends CustomRecipe {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull RecipeSerializer<?> getSerializer() {
|
public @NotNull RecipeSerializer<?> getSerializer() {
|
||||||
return io.lampnet.betterlodestones.registry.BetterLodestonesRegistry.COMPASS_UNBINDING.get();
|
return CompassUnbindingRecipeSerializer.INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class CompassUnbindingRecipeSerializer implements RecipeSerializer<CompassUnbindingRecipe> {
|
public static class CompassUnbindingRecipeSerializer implements RecipeSerializer<CompassUnbindingRecipe> {
|
||||||
public static final CompassUnbindingRecipeSerializer INSTANCE = new CompassUnbindingRecipeSerializer();
|
public static final CompassUnbindingRecipeSerializer INSTANCE = new CompassUnbindingRecipeSerializer();
|
||||||
private static final com.mojang.serialization.MapCodec<CompassUnbindingRecipe> CODEC = RecordCodecBuilder.mapCodec(instance ->
|
|
||||||
instance.group(
|
|
||||||
CraftingBookCategory.CODEC.fieldOf("category").orElse(CraftingBookCategory.MISC).forGetter(CustomRecipe::category)
|
|
||||||
).apply(instance, CompassUnbindingRecipe::new)
|
|
||||||
);
|
|
||||||
private static final StreamCodec<RegistryFriendlyByteBuf, CompassUnbindingRecipe> STREAM_CODEC = StreamCodec.of(
|
|
||||||
(buf, recipe) -> buf.writeEnum(recipe.category()),
|
|
||||||
buf -> new CompassUnbindingRecipe(buf.readEnum(CraftingBookCategory.class))
|
|
||||||
);
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull com.mojang.serialization.MapCodec<CompassUnbindingRecipe> codec() {
|
public @NotNull CompassUnbindingRecipe fromJson(ResourceLocation recipeId, JsonObject json) {
|
||||||
return CODEC;
|
return new CompassUnbindingRecipe(recipeId, CraftingBookCategory.MISC);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull StreamCodec<RegistryFriendlyByteBuf, CompassUnbindingRecipe> streamCodec() {
|
public @NotNull CompassUnbindingRecipe fromNetwork(ResourceLocation recipeId, FriendlyByteBuf buffer) {
|
||||||
return STREAM_CODEC;
|
return new CompassUnbindingRecipe(recipeId, CraftingBookCategory.MISC);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void toNetwork(FriendlyByteBuf buffer, CompassUnbindingRecipe recipe) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
package io.lampnet.betterlodestones.recipe;
|
package io.lampnet.betterlodestones.recipe;
|
||||||
|
|
||||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
import com.google.gson.JsonObject;
|
||||||
import io.lampnet.betterlodestones.config.ConfigManager;
|
import io.lampnet.betterlodestones.config.ConfigManager;
|
||||||
import net.minecraft.core.HolderLookup;
|
import net.minecraft.core.RegistryAccess;
|
||||||
import net.minecraft.network.RegistryFriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraft.network.codec.StreamCodec;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.world.item.crafting.CraftingInput;
|
import net.minecraft.world.inventory.CraftingContainer;
|
||||||
import net.minecraft.world.item.Item;
|
import net.minecraft.world.item.Item;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.item.Items;
|
import net.minecraft.world.item.Items;
|
||||||
@ -16,18 +16,18 @@ import net.minecraft.world.level.Level;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class ConfigurableLodestoneRecipe extends CustomRecipe {
|
public class ConfigurableLodestoneRecipe extends CustomRecipe {
|
||||||
public ConfigurableLodestoneRecipe(CraftingBookCategory category) {
|
public ConfigurableLodestoneRecipe(ResourceLocation id, CraftingBookCategory category) {
|
||||||
super(category);
|
super(id, category);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(CraftingInput craftingInput, Level level) {
|
public boolean matches(CraftingContainer craftingContainer, Level level) {
|
||||||
if (craftingInput.width() != 3 || craftingInput.height() != 3) {
|
if (craftingContainer.getWidth() != 3 || craftingContainer.getHeight() != 3) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Item expectedCenterItem = ConfigManager.useModernLodestoneRecipe() ? Items.IRON_INGOT : Items.NETHERITE_INGOT;
|
Item expectedCenterItem = ConfigManager.useModernLodestoneRecipe() ? Items.IRON_INGOT : Items.NETHERITE_INGOT;
|
||||||
if (!craftingInput.getItem(4).is(expectedCenterItem)) {
|
if (!craftingContainer.getItem(4).is(expectedCenterItem)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ public class ConfigurableLodestoneRecipe extends CustomRecipe {
|
|||||||
if (i == 4) {
|
if (i == 4) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!craftingInput.getItem(i).is(Items.CHISELED_STONE_BRICKS)) {
|
if (!craftingContainer.getItem(i).is(Items.CHISELED_STONE_BRICKS)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -43,7 +43,7 @@ public class ConfigurableLodestoneRecipe extends CustomRecipe {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull ItemStack assemble(@NotNull CraftingInput craftingInput, @NotNull HolderLookup.Provider provider) {
|
public @NotNull ItemStack assemble(@NotNull CraftingContainer craftingContainer, RegistryAccess registryAccess) {
|
||||||
return new ItemStack(Items.LODESTONE);
|
return new ItemStack(Items.LODESTONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,29 +54,24 @@ public class ConfigurableLodestoneRecipe extends CustomRecipe {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull RecipeSerializer<?> getSerializer() {
|
public @NotNull RecipeSerializer<?> getSerializer() {
|
||||||
return io.lampnet.betterlodestones.registry.BetterLodestonesRegistry.CONFIGURABLE_LODESTONE.get();
|
return Serializer.INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Serializer implements RecipeSerializer<ConfigurableLodestoneRecipe> {
|
public static class Serializer implements RecipeSerializer<ConfigurableLodestoneRecipe> {
|
||||||
public static final Serializer INSTANCE = new Serializer();
|
public static final Serializer INSTANCE = new Serializer();
|
||||||
private static final com.mojang.serialization.MapCodec<ConfigurableLodestoneRecipe> CODEC = RecordCodecBuilder.mapCodec(instance ->
|
|
||||||
instance.group(
|
|
||||||
CraftingBookCategory.CODEC.fieldOf("category").orElse(CraftingBookCategory.MISC).forGetter(CustomRecipe::category)
|
|
||||||
).apply(instance, ConfigurableLodestoneRecipe::new)
|
|
||||||
);
|
|
||||||
private static final StreamCodec<RegistryFriendlyByteBuf, ConfigurableLodestoneRecipe> STREAM_CODEC = StreamCodec.of(
|
|
||||||
(buf, recipe) -> buf.writeEnum(recipe.category()),
|
|
||||||
buf -> new ConfigurableLodestoneRecipe(buf.readEnum(CraftingBookCategory.class))
|
|
||||||
);
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull com.mojang.serialization.MapCodec<ConfigurableLodestoneRecipe> codec() {
|
public @NotNull ConfigurableLodestoneRecipe fromJson(ResourceLocation recipeId, JsonObject json) {
|
||||||
return CODEC;
|
return new ConfigurableLodestoneRecipe(recipeId, CraftingBookCategory.MISC);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull StreamCodec<RegistryFriendlyByteBuf, ConfigurableLodestoneRecipe> streamCodec() {
|
public @NotNull ConfigurableLodestoneRecipe fromNetwork(ResourceLocation recipeId, FriendlyByteBuf buffer) {
|
||||||
return STREAM_CODEC;
|
return new ConfigurableLodestoneRecipe(recipeId, CraftingBookCategory.MISC);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void toNetwork(FriendlyByteBuf buffer, ConfigurableLodestoneRecipe recipe) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import io.lampnet.betterlodestones.BetterLodestones;
|
|||||||
import io.lampnet.betterlodestones.advancement.DimensionalCompassBindingTrigger;
|
import io.lampnet.betterlodestones.advancement.DimensionalCompassBindingTrigger;
|
||||||
import io.lampnet.betterlodestones.recipe.CompassUnbindingRecipe;
|
import io.lampnet.betterlodestones.recipe.CompassUnbindingRecipe;
|
||||||
import io.lampnet.betterlodestones.recipe.ConfigurableLodestoneRecipe;
|
import io.lampnet.betterlodestones.recipe.ConfigurableLodestoneRecipe;
|
||||||
import net.minecraft.advancements.CriterionTrigger;
|
import net.minecraft.advancements.CriteriaTriggers;
|
||||||
import net.minecraft.core.registries.Registries;
|
import net.minecraft.core.registries.Registries;
|
||||||
import net.minecraft.world.item.crafting.RecipeSerializer;
|
import net.minecraft.world.item.crafting.RecipeSerializer;
|
||||||
|
|
||||||
@ -20,14 +20,10 @@ public final class BetterLodestonesRegistry {
|
|||||||
public static final RegistrySupplier<RecipeSerializer<?>> COMPASS_UNBINDING =
|
public static final RegistrySupplier<RecipeSerializer<?>> COMPASS_UNBINDING =
|
||||||
RECIPE_SERIALIZERS.register("compass_unbinding", () -> CompassUnbindingRecipe.CompassUnbindingRecipeSerializer.INSTANCE);
|
RECIPE_SERIALIZERS.register("compass_unbinding", () -> CompassUnbindingRecipe.CompassUnbindingRecipeSerializer.INSTANCE);
|
||||||
|
|
||||||
public static final DeferredRegister<CriterionTrigger<?>> CRITERION_TRIGGERS =
|
public static final DimensionalCompassBindingTrigger DIMENSIONAL_COMPASS_BINDING = new DimensionalCompassBindingTrigger();
|
||||||
DeferredRegister.create(BetterLodestones.MOD_ID, Registries.TRIGGER_TYPE);
|
|
||||||
|
|
||||||
public static final RegistrySupplier<CriterionTrigger<DimensionalCompassBindingTrigger.TriggerInstance>> DIMENSIONAL_COMPASS_BINDING =
|
|
||||||
CRITERION_TRIGGERS.register("dimensional_compass_binding", DimensionalCompassBindingTrigger::new);
|
|
||||||
|
|
||||||
public static void init() {
|
public static void init() {
|
||||||
RECIPE_SERIALIZERS.register();
|
RECIPE_SERIALIZERS.register();
|
||||||
CRITERION_TRIGGERS.register();
|
CriteriaTriggers.register(DIMENSIONAL_COMPASS_BINDING);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,6 +7,7 @@
|
|||||||
],
|
],
|
||||||
"mixins": [
|
"mixins": [
|
||||||
"CompassItemMixin",
|
"CompassItemMixin",
|
||||||
|
"CompassItemMixinPointing",
|
||||||
"CompassTooltipMixin",
|
"CompassTooltipMixin",
|
||||||
"InventoryInteractionMixin",
|
"InventoryInteractionMixin",
|
||||||
"ItemPickupMixin",
|
"ItemPickupMixin",
|
||||||
|
|||||||
@ -1,11 +1,9 @@
|
|||||||
{
|
{
|
||||||
"parent": "minecraft:adventure/use_lodestone",
|
"parent": "minecraft:nether/use_lodestone",
|
||||||
"display": {
|
"display": {
|
||||||
"icon": {
|
"icon": {
|
||||||
"id": "minecraft:compass",
|
"item": "minecraft:compass",
|
||||||
"components": {
|
"nbt": "{CustomModelData:1}"
|
||||||
"minecraft:custom_model_data": 1
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"title": {
|
"title": {
|
||||||
"translate": "advancements.better_lodestones.dimensional_lodestone_master.title"
|
"translate": "advancements.better_lodestones.dimensional_lodestone_master.title"
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
{
|
{
|
||||||
"type": "better_lodestones:compass_unbinding",
|
"type": "better_lodestones:compass_unbinding"
|
||||||
"category": "misc"
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
{
|
{
|
||||||
"type": "better_lodestones:configurable_lodestone",
|
"type": "better_lodestones:configurable_lodestone"
|
||||||
"category": "building"
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
"parent": "minecraft:adventure/root",
|
"parent": "minecraft:adventure/root",
|
||||||
"display": {
|
"display": {
|
||||||
"icon": {
|
"icon": {
|
||||||
"id": "minecraft:lodestone"
|
"item": "minecraft:lodestone"
|
||||||
},
|
},
|
||||||
"title": {
|
"title": {
|
||||||
"translate": "advancements.nether.use_lodestone.title"
|
"translate": "advancements.nether.use_lodestone.title"
|
||||||
@ -19,16 +19,22 @@
|
|||||||
"use_lodestone": {
|
"use_lodestone": {
|
||||||
"trigger": "minecraft:item_used_on_block",
|
"trigger": "minecraft:item_used_on_block",
|
||||||
"conditions": {
|
"conditions": {
|
||||||
|
"location": [
|
||||||
|
{
|
||||||
|
"condition": "minecraft:match_tool",
|
||||||
|
"predicate": {
|
||||||
|
"items": [
|
||||||
|
"minecraft:compass"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
"item": {
|
"item": {
|
||||||
"items": [
|
"items": [
|
||||||
"minecraft:compass"
|
"minecraft:compass"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"location": {
|
"block": "minecraft:lodestone"
|
||||||
"block": {
|
|
||||||
"blocks": "minecraft:lodestone"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,4 +1,3 @@
|
|||||||
{
|
{
|
||||||
"type": "better_lodestones:configurable_lodestone",
|
"type": "better_lodestones:configurable_lodestone"
|
||||||
"category": "building"
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,11 +0,0 @@
|
|||||||
package io.lampnet.betterlodestones.fabric;
|
|
||||||
|
|
||||||
import io.lampnet.betterlodestones.client.BetterLodestonesClient;
|
|
||||||
import net.fabricmc.api.ClientModInitializer;
|
|
||||||
|
|
||||||
public final class BetterLodestonesFabricClient implements ClientModInitializer {
|
|
||||||
@Override
|
|
||||||
public void onInitializeClient() {
|
|
||||||
BetterLodestonesClient.initClient();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -16,9 +16,6 @@
|
|||||||
"entrypoints": {
|
"entrypoints": {
|
||||||
"main": [
|
"main": [
|
||||||
"io.lampnet.betterlodestones.fabric.BetterLodestonesFabric"
|
"io.lampnet.betterlodestones.fabric.BetterLodestonesFabric"
|
||||||
],
|
|
||||||
"client": [
|
|
||||||
"io.lampnet.betterlodestones.fabric.BetterLodestonesFabricClient"
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"mixins": [
|
"mixins": [
|
||||||
@ -26,9 +23,9 @@
|
|||||||
],
|
],
|
||||||
"depends": {
|
"depends": {
|
||||||
"fabricloader": ">=0.17.2",
|
"fabricloader": ">=0.17.2",
|
||||||
"minecraft": "~1.21.1",
|
"minecraft": "~1.20.1",
|
||||||
"java": ">=21",
|
"java": ">=17",
|
||||||
"architectury": ">=13.0.8",
|
"architectury": ">=9.2.14",
|
||||||
"fabric-api": "*"
|
"fabric-api": "*"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,9 +2,15 @@ plugins {
|
|||||||
id 'com.github.johnrengelman.shadow'
|
id 'com.github.johnrengelman.shadow'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
loom {
|
||||||
|
forge {
|
||||||
|
mixinConfig "better_lodestones.mixins.json"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
architectury {
|
architectury {
|
||||||
platformSetupLoomIde()
|
platformSetupLoomIde()
|
||||||
neoForge()
|
forge()
|
||||||
}
|
}
|
||||||
|
|
||||||
configurations {
|
configurations {
|
||||||
@ -14,7 +20,7 @@ configurations {
|
|||||||
}
|
}
|
||||||
compileClasspath.extendsFrom common
|
compileClasspath.extendsFrom common
|
||||||
runtimeClasspath.extendsFrom common
|
runtimeClasspath.extendsFrom common
|
||||||
developmentNeoForge.extendsFrom common
|
developmentForge.extendsFrom common
|
||||||
|
|
||||||
// Files in this configuration will be bundled into your mod using the Shadow plugin.
|
// Files in this configuration will be bundled into your mod using the Shadow plugin.
|
||||||
// Don't use the `shadow` configuration from the plugin itself as it's meant for excluding files.
|
// Don't use the `shadow` configuration from the plugin itself as it's meant for excluding files.
|
||||||
@ -24,26 +30,19 @@ configurations {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
|
||||||
maven {
|
|
||||||
name = 'NeoForged'
|
|
||||||
url = 'https://maven.neoforged.net/releases'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
neoForge "net.neoforged:neoforge:$rootProject.neoforge_version"
|
forge "net.minecraftforge:forge:$rootProject.forge_version"
|
||||||
|
|
||||||
modImplementation "dev.architectury:architectury-neoforge:$rootProject.architectury_api_version"
|
modImplementation "dev.architectury:architectury-forge:$rootProject.architectury_api_version"
|
||||||
|
|
||||||
common(project(path: ':common', configuration: 'namedElements')) { transitive false }
|
common(project(path: ':common', configuration: 'namedElements')) { transitive false }
|
||||||
shadowBundle project(path: ':common', configuration: 'transformProductionNeoForge')
|
shadowBundle project(path: ':common', configuration: 'transformProductionForge')
|
||||||
}
|
}
|
||||||
|
|
||||||
processResources {
|
processResources {
|
||||||
inputs.property 'version', project.version
|
inputs.property 'version', project.version
|
||||||
|
|
||||||
filesMatching('META-INF/neoforge.mods.toml') {
|
filesMatching('META-INF/mods.toml') {
|
||||||
expand version: project.version
|
expand version: project.version
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
1
forge/gradle.properties
Normal file
1
forge/gradle.properties
Normal file
@ -0,0 +1 @@
|
|||||||
|
loom.platform=forge
|
||||||
@ -0,0 +1,32 @@
|
|||||||
|
package io.lampnet.betterlodestones.forge;
|
||||||
|
|
||||||
|
import io.lampnet.betterlodestones.BetterLodestones;
|
||||||
|
import io.lampnet.betterlodestones.config.ConfigManager;
|
||||||
|
import io.lampnet.betterlodestones.forge.config.BetterLodestonesForgeConfig;
|
||||||
|
import dev.architectury.platform.forge.EventBuses;
|
||||||
|
import net.minecraftforge.fml.ModLoadingContext;
|
||||||
|
import net.minecraftforge.fml.common.Mod;
|
||||||
|
import net.minecraftforge.fml.config.ModConfig;
|
||||||
|
import net.minecraftforge.fml.event.config.ModConfigEvent;
|
||||||
|
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||||
|
|
||||||
|
@Mod(BetterLodestones.MOD_ID)
|
||||||
|
public final class BetterLodestonesForge {
|
||||||
|
public BetterLodestonesForge() {
|
||||||
|
var modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
|
||||||
|
EventBuses.registerModEventBus(BetterLodestones.MOD_ID, modEventBus);
|
||||||
|
ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, BetterLodestonesForgeConfig.SPEC, "better-lodestones.toml");
|
||||||
|
|
||||||
|
modEventBus.addListener(this::onConfigLoad);
|
||||||
|
|
||||||
|
BetterLodestones.init();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onConfigLoad(final ModConfigEvent event) {
|
||||||
|
if (event.getConfig().getSpec() == BetterLodestonesForgeConfig.SPEC) {
|
||||||
|
ConfigManager.setMaxLodestones(BetterLodestonesForgeConfig.getMaxLodestones());
|
||||||
|
ConfigManager.setUseModernLodestoneRecipe(BetterLodestonesForgeConfig.useModernLodestoneRecipe());
|
||||||
|
BetterLodestones.LOGGER.info("Loaded Forge config and updated ConfigManager.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,14 +1,14 @@
|
|||||||
package io.lampnet.betterlodestones.neoforge.config;
|
package io.lampnet.betterlodestones.forge.config;
|
||||||
|
|
||||||
import net.neoforged.neoforge.common.ModConfigSpec;
|
import net.minecraftforge.common.ForgeConfigSpec;
|
||||||
|
|
||||||
public class BetterLodestonesNeoForgeConfig {
|
public class BetterLodestonesForgeConfig {
|
||||||
public static final ModConfigSpec SPEC;
|
public static final ForgeConfigSpec SPEC;
|
||||||
public static final ModConfigSpec.IntValue MAX_LODESTONES;
|
public static final ForgeConfigSpec.IntValue MAX_LODESTONES;
|
||||||
public static final ModConfigSpec.BooleanValue USE_MODERN_LODESTONE_RECIPE;
|
public static final ForgeConfigSpec.BooleanValue USE_MODERN_LODESTONE_RECIPE;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
ModConfigSpec.Builder builder = new ModConfigSpec.Builder();
|
ForgeConfigSpec.Builder builder = new ForgeConfigSpec.Builder();
|
||||||
|
|
||||||
builder.comment("Maximum number of Lodestones that can be bound to a single compass")
|
builder.comment("Maximum number of Lodestones that can be bound to a single compass")
|
||||||
.comment("0 = No limit (default)")
|
.comment("0 = No limit (default)")
|
||||||
@ -1,6 +1,6 @@
|
|||||||
modLoader = "javafml"
|
modLoader = "javafml"
|
||||||
loaderVersion = "[2,)"
|
loaderVersion = "[47,)"
|
||||||
issueTrackerURL = "https://github.com/C4ndle/better-lodestones/issues"
|
#issueTrackerURL = ""
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
|
|
||||||
[[mods]]
|
[[mods]]
|
||||||
@ -12,27 +12,23 @@ description = 'Reworks Lodestone system, allowing Compasses to be bound to multi
|
|||||||
|
|
||||||
#logoFile = ""
|
#logoFile = ""
|
||||||
|
|
||||||
[[mixins]]
|
|
||||||
type = "COMMON"
|
|
||||||
config = "better_lodestones.mixins.json"
|
|
||||||
|
|
||||||
[[dependencies.better_lodestones]]
|
[[dependencies.better_lodestones]]
|
||||||
modId = "neoforge"
|
modId = "forge"
|
||||||
mandatory = true
|
mandatory = true
|
||||||
versionRange = "[21.0,)"
|
versionRange = "[47,)"
|
||||||
ordering = "NONE"
|
ordering = "NONE"
|
||||||
side = "BOTH"
|
side = "BOTH"
|
||||||
|
|
||||||
[[dependencies.better_lodestones]]
|
[[dependencies.better_lodestones]]
|
||||||
modId = "minecraft"
|
modId = "minecraft"
|
||||||
mandatory = true
|
mandatory = true
|
||||||
versionRange = "[1.21.1,)"
|
versionRange = "[1.20.1,)"
|
||||||
ordering = "NONE"
|
ordering = "NONE"
|
||||||
side = "BOTH"
|
side = "BOTH"
|
||||||
|
|
||||||
[[dependencies.better_lodestones]]
|
[[dependencies.better_lodestones]]
|
||||||
modId = "architectury"
|
modId = "architectury"
|
||||||
mandatory = true
|
mandatory = true
|
||||||
versionRange = "[13.0,)"
|
versionRange = "[9.2.14,)"
|
||||||
ordering = "AFTER"
|
ordering = "AFTER"
|
||||||
side = "BOTH"
|
side = "BOTH"
|
||||||
@ -2,16 +2,14 @@
|
|||||||
org.gradle.jvmargs=-Xmx2G
|
org.gradle.jvmargs=-Xmx2G
|
||||||
org.gradle.parallel=true
|
org.gradle.parallel=true
|
||||||
# Mod properties
|
# Mod properties
|
||||||
mod_version=0.10
|
mod_version=0.9
|
||||||
maven_group=io.lampnet
|
maven_group=io.lampnet
|
||||||
archives_name=better-lodestones
|
archives_name=better-lodestones
|
||||||
enabled_platforms=fabric,neoforge
|
enabled_platforms=fabric,forge
|
||||||
# Minecraft properties
|
# Minecraft properties
|
||||||
minecraft_version=1.21.1
|
minecraft_version=1.20.1
|
||||||
# Dependencies
|
# Dependencies
|
||||||
architectury_api_version=13.0.8
|
architectury_api_version=9.2.14
|
||||||
fabric_loader_version=0.17.2
|
fabric_loader_version=0.17.2
|
||||||
fabric_api_version=0.116.6+1.21.1
|
fabric_api_version=0.92.6+1.20.1
|
||||||
neoforge_version=21.1.209
|
forge_version=1.20.1-47.4.9
|
||||||
|
|
||||||
loom.experimental.official_data_components=true
|
|
||||||
|
|||||||
@ -1 +0,0 @@
|
|||||||
loom.platform=neoforge
|
|
||||||
@ -1,29 +0,0 @@
|
|||||||
package io.lampnet.betterlodestones.neoforge;
|
|
||||||
|
|
||||||
import io.lampnet.betterlodestones.BetterLodestones;
|
|
||||||
import io.lampnet.betterlodestones.config.ConfigManager;
|
|
||||||
import io.lampnet.betterlodestones.neoforge.config.BetterLodestonesNeoForgeConfig;
|
|
||||||
import net.neoforged.fml.ModContainer;
|
|
||||||
import net.neoforged.fml.common.Mod;
|
|
||||||
import net.neoforged.fml.config.ModConfig;
|
|
||||||
import net.neoforged.fml.event.config.ModConfigEvent;
|
|
||||||
import net.neoforged.bus.api.IEventBus;
|
|
||||||
|
|
||||||
@Mod(BetterLodestones.MOD_ID)
|
|
||||||
public final class BetterLodestonesNeoForge {
|
|
||||||
public BetterLodestonesNeoForge(IEventBus modEventBus, ModContainer modContainer) {
|
|
||||||
modContainer.registerConfig(ModConfig.Type.COMMON, BetterLodestonesNeoForgeConfig.SPEC, "better-lodestones.toml");
|
|
||||||
|
|
||||||
modEventBus.addListener(this::onConfigLoad);
|
|
||||||
|
|
||||||
BetterLodestones.init();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void onConfigLoad(final ModConfigEvent event) {
|
|
||||||
if (event.getConfig().getSpec() == BetterLodestonesNeoForgeConfig.SPEC) {
|
|
||||||
ConfigManager.setMaxLodestones(BetterLodestonesNeoForgeConfig.getMaxLodestones());
|
|
||||||
ConfigManager.setUseModernLodestoneRecipe(BetterLodestonesNeoForgeConfig.useModernLodestoneRecipe());
|
|
||||||
BetterLodestones.LOGGER.info("Loaded NeoForge config and updated ConfigManager.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,17 +0,0 @@
|
|||||||
package io.lampnet.betterlodestones.neoforge;
|
|
||||||
|
|
||||||
import io.lampnet.betterlodestones.BetterLodestones;
|
|
||||||
import io.lampnet.betterlodestones.client.BetterLodestonesClient;
|
|
||||||
import net.neoforged.api.distmarker.Dist;
|
|
||||||
import net.neoforged.bus.api.SubscribeEvent;
|
|
||||||
import net.neoforged.fml.common.EventBusSubscriber;
|
|
||||||
import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent;
|
|
||||||
|
|
||||||
@EventBusSubscriber(modid = BetterLodestones.MOD_ID, value = Dist.CLIENT)
|
|
||||||
public class BetterLodestonesNeoForgeClient {
|
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
public static void onClientSetup(FMLClientSetupEvent event) {
|
|
||||||
event.enqueueWork(BetterLodestonesClient::initClient);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -7,8 +7,8 @@ pluginManagement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rootProject.name = "Better Lodestones"
|
rootProject.name = 'better_lodestones'
|
||||||
|
|
||||||
include('common')
|
include 'common'
|
||||||
include('fabric')
|
include 'fabric'
|
||||||
include('neoforge')
|
include 'forge'
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user