Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b3b4e48071 | |||
| 8266691770 |
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,7 +1,8 @@
|
|||||||
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 'architectury-plugin' version '3.4-SNAPSHOT'
|
|
||||||
id 'com.github.johnrengelman.shadow' version '8.1.1' apply false
|
id 'com.github.johnrengelman.shadow' version '8.1.1' apply false
|
||||||
|
id 'architectury-plugin' version '3.4-SNAPSHOT'
|
||||||
}
|
}
|
||||||
|
|
||||||
architectury {
|
architectury {
|
||||||
@ -23,13 +23,7 @@ subprojects {
|
|||||||
archivesName = "$rootProject.archives_name-$project.name"
|
archivesName = "$rootProject.archives_name-$project.name"
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
// repositories are declared in settings.gradle
|
||||||
// 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"
|
||||||
@ -42,12 +36,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_17
|
sourceCompatibility = JavaVersion.VERSION_21
|
||||||
targetCompatibility = JavaVersion.VERSION_17
|
targetCompatibility = JavaVersion.VERSION_21
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.withType(JavaCompile).configureEach {
|
tasks.withType(JavaCompile).configureEach {
|
||||||
it.options.release = 17
|
it.options.release = 21
|
||||||
}
|
}
|
||||||
|
|
||||||
// Configure Maven publishing.
|
// Configure Maven publishing.
|
||||||
|
|||||||
@ -3,7 +3,9 @@ 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"
|
||||||
|
|
||||||
modImplementation "dev.architectury:architectury:$rootProject.architectury_api_version"
|
modApi "dev.architectury:architectury:$rootProject.architectury_api_version"
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
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;
|
||||||
@ -10,6 +11,7 @@ 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,125 +1,71 @@
|
|||||||
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.registries.Registries;
|
import net.minecraft.core.component.DataComponents;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
|
||||||
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.level.Level;
|
|
||||||
import net.minecraft.world.level.block.Blocks;
|
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.item.CompassItem;
|
import net.minecraft.world.item.CompassItem;
|
||||||
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
import net.minecraft.world.item.component.LodestoneTracker;
|
||||||
|
import net.minecraft.world.level.Level;
|
||||||
|
import net.minecraft.world.level.block.Blocks;
|
||||||
|
|
||||||
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 {
|
||||||
private static final String LODESTONES_KEY = "BetterLodestones";
|
|
||||||
private static final String CURRENT_INDEX_KEY = "CurrentLodestoneIndex";
|
|
||||||
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 List<GlobalPos> getLodestones(ItemStack compass) {
|
public static List<GlobalPos> getLodestones(ItemStack compass) {
|
||||||
List<GlobalPos> lodestones = new ArrayList<>();
|
List<GlobalPos> lodestones = compass.get(BetterLodestonesComponents.LODESTONES.get());
|
||||||
CompoundTag tag = compass.getTag();
|
return lodestones != null ? lodestones : Collections.emptyList();
|
||||||
if (tag == null || !tag.contains(LODESTONES_KEY)) {
|
}
|
||||||
return lodestones;
|
|
||||||
}
|
|
||||||
|
|
||||||
ListTag lodestoneList = tag.getList(LODESTONES_KEY, Tag.TAG_COMPOUND);
|
public static void syncVanillaLodestoneTracker(ItemStack compass) {
|
||||||
for (int i = 0; i < lodestoneList.size(); i++) {
|
Optional<GlobalPos> currentLodestone = getCurrentLodestone(compass);
|
||||||
CompoundTag lodestoneTag = lodestoneList.getCompound(i);
|
if (currentLodestone.isPresent()) {
|
||||||
|
boolean tracked = !hasBrokenLodestone(compass);
|
||||||
int x = lodestoneTag.getInt(POS_X_KEY);
|
compass.set(DataComponents.LODESTONE_TRACKER, new LodestoneTracker(currentLodestone, tracked));
|
||||||
int y = lodestoneTag.getInt(POS_Y_KEY);
|
} else {
|
||||||
int z = lodestoneTag.getInt(POS_Z_KEY);
|
compass.remove(DataComponents.LODESTONE_TRACKER);
|
||||||
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) {
|
||||||
CompoundTag tag = compass.getOrCreateTag();
|
List<GlobalPos> lodestones = new ArrayList<>(getLodestones(compass));
|
||||||
ListTag lodestoneList = tag.getList(LODESTONES_KEY, Tag.TAG_COMPOUND);
|
if (!lodestones.contains(lodestone)) {
|
||||||
|
lodestones.add(lodestone);
|
||||||
for (int i = 0; i < lodestoneList.size(); i++) {
|
compass.set(BetterLodestonesComponents.LODESTONES.get(), lodestones);
|
||||||
CompoundTag existing = lodestoneList.getCompound(i);
|
if (lodestones.size() == 1) {
|
||||||
if (isSameLodestone(existing, lodestone)) {
|
compass.set(BetterLodestonesComponents.CURRENT_LODESTONE_INDEX.get(), 0);
|
||||||
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) {
|
||||||
CompoundTag tag = compass.getTag();
|
List<GlobalPos> lodestones = new ArrayList<>(getLodestones(compass));
|
||||||
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)) {
|
||||||
for (int i = lodestoneList.size() - 1; i >= 0; i--) {
|
if (lodestones.isEmpty()) {
|
||||||
CompoundTag existing = lodestoneList.getCompound(i);
|
compass.remove(BetterLodestonesComponents.LODESTONES.get());
|
||||||
if (isSameLodestone(existing, lodestone)) {
|
compass.remove(BetterLodestonesComponents.CURRENT_LODESTONE_INDEX.get());
|
||||||
lodestoneList.remove(i);
|
} else {
|
||||||
|
if (currentIndex >= lodestones.size()) {
|
||||||
if (i < currentIndex) {
|
currentIndex = lodestones.size() - 1;
|
||||||
currentIndex--;
|
|
||||||
} else if (i == currentIndex && currentIndex >= lodestoneList.size()) {
|
|
||||||
currentIndex = lodestoneList.size() - 1;
|
|
||||||
}
|
}
|
||||||
break;
|
compass.set(BetterLodestonesComponents.LODESTONES.get(), lodestones);
|
||||||
|
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) {
|
||||||
CompoundTag tag = compass.getTag();
|
return compass.getOrDefault(BetterLodestonesComponents.CURRENT_LODESTONE_INDEX.get(), 0);
|
||||||
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) {
|
||||||
@ -127,12 +73,10 @@ 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));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,12 +86,9 @@ 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)) {
|
||||||
@ -164,12 +105,10 @@ public class CompassDataHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void clearAllLodestones(ItemStack compass) {
|
public static void clearAllLodestones(ItemStack compass) {
|
||||||
CompoundTag tag = compass.getTag();
|
compass.remove(BetterLodestonesComponents.LODESTONES.get());
|
||||||
if (tag != null) {
|
compass.remove(BetterLodestonesComponents.CURRENT_LODESTONE_INDEX.get());
|
||||||
tag.remove(LODESTONES_KEY);
|
compass.remove(BetterLodestonesComponents.BROKEN_LODESTONE.get());
|
||||||
tag.remove(CURRENT_INDEX_KEY);
|
syncVanillaLodestoneTracker(compass);
|
||||||
tag.remove(BROKEN_LODESTONE_FLAG);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void removeCurrentLodestone(ItemStack compass) {
|
public static void removeCurrentLodestone(ItemStack compass) {
|
||||||
@ -178,19 +117,7 @@ public class CompassDataHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isLodestoneAlreadyBound(ItemStack compass, GlobalPos lodestone) {
|
public static boolean isLodestoneAlreadyBound(ItemStack compass, GlobalPos lodestone) {
|
||||||
CompoundTag tag = compass.getTag();
|
return getLodestones(compass).contains(lodestone);
|
||||||
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) {
|
||||||
@ -259,20 +186,17 @@ public class CompassDataHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void markLodestoneAsBroken(ItemStack compass) {
|
public static void markLodestoneAsBroken(ItemStack compass) {
|
||||||
CompoundTag tag = compass.getOrCreateTag();
|
compass.set(BetterLodestonesComponents.BROKEN_LODESTONE.get(), true);
|
||||||
tag.putBoolean(BROKEN_LODESTONE_FLAG, true);
|
syncVanillaLodestoneTracker(compass);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean hasBrokenLodestone(ItemStack compass) {
|
public static boolean hasBrokenLodestone(ItemStack compass) {
|
||||||
CompoundTag tag = compass.getTag();
|
return compass.getOrDefault(BetterLodestonesComponents.BROKEN_LODESTONE.get(), false);
|
||||||
return tag != null && tag.getBoolean(BROKEN_LODESTONE_FLAG);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void clearBrokenLodestoneFlag(ItemStack compass) {
|
public static void clearBrokenLodestoneFlag(ItemStack compass) {
|
||||||
CompoundTag tag = compass.getTag();
|
compass.remove(BetterLodestonesComponents.BROKEN_LODESTONE.get());
|
||||||
if (tag != null) {
|
syncVanillaLodestoneTracker(compass);
|
||||||
tag.remove(BROKEN_LODESTONE_FLAG);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void onLodestoneRemoved(Level level, BlockPos removedPos) {
|
public static void onLodestoneRemoved(Level level, BlockPos removedPos) {
|
||||||
@ -327,57 +251,21 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
CompoundTag tag = compass.getTag();
|
var lodestoneTarget = compass.get(DataComponents.LODESTONE_TRACKER);
|
||||||
if (tag == null) {
|
if (lodestoneTarget == 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,6 +1,7 @@
|
|||||||
package io.lampnet.betterlodestones.advancement;
|
package io.lampnet.betterlodestones.advancement;
|
||||||
|
|
||||||
import com.google.gson.JsonObject;
|
import com.mojang.serialization.Codec;
|
||||||
|
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.*;
|
||||||
@ -8,40 +9,31 @@ 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 = new ResourceLocation(BetterLodestones.MOD_ID, "dimensional_compass_binding");
|
static final ResourceLocation ID = ResourceLocation.fromNamespaceAndPath(BetterLodestones.MOD_ID, "dimensional_compass_binding");
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull ResourceLocation getId() {
|
public Codec<TriggerInstance> codec() {
|
||||||
return ID;
|
return TriggerInstance.CODEC;
|
||||||
}
|
|
||||||
|
|
||||||
@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 static class TriggerInstance extends AbstractCriterionTriggerInstance {
|
public record TriggerInstance(Optional<ContextAwarePredicate> player, int minDimensions) implements SimpleCriterionTrigger.SimpleInstance {
|
||||||
private final int minDimensions;
|
public static final Codec<TriggerInstance> CODEC = RecordCodecBuilder.create(instance -> instance.group(
|
||||||
|
ContextAwarePredicate.CODEC.optionalFieldOf("player").forGetter(TriggerInstance::player),
|
||||||
public TriggerInstance(ContextAwarePredicate player, int minDimensions) {
|
Codec.INT.fieldOf("min_dimensions").forGetter(TriggerInstance::minDimensions)
|
||||||
super(ID, player);
|
).apply(instance, TriggerInstance::new));
|
||||||
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);
|
||||||
@ -55,12 +47,5 @@ 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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,6 @@
|
|||||||
|
package io.lampnet.betterlodestones.client;
|
||||||
|
|
||||||
|
public class BetterLodestonesClient {
|
||||||
|
public static void initClient() {
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,34 @@
|
|||||||
|
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,6 +1,7 @@
|
|||||||
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;
|
||||||
@ -72,7 +73,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) {
|
||||||
BetterLodestonesRegistry.DIMENSIONAL_COMPASS_BINDING.trigger(serverPlayer, compass);
|
((DimensionalCompassBindingTrigger) BetterLodestonesRegistry.DIMENSIONAL_COMPASS_BINDING.get()).trigger(serverPlayer, compass);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
|
|||||||
@ -1,41 +0,0 @@
|
|||||||
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,19 +29,12 @@ 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, Level level, List<Component> tooltip, TooltipFlag flag, CallbackInfo ci) {
|
private void addCustomTooltip(ItemStack stack, Item.TooltipContext context, List<Component> tooltip, TooltipFlag flag, CallbackInfo ci) {
|
||||||
if (!(stack.getItem() instanceof CompassItem)) {
|
if (!(stack.getItem() instanceof CompassItem)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (level != null && !level.isClientSide()) {
|
// Tooltip is client-side, so we don't do server-side validation here
|
||||||
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) {
|
||||||
@ -61,9 +54,7 @@ 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.isLodestoneInDifferentDimension(level, lodestone)) {
|
if (CompassDataHandler.hasBrokenLodestone(stack)) {
|
||||||
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,6 +4,7 @@ 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;
|
||||||
@ -14,7 +15,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, CallbackInfo ci) {
|
private void onPlayerJoin(Connection connection, ServerPlayer player, CommonListenerCookie commonListenerCookie, 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.google.gson.JsonObject;
|
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||||
import io.lampnet.betterlodestones.CompassDataHandler;
|
import io.lampnet.betterlodestones.CompassDataHandler;
|
||||||
import net.minecraft.core.RegistryAccess;
|
import io.lampnet.betterlodestones.component.BetterLodestonesComponents;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.core.HolderLookup;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.network.codec.StreamCodec;
|
||||||
import net.minecraft.world.inventory.CraftingContainer;
|
import net.minecraft.world.item.crafting.CraftingInput;
|
||||||
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(ResourceLocation id, CraftingBookCategory category) {
|
public CompassUnbindingRecipe(CraftingBookCategory category) {
|
||||||
super(id, category);
|
super(category);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(CraftingContainer craftingContainer, Level level) {
|
public boolean matches(CraftingInput craftingInput, Level level) {
|
||||||
ItemStack compass = ItemStack.EMPTY;
|
ItemStack compass = ItemStack.EMPTY;
|
||||||
|
|
||||||
for (int i = 0; i < craftingContainer.getContainerSize(); ++i) {
|
for (int i = 0; i < craftingInput.size(); ++i) {
|
||||||
ItemStack currentStack = craftingContainer.getItem(i);
|
ItemStack currentStack = craftingInput.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,20 +39,15 @@ public class CompassUnbindingRecipe extends CustomRecipe {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (compass.isEmpty() || !compass.hasTag()) {
|
return !compass.isEmpty() && (compass.has(BetterLodestonesComponents.LODESTONES.get()) || compass.has(net.minecraft.core.component.DataComponents.LODESTONE_TRACKER));
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
CompoundTag tag = compass.getTag();
|
|
||||||
return tag != null && (tag.contains("LodestonePos") || tag.contains("BetterLodestones"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull ItemStack assemble(CraftingContainer craftingContainer, RegistryAccess registryAccess) {
|
public @NotNull ItemStack assemble(@NotNull CraftingInput craftingInput, @NotNull HolderLookup.Provider provider) {
|
||||||
ItemStack compass = ItemStack.EMPTY;
|
ItemStack compass = ItemStack.EMPTY;
|
||||||
|
|
||||||
for (int i = 0; i < craftingContainer.getContainerSize(); i++) {
|
for (int i = 0; i < craftingInput.size(); i++) {
|
||||||
ItemStack currentStack = craftingContainer.getItem(i);
|
ItemStack currentStack = craftingInput.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);
|
||||||
@ -81,24 +76,30 @@ public class CompassUnbindingRecipe extends CustomRecipe {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull RecipeSerializer<?> getSerializer() {
|
public @NotNull RecipeSerializer<?> getSerializer() {
|
||||||
return CompassUnbindingRecipeSerializer.INSTANCE;
|
return io.lampnet.betterlodestones.registry.BetterLodestonesRegistry.COMPASS_UNBINDING.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
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 CompassUnbindingRecipe fromJson(ResourceLocation recipeId, JsonObject json) {
|
public @NotNull com.mojang.serialization.MapCodec<CompassUnbindingRecipe> codec() {
|
||||||
return new CompassUnbindingRecipe(recipeId, CraftingBookCategory.MISC);
|
return CODEC;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull CompassUnbindingRecipe fromNetwork(ResourceLocation recipeId, FriendlyByteBuf buffer) {
|
public @NotNull StreamCodec<RegistryFriendlyByteBuf, CompassUnbindingRecipe> streamCodec() {
|
||||||
return new CompassUnbindingRecipe(recipeId, CraftingBookCategory.MISC);
|
return STREAM_CODEC;
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void toNetwork(FriendlyByteBuf buffer, CompassUnbindingRecipe recipe) {
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
package io.lampnet.betterlodestones.recipe;
|
package io.lampnet.betterlodestones.recipe;
|
||||||
|
|
||||||
import com.google.gson.JsonObject;
|
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||||
import io.lampnet.betterlodestones.config.ConfigManager;
|
import io.lampnet.betterlodestones.config.ConfigManager;
|
||||||
import net.minecraft.core.RegistryAccess;
|
import net.minecraft.core.HolderLookup;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.network.codec.StreamCodec;
|
||||||
import net.minecraft.world.inventory.CraftingContainer;
|
import net.minecraft.world.item.crafting.CraftingInput;
|
||||||
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(ResourceLocation id, CraftingBookCategory category) {
|
public ConfigurableLodestoneRecipe(CraftingBookCategory category) {
|
||||||
super(id, category);
|
super(category);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(CraftingContainer craftingContainer, Level level) {
|
public boolean matches(CraftingInput craftingInput, Level level) {
|
||||||
if (craftingContainer.getWidth() != 3 || craftingContainer.getHeight() != 3) {
|
if (craftingInput.width() != 3 || craftingInput.height() != 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 (!craftingContainer.getItem(4).is(expectedCenterItem)) {
|
if (!craftingInput.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 (!craftingContainer.getItem(i).is(Items.CHISELED_STONE_BRICKS)) {
|
if (!craftingInput.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 CraftingContainer craftingContainer, RegistryAccess registryAccess) {
|
public @NotNull ItemStack assemble(@NotNull CraftingInput craftingInput, @NotNull HolderLookup.Provider provider) {
|
||||||
return new ItemStack(Items.LODESTONE);
|
return new ItemStack(Items.LODESTONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,24 +54,29 @@ public class ConfigurableLodestoneRecipe extends CustomRecipe {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull RecipeSerializer<?> getSerializer() {
|
public @NotNull RecipeSerializer<?> getSerializer() {
|
||||||
return Serializer.INSTANCE;
|
return io.lampnet.betterlodestones.registry.BetterLodestonesRegistry.CONFIGURABLE_LODESTONE.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
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 ConfigurableLodestoneRecipe fromJson(ResourceLocation recipeId, JsonObject json) {
|
public @NotNull com.mojang.serialization.MapCodec<ConfigurableLodestoneRecipe> codec() {
|
||||||
return new ConfigurableLodestoneRecipe(recipeId, CraftingBookCategory.MISC);
|
return CODEC;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull ConfigurableLodestoneRecipe fromNetwork(ResourceLocation recipeId, FriendlyByteBuf buffer) {
|
public @NotNull StreamCodec<RegistryFriendlyByteBuf, ConfigurableLodestoneRecipe> streamCodec() {
|
||||||
return new ConfigurableLodestoneRecipe(recipeId, CraftingBookCategory.MISC);
|
return STREAM_CODEC;
|
||||||
}
|
|
||||||
|
|
||||||
@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.CriteriaTriggers;
|
import net.minecraft.advancements.CriterionTrigger;
|
||||||
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,10 +20,14 @@ 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 DimensionalCompassBindingTrigger DIMENSIONAL_COMPASS_BINDING = new DimensionalCompassBindingTrigger();
|
public static final DeferredRegister<CriterionTrigger<?>> CRITERION_TRIGGERS =
|
||||||
|
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();
|
||||||
CriteriaTriggers.register(DIMENSIONAL_COMPASS_BINDING);
|
CRITERION_TRIGGERS.register();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,7 +7,6 @@
|
|||||||
],
|
],
|
||||||
"mixins": [
|
"mixins": [
|
||||||
"CompassItemMixin",
|
"CompassItemMixin",
|
||||||
"CompassItemMixinPointing",
|
|
||||||
"CompassTooltipMixin",
|
"CompassTooltipMixin",
|
||||||
"InventoryInteractionMixin",
|
"InventoryInteractionMixin",
|
||||||
"ItemPickupMixin",
|
"ItemPickupMixin",
|
||||||
|
|||||||
@ -1,9 +1,11 @@
|
|||||||
{
|
{
|
||||||
"parent": "minecraft:nether/use_lodestone",
|
"parent": "minecraft:adventure/use_lodestone",
|
||||||
"display": {
|
"display": {
|
||||||
"icon": {
|
"icon": {
|
||||||
"item": "minecraft:compass",
|
"id": "minecraft:compass",
|
||||||
"nbt": "{CustomModelData:1}"
|
"components": {
|
||||||
|
"minecraft:custom_model_data": 1
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"title": {
|
"title": {
|
||||||
"translate": "advancements.better_lodestones.dimensional_lodestone_master.title"
|
"translate": "advancements.better_lodestones.dimensional_lodestone_master.title"
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
{
|
{
|
||||||
"type": "better_lodestones:compass_unbinding"
|
"type": "better_lodestones:compass_unbinding",
|
||||||
|
"category": "misc"
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
{
|
{
|
||||||
"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": {
|
||||||
"item": "minecraft:lodestone"
|
"id": "minecraft:lodestone"
|
||||||
},
|
},
|
||||||
"title": {
|
"title": {
|
||||||
"translate": "advancements.nether.use_lodestone.title"
|
"translate": "advancements.nether.use_lodestone.title"
|
||||||
@ -19,22 +19,16 @@
|
|||||||
"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"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"block": "minecraft:lodestone"
|
"location": {
|
||||||
|
"block": {
|
||||||
|
"blocks": "minecraft:lodestone"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,3 +1,4 @@
|
|||||||
{
|
{
|
||||||
"type": "better_lodestones:configurable_lodestone"
|
"type": "better_lodestones:configurable_lodestone",
|
||||||
|
"category": "building"
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,11 @@
|
|||||||
|
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,6 +16,9 @@
|
|||||||
"entrypoints": {
|
"entrypoints": {
|
||||||
"main": [
|
"main": [
|
||||||
"io.lampnet.betterlodestones.fabric.BetterLodestonesFabric"
|
"io.lampnet.betterlodestones.fabric.BetterLodestonesFabric"
|
||||||
|
],
|
||||||
|
"client": [
|
||||||
|
"io.lampnet.betterlodestones.fabric.BetterLodestonesFabricClient"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"mixins": [
|
"mixins": [
|
||||||
@ -23,9 +26,9 @@
|
|||||||
],
|
],
|
||||||
"depends": {
|
"depends": {
|
||||||
"fabricloader": ">=0.17.2",
|
"fabricloader": ">=0.17.2",
|
||||||
"minecraft": "~1.20.1",
|
"minecraft": "~1.21.1",
|
||||||
"java": ">=17",
|
"java": ">=21",
|
||||||
"architectury": ">=9.2.14",
|
"architectury": ">=13.0.8",
|
||||||
"fabric-api": "*"
|
"fabric-api": "*"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1 +0,0 @@
|
|||||||
loom.platform=forge
|
|
||||||
@ -1,32 +0,0 @@
|
|||||||
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.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -2,14 +2,16 @@
|
|||||||
org.gradle.jvmargs=-Xmx2G
|
org.gradle.jvmargs=-Xmx2G
|
||||||
org.gradle.parallel=true
|
org.gradle.parallel=true
|
||||||
# Mod properties
|
# Mod properties
|
||||||
mod_version=0.9
|
mod_version=0.10
|
||||||
maven_group=io.lampnet
|
maven_group=io.lampnet
|
||||||
archives_name=better-lodestones
|
archives_name=better-lodestones
|
||||||
enabled_platforms=fabric,forge
|
enabled_platforms=fabric,neoforge
|
||||||
# Minecraft properties
|
# Minecraft properties
|
||||||
minecraft_version=1.20.1
|
minecraft_version=1.21.1
|
||||||
# Dependencies
|
# Dependencies
|
||||||
architectury_api_version=9.2.14
|
architectury_api_version=13.0.8
|
||||||
fabric_loader_version=0.17.2
|
fabric_loader_version=0.17.2
|
||||||
fabric_api_version=0.92.6+1.20.1
|
fabric_api_version=0.116.6+1.21.1
|
||||||
forge_version=1.20.1-47.4.9
|
neoforge_version=21.1.209
|
||||||
|
|
||||||
|
loom.experimental.official_data_components=true
|
||||||
|
|||||||
@ -2,15 +2,9 @@ plugins {
|
|||||||
id 'com.github.johnrengelman.shadow'
|
id 'com.github.johnrengelman.shadow'
|
||||||
}
|
}
|
||||||
|
|
||||||
loom {
|
|
||||||
forge {
|
|
||||||
mixinConfig "better_lodestones.mixins.json"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
architectury {
|
architectury {
|
||||||
platformSetupLoomIde()
|
platformSetupLoomIde()
|
||||||
forge()
|
neoForge()
|
||||||
}
|
}
|
||||||
|
|
||||||
configurations {
|
configurations {
|
||||||
@ -20,7 +14,7 @@ configurations {
|
|||||||
}
|
}
|
||||||
compileClasspath.extendsFrom common
|
compileClasspath.extendsFrom common
|
||||||
runtimeClasspath.extendsFrom common
|
runtimeClasspath.extendsFrom common
|
||||||
developmentForge.extendsFrom common
|
developmentNeoForge.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.
|
||||||
@ -30,19 +24,26 @@ configurations {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
repositories {
|
||||||
forge "net.minecraftforge:forge:$rootProject.forge_version"
|
maven {
|
||||||
|
name = 'NeoForged'
|
||||||
|
url = 'https://maven.neoforged.net/releases'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
modImplementation "dev.architectury:architectury-forge:$rootProject.architectury_api_version"
|
dependencies {
|
||||||
|
neoForge "net.neoforged:neoforge:$rootProject.neoforge_version"
|
||||||
|
|
||||||
|
modImplementation "dev.architectury:architectury-neoforge:$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: 'transformProductionForge')
|
shadowBundle project(path: ':common', configuration: 'transformProductionNeoForge')
|
||||||
}
|
}
|
||||||
|
|
||||||
processResources {
|
processResources {
|
||||||
inputs.property 'version', project.version
|
inputs.property 'version', project.version
|
||||||
|
|
||||||
filesMatching('META-INF/mods.toml') {
|
filesMatching('META-INF/neoforge.mods.toml') {
|
||||||
expand version: project.version
|
expand version: project.version
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
1
neoforge/gradle.properties
Normal file
1
neoforge/gradle.properties
Normal file
@ -0,0 +1 @@
|
|||||||
|
loom.platform=neoforge
|
||||||
@ -0,0 +1,29 @@
|
|||||||
|
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.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,17 @@
|
|||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,14 +1,14 @@
|
|||||||
package io.lampnet.betterlodestones.forge.config;
|
package io.lampnet.betterlodestones.neoforge.config;
|
||||||
|
|
||||||
import net.minecraftforge.common.ForgeConfigSpec;
|
import net.neoforged.neoforge.common.ModConfigSpec;
|
||||||
|
|
||||||
public class BetterLodestonesForgeConfig {
|
public class BetterLodestonesNeoForgeConfig {
|
||||||
public static final ForgeConfigSpec SPEC;
|
public static final ModConfigSpec SPEC;
|
||||||
public static final ForgeConfigSpec.IntValue MAX_LODESTONES;
|
public static final ModConfigSpec.IntValue MAX_LODESTONES;
|
||||||
public static final ForgeConfigSpec.BooleanValue USE_MODERN_LODESTONE_RECIPE;
|
public static final ModConfigSpec.BooleanValue USE_MODERN_LODESTONE_RECIPE;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
ForgeConfigSpec.Builder builder = new ForgeConfigSpec.Builder();
|
ModConfigSpec.Builder builder = new ModConfigSpec.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 = "[47,)"
|
loaderVersion = "[2,)"
|
||||||
#issueTrackerURL = ""
|
issueTrackerURL = "https://github.com/C4ndle/better-lodestones/issues"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
|
|
||||||
[[mods]]
|
[[mods]]
|
||||||
@ -12,23 +12,27 @@ 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 = "forge"
|
modId = "neoforge"
|
||||||
mandatory = true
|
mandatory = true
|
||||||
versionRange = "[47,)"
|
versionRange = "[21.0,)"
|
||||||
ordering = "NONE"
|
ordering = "NONE"
|
||||||
side = "BOTH"
|
side = "BOTH"
|
||||||
|
|
||||||
[[dependencies.better_lodestones]]
|
[[dependencies.better_lodestones]]
|
||||||
modId = "minecraft"
|
modId = "minecraft"
|
||||||
mandatory = true
|
mandatory = true
|
||||||
versionRange = "[1.20.1,)"
|
versionRange = "[1.21.1,)"
|
||||||
ordering = "NONE"
|
ordering = "NONE"
|
||||||
side = "BOTH"
|
side = "BOTH"
|
||||||
|
|
||||||
[[dependencies.better_lodestones]]
|
[[dependencies.better_lodestones]]
|
||||||
modId = "architectury"
|
modId = "architectury"
|
||||||
mandatory = true
|
mandatory = true
|
||||||
versionRange = "[9.2.14,)"
|
versionRange = "[13.0,)"
|
||||||
ordering = "AFTER"
|
ordering = "AFTER"
|
||||||
side = "BOTH"
|
side = "BOTH"
|
||||||
@ -7,8 +7,8 @@ pluginManagement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rootProject.name = 'better_lodestones'
|
rootProject.name = "Better Lodestones"
|
||||||
|
|
||||||
include 'common'
|
include('common')
|
||||||
include 'fabric'
|
include('fabric')
|
||||||
include 'forge'
|
include('neoforge')
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user