Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b3b4e48071 | |||
| 8266691770 |
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,7 +1,8 @@
|
||||
build/
|
||||
bin/
|
||||
run/
|
||||
.idea/
|
||||
.c*
|
||||
.gradle/
|
||||
gradle/
|
||||
.architectury-transformer/
|
||||
.architectury-transformer/
|
||||
|
||||
16
build.gradle
16
build.gradle
@ -1,7 +1,7 @@
|
||||
plugins {
|
||||
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 'architectury-plugin' version '3.4-SNAPSHOT'
|
||||
}
|
||||
|
||||
architectury {
|
||||
@ -23,13 +23,7 @@ subprojects {
|
||||
archivesName = "$rootProject.archives_name-$project.name"
|
||||
}
|
||||
|
||||
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.
|
||||
}
|
||||
// repositories are declared in settings.gradle
|
||||
|
||||
dependencies {
|
||||
minecraft "net.minecraft:minecraft:$rootProject.minecraft_version"
|
||||
@ -42,12 +36,12 @@ subprojects {
|
||||
// If you remove this line, sources will not be generated.
|
||||
withSourcesJar()
|
||||
|
||||
sourceCompatibility = JavaVersion.VERSION_17
|
||||
targetCompatibility = JavaVersion.VERSION_17
|
||||
sourceCompatibility = JavaVersion.VERSION_21
|
||||
targetCompatibility = JavaVersion.VERSION_21
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
it.options.release = 17
|
||||
it.options.release = 21
|
||||
}
|
||||
|
||||
// Configure Maven publishing.
|
||||
|
||||
@ -3,7 +3,9 @@ architectury {
|
||||
}
|
||||
|
||||
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 "dev.architectury:architectury:$rootProject.architectury_api_version"
|
||||
modApi "dev.architectury:architectury:$rootProject.architectury_api_version"
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package io.lampnet.betterlodestones;
|
||||
|
||||
import io.lampnet.betterlodestones.component.BetterLodestonesComponents;
|
||||
import io.lampnet.betterlodestones.config.ConfigManager;
|
||||
import io.lampnet.betterlodestones.registry.BetterLodestonesRegistry;
|
||||
import org.slf4j.Logger;
|
||||
@ -10,6 +11,7 @@ public final class BetterLodestones {
|
||||
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
|
||||
|
||||
public static void init() {
|
||||
BetterLodestonesComponents.init();
|
||||
BetterLodestonesRegistry.init();
|
||||
|
||||
LOGGER.info("Better Lodestones initialized.");
|
||||
|
||||
@ -1,125 +1,71 @@
|
||||
package io.lampnet.betterlodestones;
|
||||
|
||||
import io.lampnet.betterlodestones.component.BetterLodestonesComponents;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.GlobalPos;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
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.core.component.DataComponents;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
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.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
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) {
|
||||
List<GlobalPos> lodestones = new ArrayList<>();
|
||||
CompoundTag tag = compass.getTag();
|
||||
if (tag == null || !tag.contains(LODESTONES_KEY)) {
|
||||
return lodestones;
|
||||
}
|
||||
List<GlobalPos> lodestones = compass.get(BetterLodestonesComponents.LODESTONES.get());
|
||||
return lodestones != null ? lodestones : Collections.emptyList();
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
public static void syncVanillaLodestoneTracker(ItemStack compass) {
|
||||
Optional<GlobalPos> currentLodestone = getCurrentLodestone(compass);
|
||||
if (currentLodestone.isPresent()) {
|
||||
boolean tracked = !hasBrokenLodestone(compass);
|
||||
compass.set(DataComponents.LODESTONE_TRACKER, new LodestoneTracker(currentLodestone, tracked));
|
||||
} else {
|
||||
compass.remove(DataComponents.LODESTONE_TRACKER);
|
||||
}
|
||||
|
||||
return lodestones;
|
||||
}
|
||||
|
||||
public static void addLodestone(ItemStack compass, GlobalPos lodestone) {
|
||||
CompoundTag tag = compass.getOrCreateTag();
|
||||
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;
|
||||
List<GlobalPos> lodestones = new ArrayList<>(getLodestones(compass));
|
||||
if (!lodestones.contains(lodestone)) {
|
||||
lodestones.add(lodestone);
|
||||
compass.set(BetterLodestonesComponents.LODESTONES.get(), lodestones);
|
||||
if (lodestones.size() == 1) {
|
||||
compass.set(BetterLodestonesComponents.CURRENT_LODESTONE_INDEX.get(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
syncVanillaLodestoneTracker(compass);
|
||||
}
|
||||
}
|
||||
|
||||
public static void removeLodestone(ItemStack compass, GlobalPos lodestone) {
|
||||
CompoundTag tag = compass.getTag();
|
||||
if (tag == null || !tag.contains(LODESTONES_KEY)) {
|
||||
return;
|
||||
}
|
||||
|
||||
ListTag lodestoneList = tag.getList(LODESTONES_KEY, Tag.TAG_COMPOUND);
|
||||
List<GlobalPos> lodestones = new ArrayList<>(getLodestones(compass));
|
||||
int currentIndex = getCurrentLodestoneIndex(compass);
|
||||
|
||||
for (int i = lodestoneList.size() - 1; i >= 0; i--) {
|
||||
CompoundTag existing = lodestoneList.getCompound(i);
|
||||
if (isSameLodestone(existing, lodestone)) {
|
||||
lodestoneList.remove(i);
|
||||
|
||||
if (i < currentIndex) {
|
||||
currentIndex--;
|
||||
} else if (i == currentIndex && currentIndex >= lodestoneList.size()) {
|
||||
currentIndex = lodestoneList.size() - 1;
|
||||
if (lodestones.remove(lodestone)) {
|
||||
if (lodestones.isEmpty()) {
|
||||
compass.remove(BetterLodestonesComponents.LODESTONES.get());
|
||||
compass.remove(BetterLodestonesComponents.CURRENT_LODESTONE_INDEX.get());
|
||||
} else {
|
||||
if (currentIndex >= lodestones.size()) {
|
||||
currentIndex = lodestones.size() - 1;
|
||||
}
|
||||
break;
|
||||
compass.set(BetterLodestonesComponents.LODESTONES.get(), lodestones);
|
||||
compass.set(BetterLodestonesComponents.CURRENT_LODESTONE_INDEX.get(), Math.max(0, currentIndex));
|
||||
}
|
||||
}
|
||||
|
||||
if (lodestoneList.isEmpty()) {
|
||||
tag.remove(CURRENT_INDEX_KEY);
|
||||
tag.remove(LODESTONES_KEY);
|
||||
} else {
|
||||
tag.putInt(CURRENT_INDEX_KEY, Math.max(0, currentIndex));
|
||||
syncVanillaLodestoneTracker(compass);
|
||||
}
|
||||
}
|
||||
|
||||
public static int getCurrentLodestoneIndex(ItemStack compass) {
|
||||
CompoundTag tag = compass.getTag();
|
||||
if (tag == null) {
|
||||
return 0;
|
||||
}
|
||||
return tag.getInt(CURRENT_INDEX_KEY);
|
||||
return compass.getOrDefault(BetterLodestonesComponents.CURRENT_LODESTONE_INDEX.get(), 0);
|
||||
}
|
||||
|
||||
public static Optional<GlobalPos> getCurrentLodestone(ItemStack compass) {
|
||||
@ -127,12 +73,10 @@ public class CompassDataHandler {
|
||||
if (lodestones.isEmpty()) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
int index = getCurrentLodestoneIndex(compass);
|
||||
if (index < 0 || index >= lodestones.size()) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
return Optional.of(lodestones.get(index));
|
||||
}
|
||||
|
||||
@ -142,12 +86,9 @@ public class CompassDataHandler {
|
||||
validateCurrentLodestone(compass, level);
|
||||
return;
|
||||
}
|
||||
|
||||
int currentIndex = getCurrentLodestoneIndex(compass);
|
||||
int nextIndex = (currentIndex + 1) % lodestones.size();
|
||||
|
||||
CompoundTag tag = compass.getOrCreateTag();
|
||||
tag.putInt(CURRENT_INDEX_KEY, nextIndex);
|
||||
compass.set(BetterLodestonesComponents.CURRENT_LODESTONE_INDEX.get(), nextIndex);
|
||||
|
||||
GlobalPos newLodestone = lodestones.get(nextIndex);
|
||||
if (isLodestoneValid(level, newLodestone)) {
|
||||
@ -164,12 +105,10 @@ public class CompassDataHandler {
|
||||
}
|
||||
|
||||
public static void clearAllLodestones(ItemStack compass) {
|
||||
CompoundTag tag = compass.getTag();
|
||||
if (tag != null) {
|
||||
tag.remove(LODESTONES_KEY);
|
||||
tag.remove(CURRENT_INDEX_KEY);
|
||||
tag.remove(BROKEN_LODESTONE_FLAG);
|
||||
}
|
||||
compass.remove(BetterLodestonesComponents.LODESTONES.get());
|
||||
compass.remove(BetterLodestonesComponents.CURRENT_LODESTONE_INDEX.get());
|
||||
compass.remove(BetterLodestonesComponents.BROKEN_LODESTONE.get());
|
||||
syncVanillaLodestoneTracker(compass);
|
||||
}
|
||||
|
||||
public static void removeCurrentLodestone(ItemStack compass) {
|
||||
@ -178,19 +117,7 @@ public class CompassDataHandler {
|
||||
}
|
||||
|
||||
public static boolean isLodestoneAlreadyBound(ItemStack compass, GlobalPos 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;
|
||||
return getLodestones(compass).contains(lodestone);
|
||||
}
|
||||
|
||||
public static boolean isLodestoneValid(Level level, GlobalPos lodestone) {
|
||||
@ -259,20 +186,17 @@ public class CompassDataHandler {
|
||||
}
|
||||
|
||||
public static void markLodestoneAsBroken(ItemStack compass) {
|
||||
CompoundTag tag = compass.getOrCreateTag();
|
||||
tag.putBoolean(BROKEN_LODESTONE_FLAG, true);
|
||||
compass.set(BetterLodestonesComponents.BROKEN_LODESTONE.get(), true);
|
||||
syncVanillaLodestoneTracker(compass);
|
||||
}
|
||||
|
||||
public static boolean hasBrokenLodestone(ItemStack compass) {
|
||||
CompoundTag tag = compass.getTag();
|
||||
return tag != null && tag.getBoolean(BROKEN_LODESTONE_FLAG);
|
||||
return compass.getOrDefault(BetterLodestonesComponents.BROKEN_LODESTONE.get(), false);
|
||||
}
|
||||
|
||||
public static void clearBrokenLodestoneFlag(ItemStack compass) {
|
||||
CompoundTag tag = compass.getTag();
|
||||
if (tag != null) {
|
||||
tag.remove(BROKEN_LODESTONE_FLAG);
|
||||
}
|
||||
compass.remove(BetterLodestonesComponents.BROKEN_LODESTONE.get());
|
||||
syncVanillaLodestoneTracker(compass);
|
||||
}
|
||||
|
||||
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) {
|
||||
if (compass == null || !(compass.getItem() instanceof CompassItem)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
CompoundTag tag = compass.getTag();
|
||||
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
|
||||
|
||||
var lodestoneTarget = compass.get(DataComponents.LODESTONE_TRACKER);
|
||||
if (lodestoneTarget == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
lodestoneTarget.target().ifPresent(globalPos -> {
|
||||
addLodestone(compass, globalPos);
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static int convertPlayerLodestoneCompasses(Player player) {
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
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.CompassDataHandler;
|
||||
import net.minecraft.advancements.critereon.*;
|
||||
@ -8,40 +9,31 @@ import net.minecraft.core.GlobalPos;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.util.GsonHelper;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
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
|
||||
public @NotNull ResourceLocation getId() {
|
||||
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 Codec<TriggerInstance> codec() {
|
||||
return TriggerInstance.CODEC;
|
||||
}
|
||||
|
||||
public void trigger(ServerPlayer player, ItemStack compass) {
|
||||
this.trigger(player, (triggerInstance) -> triggerInstance.matches(compass));
|
||||
}
|
||||
|
||||
public static class TriggerInstance extends AbstractCriterionTriggerInstance {
|
||||
private final int minDimensions;
|
||||
|
||||
public TriggerInstance(ContextAwarePredicate player, int minDimensions) {
|
||||
super(ID, player);
|
||||
this.minDimensions = minDimensions;
|
||||
}
|
||||
public record TriggerInstance(Optional<ContextAwarePredicate> player, int minDimensions) implements SimpleCriterionTrigger.SimpleInstance {
|
||||
public static final Codec<TriggerInstance> CODEC = RecordCodecBuilder.create(instance -> instance.group(
|
||||
ContextAwarePredicate.CODEC.optionalFieldOf("player").forGetter(TriggerInstance::player),
|
||||
Codec.INT.fieldOf("min_dimensions").forGetter(TriggerInstance::minDimensions)
|
||||
).apply(instance, TriggerInstance::new));
|
||||
|
||||
public boolean matches(ItemStack compass) {
|
||||
List<GlobalPos> lodestones = CompassDataHandler.getLodestones(compass);
|
||||
@ -55,12 +47,5 @@ public final class DimensionalCompassBindingTrigger extends SimpleCriterionTrigg
|
||||
|
||||
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;
|
||||
|
||||
import io.lampnet.betterlodestones.CompassDataHandler;
|
||||
import io.lampnet.betterlodestones.advancement.DimensionalCompassBindingTrigger;
|
||||
import io.lampnet.betterlodestones.config.ConfigManager;
|
||||
import io.lampnet.betterlodestones.registry.BetterLodestonesRegistry;
|
||||
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);
|
||||
|
||||
if (player instanceof ServerPlayer serverPlayer) {
|
||||
BetterLodestonesRegistry.DIMENSIONAL_COMPASS_BINDING.trigger(serverPlayer, compass);
|
||||
((DimensionalCompassBindingTrigger) BetterLodestonesRegistry.DIMENSIONAL_COMPASS_BINDING.get()).trigger(serverPlayer, compass);
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
@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)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (level != null && !level.isClientSide()) {
|
||||
CompassDataHandler.convertVanillaLodestoneCompass(stack);
|
||||
}
|
||||
|
||||
if (level != null) {
|
||||
CompassDataHandler.validateCurrentLodestone(stack, level);
|
||||
}
|
||||
|
||||
// Tooltip is client-side, so we don't do server-side validation here
|
||||
int lodestoneCount = CompassDataHandler.getLodestoneCount(stack);
|
||||
|
||||
if (lodestoneCount > 0) {
|
||||
@ -61,9 +54,7 @@ public class CompassTooltipMixin {
|
||||
tooltip.add(Component.literal("§7Current: §f" + currentIndex + "/" + lodestoneCount +
|
||||
" §7at §f" + pos.getX() + ", " + pos.getY() + ", " + pos.getZ()));
|
||||
|
||||
if (CompassDataHandler.isLodestoneInDifferentDimension(level, lodestone)) {
|
||||
tooltip.add(Component.literal("§7Dimension: §c" + better_lodestones$formatDimensionName(dimensionName)));
|
||||
} else if (CompassDataHandler.hasBrokenLodestone(stack)) {
|
||||
if (CompassDataHandler.hasBrokenLodestone(stack)) {
|
||||
tooltip.add(Component.literal("§cLodestone destroyed!"));
|
||||
} else {
|
||||
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 net.minecraft.network.Connection;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.server.network.CommonListenerCookie;
|
||||
import net.minecraft.server.players.PlayerList;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@ -14,7 +15,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
public class PlayerJoinMixin {
|
||||
|
||||
@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) {
|
||||
int convertedCount = CompassDataHandler.convertPlayerLodestoneCompasses(player);
|
||||
if (convertedCount > 0) {
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
package io.lampnet.betterlodestones.recipe;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
import io.lampnet.betterlodestones.CompassDataHandler;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.inventory.CraftingContainer;
|
||||
import io.lampnet.betterlodestones.component.BetterLodestonesComponents;
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||
import net.minecraft.network.codec.StreamCodec;
|
||||
import net.minecraft.world.item.crafting.CraftingInput;
|
||||
import net.minecraft.world.item.CompassItem;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
@ -17,16 +17,16 @@ import net.minecraft.world.level.Level;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class CompassUnbindingRecipe extends CustomRecipe {
|
||||
public CompassUnbindingRecipe(ResourceLocation id, CraftingBookCategory category) {
|
||||
super(id, category);
|
||||
public CompassUnbindingRecipe(CraftingBookCategory category) {
|
||||
super(category);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(CraftingContainer craftingContainer, Level level) {
|
||||
public boolean matches(CraftingInput craftingInput, Level level) {
|
||||
ItemStack compass = ItemStack.EMPTY;
|
||||
|
||||
for (int i = 0; i < craftingContainer.getContainerSize(); ++i) {
|
||||
ItemStack currentStack = craftingContainer.getItem(i);
|
||||
for (int i = 0; i < craftingInput.size(); ++i) {
|
||||
ItemStack currentStack = craftingInput.getItem(i);
|
||||
if (!currentStack.isEmpty()) {
|
||||
if (currentStack.getItem() instanceof CompassItem) {
|
||||
if (!compass.isEmpty()) {
|
||||
@ -39,20 +39,15 @@ public class CompassUnbindingRecipe extends CustomRecipe {
|
||||
}
|
||||
}
|
||||
|
||||
if (compass.isEmpty() || !compass.hasTag()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
CompoundTag tag = compass.getTag();
|
||||
return tag != null && (tag.contains("LodestonePos") || tag.contains("BetterLodestones"));
|
||||
return !compass.isEmpty() && (compass.has(BetterLodestonesComponents.LODESTONES.get()) || compass.has(net.minecraft.core.component.DataComponents.LODESTONE_TRACKER));
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull ItemStack assemble(CraftingContainer craftingContainer, RegistryAccess registryAccess) {
|
||||
public @NotNull ItemStack assemble(@NotNull CraftingInput craftingInput, @NotNull HolderLookup.Provider provider) {
|
||||
ItemStack compass = ItemStack.EMPTY;
|
||||
|
||||
for (int i = 0; i < craftingContainer.getContainerSize(); i++) {
|
||||
ItemStack currentStack = craftingContainer.getItem(i);
|
||||
for (int i = 0; i < craftingInput.size(); i++) {
|
||||
ItemStack currentStack = craftingInput.getItem(i);
|
||||
if (!currentStack.isEmpty() && currentStack.getItem() instanceof CompassItem) {
|
||||
compass = currentStack.copy();
|
||||
compass.setCount(1);
|
||||
@ -81,24 +76,30 @@ public class CompassUnbindingRecipe extends CustomRecipe {
|
||||
|
||||
@Override
|
||||
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 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
|
||||
public @NotNull CompassUnbindingRecipe fromJson(ResourceLocation recipeId, JsonObject json) {
|
||||
return new CompassUnbindingRecipe(recipeId, CraftingBookCategory.MISC);
|
||||
public @NotNull com.mojang.serialization.MapCodec<CompassUnbindingRecipe> codec() {
|
||||
return CODEC;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull CompassUnbindingRecipe fromNetwork(ResourceLocation recipeId, FriendlyByteBuf buffer) {
|
||||
return new CompassUnbindingRecipe(recipeId, CraftingBookCategory.MISC);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toNetwork(FriendlyByteBuf buffer, CompassUnbindingRecipe recipe) {
|
||||
public @NotNull StreamCodec<RegistryFriendlyByteBuf, CompassUnbindingRecipe> streamCodec() {
|
||||
return STREAM_CODEC;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
package io.lampnet.betterlodestones.recipe;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
import io.lampnet.betterlodestones.config.ConfigManager;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.inventory.CraftingContainer;
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||
import net.minecraft.network.codec.StreamCodec;
|
||||
import net.minecraft.world.item.crafting.CraftingInput;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
@ -16,18 +16,18 @@ import net.minecraft.world.level.Level;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ConfigurableLodestoneRecipe extends CustomRecipe {
|
||||
public ConfigurableLodestoneRecipe(ResourceLocation id, CraftingBookCategory category) {
|
||||
super(id, category);
|
||||
public ConfigurableLodestoneRecipe(CraftingBookCategory category) {
|
||||
super(category);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(CraftingContainer craftingContainer, Level level) {
|
||||
if (craftingContainer.getWidth() != 3 || craftingContainer.getHeight() != 3) {
|
||||
public boolean matches(CraftingInput craftingInput, Level level) {
|
||||
if (craftingInput.width() != 3 || craftingInput.height() != 3) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Item expectedCenterItem = ConfigManager.useModernLodestoneRecipe() ? Items.IRON_INGOT : Items.NETHERITE_INGOT;
|
||||
if (!craftingContainer.getItem(4).is(expectedCenterItem)) {
|
||||
if (!craftingInput.getItem(4).is(expectedCenterItem)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -35,7 +35,7 @@ public class ConfigurableLodestoneRecipe extends CustomRecipe {
|
||||
if (i == 4) {
|
||||
continue;
|
||||
}
|
||||
if (!craftingContainer.getItem(i).is(Items.CHISELED_STONE_BRICKS)) {
|
||||
if (!craftingInput.getItem(i).is(Items.CHISELED_STONE_BRICKS)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -43,7 +43,7 @@ public class ConfigurableLodestoneRecipe extends CustomRecipe {
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
@ -54,24 +54,29 @@ public class ConfigurableLodestoneRecipe extends CustomRecipe {
|
||||
|
||||
@Override
|
||||
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 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
|
||||
public @NotNull ConfigurableLodestoneRecipe fromJson(ResourceLocation recipeId, JsonObject json) {
|
||||
return new ConfigurableLodestoneRecipe(recipeId, CraftingBookCategory.MISC);
|
||||
public @NotNull com.mojang.serialization.MapCodec<ConfigurableLodestoneRecipe> codec() {
|
||||
return CODEC;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull ConfigurableLodestoneRecipe fromNetwork(ResourceLocation recipeId, FriendlyByteBuf buffer) {
|
||||
return new ConfigurableLodestoneRecipe(recipeId, CraftingBookCategory.MISC);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toNetwork(FriendlyByteBuf buffer, ConfigurableLodestoneRecipe recipe) {
|
||||
public @NotNull StreamCodec<RegistryFriendlyByteBuf, ConfigurableLodestoneRecipe> streamCodec() {
|
||||
return STREAM_CODEC;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@ import io.lampnet.betterlodestones.BetterLodestones;
|
||||
import io.lampnet.betterlodestones.advancement.DimensionalCompassBindingTrigger;
|
||||
import io.lampnet.betterlodestones.recipe.CompassUnbindingRecipe;
|
||||
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.world.item.crafting.RecipeSerializer;
|
||||
|
||||
@ -20,10 +20,14 @@ public final class BetterLodestonesRegistry {
|
||||
public static final RegistrySupplier<RecipeSerializer<?>> COMPASS_UNBINDING =
|
||||
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() {
|
||||
RECIPE_SERIALIZERS.register();
|
||||
CriteriaTriggers.register(DIMENSIONAL_COMPASS_BINDING);
|
||||
CRITERION_TRIGGERS.register();
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,7 +7,6 @@
|
||||
],
|
||||
"mixins": [
|
||||
"CompassItemMixin",
|
||||
"CompassItemMixinPointing",
|
||||
"CompassTooltipMixin",
|
||||
"InventoryInteractionMixin",
|
||||
"ItemPickupMixin",
|
||||
|
||||
@ -1,9 +1,11 @@
|
||||
{
|
||||
"parent": "minecraft:nether/use_lodestone",
|
||||
"parent": "minecraft:adventure/use_lodestone",
|
||||
"display": {
|
||||
"icon": {
|
||||
"item": "minecraft:compass",
|
||||
"nbt": "{CustomModelData:1}"
|
||||
"id": "minecraft:compass",
|
||||
"components": {
|
||||
"minecraft:custom_model_data": 1
|
||||
}
|
||||
},
|
||||
"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",
|
||||
"display": {
|
||||
"icon": {
|
||||
"item": "minecraft:lodestone"
|
||||
"id": "minecraft:lodestone"
|
||||
},
|
||||
"title": {
|
||||
"translate": "advancements.nether.use_lodestone.title"
|
||||
@ -19,22 +19,16 @@
|
||||
"use_lodestone": {
|
||||
"trigger": "minecraft:item_used_on_block",
|
||||
"conditions": {
|
||||
"location": [
|
||||
{
|
||||
"condition": "minecraft:match_tool",
|
||||
"predicate": {
|
||||
"items": [
|
||||
"minecraft:compass"
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"item": {
|
||||
"items": [
|
||||
"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": {
|
||||
"main": [
|
||||
"io.lampnet.betterlodestones.fabric.BetterLodestonesFabric"
|
||||
],
|
||||
"client": [
|
||||
"io.lampnet.betterlodestones.fabric.BetterLodestonesFabricClient"
|
||||
]
|
||||
},
|
||||
"mixins": [
|
||||
@ -23,9 +26,9 @@
|
||||
],
|
||||
"depends": {
|
||||
"fabricloader": ">=0.17.2",
|
||||
"minecraft": "~1.20.1",
|
||||
"java": ">=17",
|
||||
"architectury": ">=9.2.14",
|
||||
"minecraft": "~1.21.1",
|
||||
"java": ">=21",
|
||||
"architectury": ">=13.0.8",
|
||||
"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.parallel=true
|
||||
# Mod properties
|
||||
mod_version=0.9
|
||||
mod_version=0.10
|
||||
maven_group=io.lampnet
|
||||
archives_name=better-lodestones
|
||||
enabled_platforms=fabric,forge
|
||||
enabled_platforms=fabric,neoforge
|
||||
# Minecraft properties
|
||||
minecraft_version=1.20.1
|
||||
minecraft_version=1.21.1
|
||||
# Dependencies
|
||||
architectury_api_version=9.2.14
|
||||
architectury_api_version=13.0.8
|
||||
fabric_loader_version=0.17.2
|
||||
fabric_api_version=0.92.6+1.20.1
|
||||
forge_version=1.20.1-47.4.9
|
||||
fabric_api_version=0.116.6+1.21.1
|
||||
neoforge_version=21.1.209
|
||||
|
||||
loom.experimental.official_data_components=true
|
||||
|
||||
@ -2,15 +2,9 @@ plugins {
|
||||
id 'com.github.johnrengelman.shadow'
|
||||
}
|
||||
|
||||
loom {
|
||||
forge {
|
||||
mixinConfig "better_lodestones.mixins.json"
|
||||
}
|
||||
}
|
||||
|
||||
architectury {
|
||||
platformSetupLoomIde()
|
||||
forge()
|
||||
neoForge()
|
||||
}
|
||||
|
||||
configurations {
|
||||
@ -20,7 +14,7 @@ configurations {
|
||||
}
|
||||
compileClasspath.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.
|
||||
// Don't use the `shadow` configuration from the plugin itself as it's meant for excluding files.
|
||||
@ -30,19 +24,26 @@ configurations {
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
forge "net.minecraftforge:forge:$rootProject.forge_version"
|
||||
repositories {
|
||||
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 }
|
||||
shadowBundle project(path: ':common', configuration: 'transformProductionForge')
|
||||
shadowBundle project(path: ':common', configuration: 'transformProductionNeoForge')
|
||||
}
|
||||
|
||||
processResources {
|
||||
inputs.property 'version', project.version
|
||||
|
||||
filesMatching('META-INF/mods.toml') {
|
||||
filesMatching('META-INF/neoforge.mods.toml') {
|
||||
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 static final ForgeConfigSpec SPEC;
|
||||
public static final ForgeConfigSpec.IntValue MAX_LODESTONES;
|
||||
public static final ForgeConfigSpec.BooleanValue USE_MODERN_LODESTONE_RECIPE;
|
||||
public class BetterLodestonesNeoForgeConfig {
|
||||
public static final ModConfigSpec SPEC;
|
||||
public static final ModConfigSpec.IntValue MAX_LODESTONES;
|
||||
public static final ModConfigSpec.BooleanValue USE_MODERN_LODESTONE_RECIPE;
|
||||
|
||||
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")
|
||||
.comment("0 = No limit (default)")
|
||||
@ -1,6 +1,6 @@
|
||||
modLoader = "javafml"
|
||||
loaderVersion = "[47,)"
|
||||
#issueTrackerURL = ""
|
||||
loaderVersion = "[2,)"
|
||||
issueTrackerURL = "https://github.com/C4ndle/better-lodestones/issues"
|
||||
license = "MIT"
|
||||
|
||||
[[mods]]
|
||||
@ -12,23 +12,27 @@ description = 'Reworks Lodestone system, allowing Compasses to be bound to multi
|
||||
|
||||
#logoFile = ""
|
||||
|
||||
[[mixins]]
|
||||
type = "COMMON"
|
||||
config = "better_lodestones.mixins.json"
|
||||
|
||||
[[dependencies.better_lodestones]]
|
||||
modId = "forge"
|
||||
modId = "neoforge"
|
||||
mandatory = true
|
||||
versionRange = "[47,)"
|
||||
versionRange = "[21.0,)"
|
||||
ordering = "NONE"
|
||||
side = "BOTH"
|
||||
|
||||
[[dependencies.better_lodestones]]
|
||||
modId = "minecraft"
|
||||
mandatory = true
|
||||
versionRange = "[1.20.1,)"
|
||||
versionRange = "[1.21.1,)"
|
||||
ordering = "NONE"
|
||||
side = "BOTH"
|
||||
|
||||
[[dependencies.better_lodestones]]
|
||||
modId = "architectury"
|
||||
mandatory = true
|
||||
versionRange = "[9.2.14,)"
|
||||
versionRange = "[13.0,)"
|
||||
ordering = "AFTER"
|
||||
side = "BOTH"
|
||||
@ -7,8 +7,8 @@ pluginManagement {
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.name = 'better_lodestones'
|
||||
rootProject.name = "Better Lodestones"
|
||||
|
||||
include 'common'
|
||||
include 'fabric'
|
||||
include 'forge'
|
||||
include('common')
|
||||
include('fabric')
|
||||
include('neoforge')
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user