Fixes
This commit is contained in:
@@ -21,10 +21,11 @@ public class Minions implements ModInitializer {
|
||||
MinionData.register();
|
||||
PolymerEntityUtils.registerType();
|
||||
ServerLifecycleEvents.SERVER_STARTED.register(server -> {
|
||||
LOGGER.error("Initializing Minion data");
|
||||
MinionPersistentState.create(server);
|
||||
MinionPersistentState.INSTANCE.getMinionData().forEach((uuid, data) -> {
|
||||
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;
|
||||
|
||||
import com.mojang.brigadier.Message;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import com.mojang.brigadier.exceptions.CommandExceptionType;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
|
||||
import com.mojang.brigadier.suggestion.SuggestionProvider;
|
||||
|
||||
@@ -11,6 +11,7 @@ public class MinionsCommand {
|
||||
literal("minions")
|
||||
.then(SpawnSubcommand.SPAWN)
|
||||
.then(MobCapDebugSubcommand.MOB_CAP_DEBUG)
|
||||
.then(ListSubcommand.LIST)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,16 +1,12 @@
|
||||
package io.github.skippyall.minions.minion;
|
||||
|
||||
import com.mojang.serialization.Codec;
|
||||
import net.minecraft.nbt.NbtCompound;
|
||||
import net.minecraft.nbt.NbtElement;
|
||||
import net.minecraft.nbt.NbtList;
|
||||
import net.minecraft.registry.RegistryWrapper;
|
||||
import io.github.skippyall.minions.Minions;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.world.PersistentState;
|
||||
import net.minecraft.world.PersistentStateType;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -68,6 +64,7 @@ public class MinionPersistentState extends PersistentState {
|
||||
}
|
||||
|
||||
public static void create(MinecraftServer server) {
|
||||
Minions.LOGGER.error("Creating Minion Persistent state");
|
||||
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.ServerPlayerEntity;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.storage.ReadView;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.ErrorReporter;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
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.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Mixin(PlayerManager.class)
|
||||
public class PlayerListMixin {
|
||||
|
||||
@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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user