This commit is contained in:
skippyall
2025-07-02 00:27:49 +02:00
parent 362bf15a19
commit 6640f95291
7 changed files with 41 additions and 16 deletions
+5 -5
View File
@@ -3,20 +3,20 @@ org.gradle.jvmargs=-Xmx1G
# Fabric Properties # Fabric Properties
# check these on https://modmuss50.me/fabric.html # check these on https://modmuss50.me/fabric.html
minecraft_version=1.21.6 minecraft_version=1.21.7
loader_version=0.16.14 loader_version=0.16.14
yarn_mappings=1.21.6+build.1 yarn_mappings=1.21.7+build.2
# Mod Properties # Mod Properties
mod_version = 0.2.0-SNAPSHOT mod_version = 0.2.1-SNAPSHOT
maven_group = io.github.skippyall maven_group = io.github.skippyall
archives_base_name = Minions archives_base_name = Minions
# Dependencies # Dependencies
# check this on https://modmuss50.me/fabric.html # check this on https://modmuss50.me/fabric.html
fabric_version=0.127.1+1.21.6 fabric_version=0.128.1+1.21.7
polymer_version=0.13.1+1.21.6 polymer_version=0.13.3+1.21.6
sgui_version=1.10.0+1.21.6 sgui_version=1.10.0+1.21.6
server_translations_version=2.5.1+1.21.5 server_translations_version=2.5.1+1.21.5
@@ -21,10 +21,11 @@ public class Minions implements ModInitializer {
MinionData.register(); MinionData.register();
PolymerEntityUtils.registerType(); PolymerEntityUtils.registerType();
ServerLifecycleEvents.SERVER_STARTED.register(server -> { ServerLifecycleEvents.SERVER_STARTED.register(server -> {
LOGGER.error("Initializing Minion data");
MinionPersistentState.create(server); MinionPersistentState.create(server);
MinionPersistentState.INSTANCE.getMinionData().forEach((uuid, data) -> { MinionPersistentState.INSTANCE.getMinionData().forEach((uuid, data) -> {
if(data.isSpawned()) { if(data.isSpawned()) {
MinionFakePlayer.spawnMinion(data, server.getOverworld(), null, null); MinionFakePlayer.spawnMinion(data, server.getOverworld(), null, null, true);
} }
}); });
}); });
@@ -0,0 +1,25 @@
package io.github.skippyall.minions.command;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import com.mojang.brigadier.context.CommandContext;
import io.github.skippyall.minions.minion.MinionData;
import io.github.skippyall.minions.minion.MinionPersistentState;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.text.Text;
import java.util.Collection;
import static net.minecraft.server.command.CommandManager.literal;
public class ListSubcommand {
public static final LiteralArgumentBuilder<ServerCommandSource> LIST = literal("list")
.executes(ListSubcommand::list);
public static int list(CommandContext<ServerCommandSource> context) {
Collection<MinionData> minions = MinionPersistentState.INSTANCE.getMinionData().values();
for (MinionData minion : minions) {
context.getSource().sendFeedback(() -> Text.literal(minion.name() + "(" + minion.uuid() + "):" + minion.isSpawned()), false);
}
return 0;
}
}
@@ -1,8 +1,6 @@
package io.github.skippyall.minions.command; package io.github.skippyall.minions.command;
import com.mojang.brigadier.Message;
import com.mojang.brigadier.context.CommandContext; import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandExceptionType;
import com.mojang.brigadier.exceptions.CommandSyntaxException; import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType; import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
import com.mojang.brigadier.suggestion.SuggestionProvider; import com.mojang.brigadier.suggestion.SuggestionProvider;
@@ -11,6 +11,7 @@ public class MinionsCommand {
literal("minions") literal("minions")
.then(SpawnSubcommand.SPAWN) .then(SpawnSubcommand.SPAWN)
.then(MobCapDebugSubcommand.MOB_CAP_DEBUG) .then(MobCapDebugSubcommand.MOB_CAP_DEBUG)
.then(ListSubcommand.LIST)
); );
} }
@@ -1,16 +1,12 @@
package io.github.skippyall.minions.minion; package io.github.skippyall.minions.minion;
import com.mojang.serialization.Codec; import com.mojang.serialization.Codec;
import net.minecraft.nbt.NbtCompound; import io.github.skippyall.minions.Minions;
import net.minecraft.nbt.NbtElement;
import net.minecraft.nbt.NbtList;
import net.minecraft.registry.RegistryWrapper;
import net.minecraft.server.MinecraftServer; import net.minecraft.server.MinecraftServer;
import net.minecraft.world.PersistentState; import net.minecraft.world.PersistentState;
import net.minecraft.world.PersistentStateType; import net.minecraft.world.PersistentStateType;
import net.minecraft.world.World; import net.minecraft.world.World;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@@ -68,6 +64,7 @@ public class MinionPersistentState extends PersistentState {
} }
public static void create(MinecraftServer server) { public static void create(MinecraftServer server) {
Minions.LOGGER.error("Creating Minion Persistent state");
INSTANCE = server.getWorld(World.OVERWORLD).getPersistentStateManager().getOrCreate(TYPE); INSTANCE = server.getWorld(World.OVERWORLD).getPersistentStateManager().getOrCreate(TYPE);
} }
} }
@@ -17,7 +17,9 @@ import net.minecraft.server.network.ConnectedClientData;
import net.minecraft.server.network.ServerPlayNetworkHandler; import net.minecraft.server.network.ServerPlayNetworkHandler;
import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerWorld; import net.minecraft.server.world.ServerWorld;
import net.minecraft.storage.ReadView;
import net.minecraft.text.Text; import net.minecraft.text.Text;
import net.minecraft.util.ErrorReporter;
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;
import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Inject;
@@ -25,17 +27,18 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Mixin(PlayerManager.class) @Mixin(PlayerManager.class)
public class PlayerListMixin { public class PlayerListMixin {
@Inject(method = "loadPlayerData", at = @At(value = "RETURN", shift = At.Shift.BEFORE)) @Inject(method = "loadPlayerData", at = @At(value = "RETURN", shift = At.Shift.BEFORE))
private void fixStartingPos(ServerPlayerEntity serverPlayerEntity_1, CallbackInfoReturnable<NbtCompound> cir) private void fixStartingPos(ServerPlayerEntity player, ErrorReporter errorReporter, CallbackInfoReturnable<Optional<ReadView>> cir)
{ {
if (serverPlayerEntity_1 instanceof MinionFakePlayer) if (player instanceof MinionFakePlayer)
{ {
((MinionFakePlayer) serverPlayerEntity_1).fixStartingPosition.run(); ((MinionFakePlayer) player).fixStartingPosition.run();
} }
} }