Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a9d0b7fd94 | |||
| 1931848068 | |||
| a2a189a0c1 | |||
| d2d96b3f67 | |||
| 08e7952e34 | |||
| cc69b22aba | |||
| c7ff6de42b | |||
| 8007778c39 | |||
| fc70b2fe5a | |||
| 2f35493580 |
+23
-1
@@ -1,15 +1,23 @@
|
||||
plugins {
|
||||
id 'fabric-loom' version '1.6-SNAPSHOT'
|
||||
id 'fabric-loom' version '1.8-SNAPSHOT'
|
||||
id 'maven-publish'
|
||||
}
|
||||
|
||||
version = project.mod_version
|
||||
group = project.maven_group
|
||||
|
||||
loom {
|
||||
accessWidenerPath = file("src/main/resources/minions.accesswidener")
|
||||
}
|
||||
|
||||
base {
|
||||
archivesName = project.archives_base_name
|
||||
}
|
||||
|
||||
loom {
|
||||
accessWidenerPath = file("src/main/resources/minions.accesswidener")
|
||||
}
|
||||
|
||||
repositories {
|
||||
// Add repositories to retrieve artifacts from in here.
|
||||
// You should only use this when depending on other mods because
|
||||
@@ -17,6 +25,18 @@ repositories {
|
||||
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
|
||||
// for more information about repositories.
|
||||
maven { url 'https://maven.nucleoid.xyz' }
|
||||
|
||||
exclusiveContent {
|
||||
forRepository {
|
||||
maven {
|
||||
name = "Modrinth"
|
||||
url = "https://api.modrinth.com/maven"
|
||||
}
|
||||
}
|
||||
filter {
|
||||
includeGroup "maven.modrinth"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@@ -30,6 +50,8 @@ dependencies {
|
||||
modImplementation "eu.pb4:polymer-core:${project.polymer_version}"
|
||||
modImplementation include("eu.pb4:sgui:${project.sgui_version}")
|
||||
modImplementation include("xyz.nucleoid:server-translations-api:${project.server_translations_version}")
|
||||
|
||||
modCompileOnly "maven.modrinth:universal-graves:${project.universal_graves_version}"
|
||||
}
|
||||
|
||||
processResources {
|
||||
|
||||
+10
-8
@@ -3,19 +3,21 @@ org.gradle.jvmargs=-Xmx1G
|
||||
|
||||
# Fabric Properties
|
||||
# check these on https://modmuss50.me/fabric.html
|
||||
minecraft_version=1.21.1
|
||||
loader_version=0.16.3
|
||||
yarn_mappings=1.21.1+build.3
|
||||
minecraft_version=1.21.3
|
||||
loader_version=0.16.13
|
||||
yarn_mappings=1.21.3+build.2
|
||||
|
||||
# Mod Properties
|
||||
mod_version = 0.0.1-SNAPSHOT
|
||||
mod_version = 0.1.2-SNAPSHOT
|
||||
maven_group = io.github.skippyall
|
||||
archives_base_name = Minions
|
||||
|
||||
# Dependencies
|
||||
# check this on https://modmuss50.me/fabric.html
|
||||
fabric_version=0.103.0+1.21.1
|
||||
fabric_version=0.107.0+1.21.3
|
||||
|
||||
polymer_version=0.9.12+1.21.1
|
||||
sgui_version=1.6.0+1.21
|
||||
server_translations_version=2.3.1+1.21-pre2
|
||||
polymer_version=0.10.0+1.21.2
|
||||
sgui_version=1.7.1+1.21.2
|
||||
server_translations_version=2.4.0+1.21.2-rc1
|
||||
|
||||
universal_graves_version=3.5.0+1.21.2
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
|
||||
|
||||
@@ -2,64 +2,69 @@ package io.github.skippyall.minions;
|
||||
|
||||
import eu.pb4.polymer.core.api.entity.PolymerEntityUtils;
|
||||
import eu.pb4.polymer.core.api.item.SimplePolymerItem;
|
||||
import io.github.skippyall.minions.fakeplayer.MinionFakePlayer;
|
||||
import io.github.skippyall.minions.minion.fakeplayer.MinionFakePlayer;
|
||||
import io.github.skippyall.minions.minion.MinionData;
|
||||
import io.github.skippyall.minions.minion.MinionItem;
|
||||
import io.github.skippyall.minions.minion.MinionPersistentState;
|
||||
import io.github.skippyall.minions.module.Modules;
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
|
||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
|
||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
|
||||
import net.minecraft.component.DataComponentTypes;
|
||||
import net.minecraft.component.type.DamageResistantComponent;
|
||||
import net.minecraft.entity.boss.WitherEntity;
|
||||
import net.minecraft.entity.damage.DamageType;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.registry.Registries;
|
||||
import net.minecraft.registry.Registry;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.registry.tag.TagKey;
|
||||
import net.minecraft.server.world.ChunkTicketManager;
|
||||
import net.minecraft.util.Identifier;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class Minions implements ModInitializer {
|
||||
public static final String MOD_ID = "minions";
|
||||
public static final MinionItem MINION_ITEM = Registry.register(Registries.ITEM, Identifier.of(MOD_ID, "minion"), new MinionItem(false));
|
||||
public static final SimplePolymerItem BASIC_UPGRADE_BASE = Registry.register(Registries.ITEM, Identifier.of(MOD_ID, "basic_upgrade_base"), new SimplePolymerItem(new Item.Settings(), Items.NETHERITE_UPGRADE_SMITHING_TEMPLATE));
|
||||
public static final TagKey<DamageType> MINION_ITEM_RESISTS = TagKey.of(RegistryKeys.DAMAGE_TYPE, Identifier.of(MOD_ID, "minion_item_resists"));
|
||||
public static final MinionItem MINION_ITEM = registerItem(Identifier.of(MOD_ID, "minion"), settings -> new MinionItem(settings.component(DataComponentTypes.DAMAGE_RESISTANT, new DamageResistantComponent(MINION_ITEM_RESISTS))));
|
||||
public static final SimplePolymerItem BASIC_UPGRADE_BASE = registerItem(Identifier.of(MOD_ID, "basic_upgrade_base"), settings -> new SimplePolymerItem(settings, Items.NETHERITE_UPGRADE_SMITHING_TEMPLATE));
|
||||
public static final SimplePolymerItem ADVANCED_UPGRADE_BASE = registerItem(Identifier.of(MOD_ID, "advanced_upgrade_base"), settings -> new SimplePolymerItem(settings, Items.NETHERITE_UPGRADE_SMITHING_TEMPLATE));
|
||||
|
||||
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
|
||||
|
||||
private static final List<Runnable> executeOnNextTick = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
LOGGER.debug("Add Customthing");
|
||||
MinionData.register();
|
||||
PolymerEntityUtils.registerType();
|
||||
ServerLifecycleEvents.SERVER_STARTED.register(server -> {
|
||||
MinionPersistentState.create(server);
|
||||
MinionPersistentState.INSTANCE.getMinionData().forEach(data -> {
|
||||
System.out.println("spawn Minion " + data.name);
|
||||
MinionFakePlayer.spawnMinionAt(data, server.getOverworld(), null, null);
|
||||
MinionPersistentState.INSTANCE.getMinionData().forEach((uuid, data) -> {
|
||||
if(data.isSpawned()) {
|
||||
MinionFakePlayer.spawnMinion(data, server.getOverworld(), null, null);
|
||||
}
|
||||
});
|
||||
});
|
||||
ServerTickEvents.START_SERVER_TICK.register(server -> {
|
||||
exec(() -> {
|
||||
for (Runnable run:executeOnNextTick) {
|
||||
run.run();
|
||||
}
|
||||
executeOnNextTick.clear();
|
||||
});
|
||||
|
||||
CommandRegistrationCallback.EVENT.register((commandDispatcher, commandRegistryAccess, registrationEnvironment) -> {
|
||||
MobCapCommand.registerCommand(commandDispatcher);
|
||||
});
|
||||
|
||||
Modules.register();
|
||||
}
|
||||
|
||||
private static synchronized void exec(Runnable run) {
|
||||
run.run();
|
||||
private static <T extends Item> T registerItem(Identifier identifier, Function<Item.Settings, T> constructor, Item.Settings settings) {
|
||||
return Registry.register(Registries.ITEM, identifier, constructor.apply(settings.registryKey(RegistryKey.of(RegistryKeys.ITEM, identifier))));
|
||||
}
|
||||
|
||||
public static void addExecuteOnNextTick(Runnable run) {
|
||||
exec(() -> {
|
||||
executeOnNextTick.add(run);
|
||||
});
|
||||
private static <T extends Item> T registerItem(Identifier identifier, Function<Item.Settings, T> constructor) {
|
||||
return registerItem(identifier, constructor, new Item.Settings());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package io.github.skippyall.minions;
|
||||
|
||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class MinionsTickExecutor {
|
||||
private static final List<Runnable> executeOnNextTick = Collections.synchronizedList(new ArrayList<>());
|
||||
|
||||
public static void register() {
|
||||
ServerTickEvents.START_SERVER_TICK.register(server -> {
|
||||
synchronized (executeOnNextTick) {
|
||||
for (Runnable run:executeOnNextTick) {
|
||||
run.run();
|
||||
}
|
||||
executeOnNextTick.clear();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void addExecuteOnNextTick(Runnable run) {
|
||||
executeOnNextTick.add(run);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package io.github.skippyall.minions;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import io.github.skippyall.minions.mixinhelper.ChunkTicketManager$DistanceFromNearestPlayerTrackerAccessor;
|
||||
import io.github.skippyall.minions.mixinhelper.ChunkTicketManagerAccessor;
|
||||
import io.github.skippyall.minions.mixins.antimobcap.ServerChunkManagerAccessor;
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
import net.minecraft.server.world.ChunkTicketManager;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
import static net.minecraft.server.command.CommandManager.literal;
|
||||
|
||||
public class MobCapCommand {
|
||||
public static void registerCommand(CommandDispatcher<ServerCommandSource> dispatcher) {
|
||||
dispatcher.register(literal("mobcapdebug")
|
||||
.executes(context -> {
|
||||
ChunkTicketManager ticketManager = ((ServerChunkManagerAccessor)context.getSource().getWorld().getChunkManager()).getTicketManager();
|
||||
int tickedChunkCount = ((ChunkTicketManager$DistanceFromNearestPlayerTrackerAccessor)((ChunkTicketManagerAccessor)ticketManager).getMinionless()).minions$getTickedChunkCount();
|
||||
context.getSource().sendFeedback(() -> Text.of(String.valueOf(tickedChunkCount)), false);
|
||||
return 0;
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package io.github.skippyall.minions.client;
|
||||
|
||||
import io.github.skippyall.minions.networking.ClientToServerNetworking;
|
||||
import net.fabricmc.api.ClientModInitializer;
|
||||
import net.fabricmc.fabric.api.client.networking.v1.ClientConfigurationConnectionEvents;
|
||||
import net.fabricmc.fabric.api.client.networking.v1.ClientLoginConnectionEvents;
|
||||
|
||||
public class MinionsClient implements ClientModInitializer {
|
||||
/**
|
||||
* Runs the mod initializer on the client environment.
|
||||
*/
|
||||
@Override
|
||||
public void onInitializeClient() {
|
||||
//ClientConfigurationConnectionEvents.INIT.register(ClientToServerNetworking::onConfigurationInit);
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
package io.github.skippyall.minions.fakeplayer;
|
||||
|
||||
import io.github.skippyall.minions.fakeplayer.EntityPlayerActionPack;
|
||||
|
||||
public interface ServerPlayerInterface
|
||||
{
|
||||
EntityPlayerActionPack getActionPack();
|
||||
}
|
||||
@@ -2,8 +2,8 @@ package io.github.skippyall.minions.gui;
|
||||
|
||||
import eu.pb4.sgui.api.elements.GuiElementBuilder;
|
||||
import eu.pb4.sgui.api.gui.SimpleGui;
|
||||
import io.github.skippyall.minions.command.Command;
|
||||
import io.github.skippyall.minions.fakeplayer.MinionFakePlayer;
|
||||
import io.github.skippyall.minions.module.command.Command;
|
||||
import io.github.skippyall.minions.minion.fakeplayer.MinionFakePlayer;
|
||||
import io.github.skippyall.minions.module.ModuleItem;
|
||||
import net.minecraft.screen.ScreenHandlerType;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
|
||||
@@ -2,11 +2,9 @@ package io.github.skippyall.minions.gui;
|
||||
|
||||
import eu.pb4.sgui.api.elements.GuiElementBuilder;
|
||||
import eu.pb4.sgui.api.gui.SimpleGui;
|
||||
import io.github.skippyall.minions.fakeplayer.MinionFakePlayer;
|
||||
import io.github.skippyall.minions.minion.fakeplayer.MinionFakePlayer;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.screen.GenericContainerScreenHandler;
|
||||
import net.minecraft.screen.ScreenHandlerType;
|
||||
import net.minecraft.screen.SimpleNamedScreenHandlerFactory;
|
||||
import net.minecraft.screen.slot.Slot;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.text.Text;
|
||||
@@ -31,7 +29,7 @@ public class MinionGui {
|
||||
gui.setSlot(4, new GuiElementBuilder()
|
||||
.setItem(Items.REDSTONE)
|
||||
.setName(Text.translatable("minions.gui.main.programming"))
|
||||
.setCallback((i, clickType, slotActionType) -> {
|
||||
.setCallback(() -> {
|
||||
openProgrammingInventory(player, minion);
|
||||
})
|
||||
);
|
||||
@@ -39,17 +37,24 @@ public class MinionGui {
|
||||
gui.setSlot(3, new GuiElementBuilder()
|
||||
.setItem(Items.NETHERITE_UPGRADE_SMITHING_TEMPLATE)
|
||||
.setName(Text.translatable("minions.gui.main.modules"))
|
||||
.setCallback((i, clickType, slotActionType) -> {
|
||||
.setCallback(() -> {
|
||||
ModuleInventory.openModuleInventory(player, minion);
|
||||
})
|
||||
);
|
||||
gui.setSlot(5, new GuiElementBuilder()
|
||||
.setItem(Items.CHEST)
|
||||
.setName(Text.translatable("minions.gui.main.inventory"))
|
||||
.setCallback((i, clickType, slotActionType) -> {
|
||||
.setCallback(() -> {
|
||||
openMinionInventory(player, minion);
|
||||
})
|
||||
);
|
||||
gui.setSlot(7, new GuiElementBuilder()
|
||||
.setItem(Items.BARRIER)
|
||||
.setName(Text.translatable("minions.gui.main.pickup"))
|
||||
.setCallback(() -> {
|
||||
minion.kill(minion.getServerWorld());
|
||||
})
|
||||
);
|
||||
gui.open();
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
package io.github.skippyall.minions.gui;
|
||||
|
||||
import eu.pb4.sgui.api.elements.GuiElementBuilder;
|
||||
import eu.pb4.sgui.api.gui.SimpleGui;
|
||||
import io.github.skippyall.minions.input.TextInput;
|
||||
import io.github.skippyall.minions.minion.MinionData;
|
||||
import io.github.skippyall.minions.minion.MinionItem;
|
||||
import io.github.skippyall.minions.minion.MinionProfileUtils;
|
||||
import io.github.skippyall.minions.minion.skin.SkinProvider;
|
||||
import io.github.skippyall.minions.minion.skin.SkinProviders;
|
||||
import net.minecraft.component.DataComponentTypes;
|
||||
import net.minecraft.component.type.ProfileComponent;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.screen.ScreenHandlerType;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class MinionLookGui extends SimpleGui {
|
||||
private ItemStack minionItem;
|
||||
private SkinProvider currentSkinProvider;
|
||||
|
||||
public MinionLookGui(ServerPlayerEntity player, ItemStack minionItem) {
|
||||
super(ScreenHandlerType.GENERIC_9X3, player, false);
|
||||
this.minionItem = minionItem;
|
||||
this.currentSkinProvider = SkinProviders.NAME;
|
||||
}
|
||||
|
||||
public void update() {
|
||||
updateName();
|
||||
updateSkin();
|
||||
updateSkinProvider();
|
||||
}
|
||||
|
||||
private void updateName() {
|
||||
setSlot(10, new GuiElementBuilder()
|
||||
.setItem(Items.OAK_SIGN)
|
||||
.setName(Text.literal(getData().name()))
|
||||
.setCallback(() -> {
|
||||
openRenameGui(player, minionItem);
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
private void updateSkin() {
|
||||
GuiElementBuilder builder = new GuiElementBuilder()
|
||||
.setItem(Items.PLAYER_HEAD)
|
||||
.setCallback(() -> currentSkinProvider.openSkinMenu(player).thenAccept(skin -> {
|
||||
MinionItem.setData(getData().withSkin(skin), minionItem);
|
||||
}));
|
||||
if(MinionItem.getData(minionItem) != null && MinionItem.getData(minionItem).skin().isPresent()) {
|
||||
builder.setComponent(DataComponentTypes.PROFILE, new ProfileComponent(Optional.empty(), Optional.empty(), getData().skin().get()));
|
||||
}
|
||||
setSlot(16, builder);
|
||||
}
|
||||
|
||||
private void cycleSkinProvider() {
|
||||
int currentId = SkinProviders.SKIN_PROVIDERS.getRawId(currentSkinProvider);
|
||||
currentId++;
|
||||
if(SkinProviders.SKIN_PROVIDERS.size() == currentId) {
|
||||
currentId = 0;
|
||||
}
|
||||
|
||||
currentSkinProvider = SkinProviders.SKIN_PROVIDERS.get(currentId);
|
||||
updateSkinProvider();
|
||||
}
|
||||
|
||||
private void updateSkinProvider() {
|
||||
setSlot(25, new GuiElementBuilder()
|
||||
.setItem(Items.GREEN_STAINED_GLASS_PANE)
|
||||
.setComponent(DataComponentTypes.CUSTOM_NAME, currentSkinProvider.getDisplayName())
|
||||
.setCallback(this::cycleSkinProvider)
|
||||
);
|
||||
}
|
||||
|
||||
private MinionData getData() {
|
||||
return MinionItem.getDataOrDefault(minionItem);
|
||||
}
|
||||
|
||||
public static void open(ServerPlayerEntity player, ItemStack minionItem) {
|
||||
MinionLookGui gui = new MinionLookGui(player, minionItem);
|
||||
gui.update();
|
||||
gui.open();
|
||||
}
|
||||
|
||||
public void openRenameGui(ServerPlayerEntity player, ItemStack minionItem) {
|
||||
TextInput.inputSync(player, Text.translatable("minions.gui.look.rename.title"), "Minion", MinionProfileUtils::checkMinionNameWithoutPrefix)
|
||||
.thenAccept(name -> {
|
||||
MinionItem.setData(getData().withName(MinionProfileUtils.PREFIX + name), minionItem);
|
||||
open();
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package io.github.skippyall.minions.gui;
|
||||
|
||||
import io.github.skippyall.minions.command.Command;
|
||||
import io.github.skippyall.minions.fakeplayer.MinionFakePlayer;
|
||||
import io.github.skippyall.minions.module.command.Command;
|
||||
import io.github.skippyall.minions.minion.fakeplayer.MinionFakePlayer;
|
||||
import io.github.skippyall.minions.module.ModuleItem;
|
||||
import io.github.skippyall.minions.program.block.CodeBlock;
|
||||
import net.minecraft.inventory.Inventories;
|
||||
|
||||
@@ -0,0 +1,117 @@
|
||||
package io.github.skippyall.minions.input;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
public interface Result<T, E> {
|
||||
static <T> Result<T, String> wrap(UnsafeOperation<T> toWrap) {
|
||||
return wrapCustomError(toWrap, Exception::getMessage);
|
||||
}
|
||||
|
||||
static <T, E> Result<T, E> wrapCustomError(UnsafeOperation<T> toWrap, E error) {
|
||||
return wrapCustomError(toWrap, e -> error);
|
||||
}
|
||||
|
||||
static <T, E> Result<T, E> wrapCustomError(UnsafeOperation<T> toWrap, Function<Exception, E> errorTransformer) {
|
||||
try {
|
||||
return new Result.Success<>(toWrap.run());
|
||||
} catch (Exception e) {
|
||||
return new Result.Error<>(errorTransformer.apply(e));
|
||||
}
|
||||
}
|
||||
|
||||
boolean isSuccess();
|
||||
|
||||
@NotNull T getOrDefault(@NotNull T defaultValue);
|
||||
|
||||
@NotNull T getOrThrow();
|
||||
|
||||
@NotNull E getErrorOrThrow();
|
||||
|
||||
@NotNull Optional<T> getOptional();
|
||||
|
||||
void ifSuccess(@NotNull Consumer<T> handler);
|
||||
|
||||
void ifError(@NotNull Consumer<Error<T, E>> handler);
|
||||
|
||||
record Success<T, E>(@NotNull T result) implements Result<T, E> {
|
||||
@Override
|
||||
public boolean isSuccess() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull T getOrDefault(@NotNull T defaultValue) {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull T getOrThrow() {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull E getErrorOrThrow() {
|
||||
throw new RuntimeException("Result was not an Error");
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Optional<T> getOptional() {
|
||||
return Optional.of(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ifSuccess(@NotNull Consumer<T> handler) {
|
||||
handler.accept(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ifError(@NotNull Consumer<Error<T, E>> handler) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
record Error<T, E>(@NotNull E message) implements Result<T, E> {
|
||||
@Override
|
||||
public boolean isSuccess() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull T getOrDefault(@NotNull T defaultValue) {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull T getOrThrow() {
|
||||
throw new RuntimeException("Result was an error: " + message.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull E getErrorOrThrow() {
|
||||
return message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Optional<T> getOptional() {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ifSuccess(@NotNull Consumer<T> handler) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ifError(Consumer<Error<T, E>> handler) {
|
||||
handler.accept(this);
|
||||
}
|
||||
}
|
||||
|
||||
interface UnsafeOperation<T> {
|
||||
T run() throws Exception;
|
||||
}
|
||||
}
|
||||
@@ -8,20 +8,83 @@ import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class TextInput {
|
||||
public static CompletableFuture<String> inputText(ServerPlayerEntity player, Text title, String defaultText) {
|
||||
CompletableFuture<String> future = new CompletableFuture<>();
|
||||
public class TextInput<T> extends AnvilInputGui {
|
||||
private final GuiElementBuilder valid = new GuiElementBuilder()
|
||||
.setItem(Items.EMERALD_BLOCK)
|
||||
.setName(Text.literal("OK"))
|
||||
.setCallback(this::onConfirm);
|
||||
|
||||
AnvilInputGui gui = new AnvilInputGui(player, false);
|
||||
gui.setSlot(AnvilScreenHandler.OUTPUT_ID, new GuiElementBuilder()
|
||||
.setItem(Items.EMERALD_BLOCK)
|
||||
.setName(Text.literal("OK"))
|
||||
.setCallback(() -> future.complete(gui.getInput()))
|
||||
);
|
||||
gui.setTitle(title);
|
||||
gui.setDefaultInputValue(defaultText);
|
||||
gui.open();
|
||||
private final GuiElementBuilder invalid = new GuiElementBuilder()
|
||||
.setItem(Items.REDSTONE_BLOCK);
|
||||
private final Function<String, CompletableFuture<Result<T, Text>>> parser;
|
||||
private final CompletableFuture<T> future;
|
||||
private Result<T, Text> result;
|
||||
|
||||
public TextInput(ServerPlayerEntity player, Text title, String defaultValue, Function<String, CompletableFuture<Result<T, Text>>> parser, CompletableFuture<T> future) {
|
||||
super(player, false);
|
||||
setTitle(title);
|
||||
setDefaultInputValue(defaultValue);
|
||||
this.parser = parser;
|
||||
this.future = future;
|
||||
|
||||
updateConfirmButton(defaultValue);
|
||||
}
|
||||
|
||||
public static <T> CompletableFuture<T> inputSync(ServerPlayerEntity player, Text title, String defaultValue, Function<String, Result<T, Text>> parser) {
|
||||
return input(player, title, defaultValue, (String string) -> CompletableFuture.completedFuture(parser.apply(string)));
|
||||
}
|
||||
|
||||
public static <T> CompletableFuture<T> input(ServerPlayerEntity player, Text title, String defaultValue, Function<String, CompletableFuture<Result<T, Text>>> parser) {
|
||||
CompletableFuture<T> future = new CompletableFuture<>();
|
||||
new TextInput<>(player, title, defaultValue, parser, future).open();
|
||||
return future;
|
||||
}
|
||||
|
||||
public static CompletableFuture<String> inputString(ServerPlayerEntity player, Text title, String defaultValue) {
|
||||
return inputSync(player, title, defaultValue, Result.Success::new);
|
||||
}
|
||||
|
||||
public static CompletableFuture<Integer> inputInt(ServerPlayerEntity player, Text title, String defaultValue) {
|
||||
return inputSync(player, title, defaultValue, string -> Result.wrapCustomError(() -> Integer.valueOf(string), Text.translatable("minions.command.input.int.fail")));
|
||||
}
|
||||
|
||||
public static CompletableFuture<Float> inputFloat(ServerPlayerEntity player, Text title, String defaultValue) {
|
||||
return inputSync(player, title, defaultValue, string -> Result.wrapCustomError(() -> Float.valueOf(string), Text.translatable("minions.command.input.float.fail")));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInput(String input) {
|
||||
updateConfirmButton(input);
|
||||
}
|
||||
|
||||
public void updateConfirmButton(String input) {
|
||||
parser.apply(input).thenAccept(result -> {
|
||||
this.result = result;
|
||||
if(result.isSuccess()) {
|
||||
setSlot(AnvilScreenHandler.OUTPUT_ID, valid);
|
||||
} else {
|
||||
Text text = result.getErrorOrThrow();
|
||||
setSlot(AnvilScreenHandler.OUTPUT_ID, invalid.setName(text));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClose() {
|
||||
if(!future.isDone()) {
|
||||
future.cancel(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void onConfirm() {
|
||||
if(result != null) {
|
||||
result.ifSuccess(success -> {
|
||||
future.complete(success);
|
||||
close();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
package io.github.skippyall.minions.minion;
|
||||
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
import net.minecraft.component.ComponentType;
|
||||
|
||||
public class MinionComponent {
|
||||
/*public static final Codec<MinionComponent> CODEC = RecordCodecBuilder.create(instance ->
|
||||
instance.group()
|
||||
);
|
||||
public static final ComponentType<MinionComponent> TYPE = ComponentType.<MinionComponent>builder().codec(CODEC).build();
|
||||
*/
|
||||
|
||||
}
|
||||
@@ -1,45 +1,65 @@
|
||||
package io.github.skippyall.minions.minion;
|
||||
|
||||
import io.github.skippyall.minions.fakeplayer.MinionFakePlayer;
|
||||
import com.mojang.authlib.properties.PropertyMap;
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
import eu.pb4.polymer.core.api.other.PolymerComponent;
|
||||
import io.github.skippyall.minions.Minions;
|
||||
import net.minecraft.component.ComponentType;
|
||||
import net.minecraft.nbt.NbtCompound;
|
||||
import net.minecraft.nbt.NbtOps;
|
||||
import net.minecraft.registry.Registries;
|
||||
import net.minecraft.registry.Registry;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.Uuids;
|
||||
import net.minecraft.util.dynamic.Codecs;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
public class MinionData {
|
||||
public UUID uuid;
|
||||
public String name;
|
||||
public UUID skinUuid;
|
||||
public record MinionData(UUID uuid, String name, Optional<PropertyMap> skin, boolean isSpawned) {
|
||||
public static final Codec<MinionData> CODEC = RecordCodecBuilder.create(instance ->
|
||||
instance.group(
|
||||
Uuids.CODEC.fieldOf("uuid").forGetter(MinionData::uuid),
|
||||
Codec.STRING.fieldOf("name").forGetter(MinionData::name),
|
||||
Codecs.GAME_PROFILE_PROPERTY_MAP.optionalFieldOf("skin").forGetter(MinionData::skin),
|
||||
Codec.BOOL.optionalFieldOf("isSpawned", false).forGetter(MinionData::isSpawned)
|
||||
).apply(instance, MinionData::new)
|
||||
);
|
||||
|
||||
public MinionData(UUID uuid, String name, UUID skinUuid) {
|
||||
this.uuid = uuid;
|
||||
this.name = name;
|
||||
this.skinUuid = skinUuid;
|
||||
public static final ComponentType<UUID> COMPONENT = Registry.register(Registries.DATA_COMPONENT_TYPE, Identifier.of(Minions.MOD_ID, "minion_data"), ComponentType.<UUID>builder().codec(Uuids.CODEC).build());
|
||||
|
||||
public static MinionData createDefault() {
|
||||
return new MinionData(UUID.randomUUID(), MinionProfileUtils.newDefaultMinionName(), Optional.empty(), false);
|
||||
}
|
||||
|
||||
public MinionData withUuid(UUID uuid) {
|
||||
return new MinionData(uuid, name, skin, isSpawned);
|
||||
}
|
||||
|
||||
public MinionData withName(String name) {
|
||||
return new MinionData(uuid, name, skin, isSpawned);
|
||||
}
|
||||
|
||||
public MinionData withSkin(Optional<PropertyMap> skin) {
|
||||
return new MinionData(uuid, name, skin, isSpawned);
|
||||
}
|
||||
|
||||
public MinionData withSpawned(boolean isSpawned) {
|
||||
return new MinionData(uuid, name, skin, isSpawned);
|
||||
}
|
||||
|
||||
public NbtCompound writeNbt() {
|
||||
NbtCompound nbt = new NbtCompound();
|
||||
|
||||
nbt.putUuid("uuid", uuid);
|
||||
nbt.putString("name", name);
|
||||
if(skinUuid != null) {
|
||||
nbt.putUuid("skinUuid", skinUuid);
|
||||
}
|
||||
|
||||
return nbt;
|
||||
return (NbtCompound) MinionData.CODEC.encode(this, NbtOps.INSTANCE, null).result().orElse(new NbtCompound());
|
||||
}
|
||||
|
||||
public static MinionData readNbt(NbtCompound nbt) {
|
||||
UUID uuid = nbt.getUuid("uuid");
|
||||
String name = nbt.getString("name");
|
||||
UUID skinUuid = null;
|
||||
if(nbt.contains("skinUuid")) {
|
||||
skinUuid = nbt.getUuid("skinUuid");
|
||||
}
|
||||
|
||||
return new MinionData(uuid, name, skinUuid);
|
||||
return MinionData.CODEC.decode(NbtOps.INSTANCE, nbt).resultOrPartial().map(Pair::getFirst).orElseGet(MinionData::createDefault);
|
||||
}
|
||||
|
||||
public static MinionData fromMinion(MinionFakePlayer minion) {
|
||||
return new MinionData(minion.getUuid(), minion.getMinionName(), minion.getSkinUuid());
|
||||
public static void register() {
|
||||
PolymerComponent.registerDataComponent(COMPONENT);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,91 +2,102 @@ package io.github.skippyall.minions.minion;
|
||||
|
||||
import eu.pb4.polymer.core.api.item.PolymerItem;
|
||||
import eu.pb4.polymer.core.api.item.PolymerItemUtils;
|
||||
import io.github.skippyall.minions.fakeplayer.MinionFakePlayer;
|
||||
import io.github.skippyall.minions.gui.MinionLookGui;
|
||||
import io.github.skippyall.minions.minion.fakeplayer.MinionFakePlayer;
|
||||
import net.minecraft.component.DataComponentTypes;
|
||||
import net.minecraft.component.type.NbtComponent;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemUsageContext;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.item.tooltip.TooltipType;
|
||||
import net.minecraft.nbt.NbtCompound;
|
||||
import net.minecraft.nbt.NbtElement;
|
||||
import net.minecraft.registry.RegistryWrapper;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.Vec2f;
|
||||
import net.minecraft.world.World;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import xyz.nucleoid.packettweaker.PacketContext;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class MinionItem extends Item implements PolymerItem {
|
||||
private final boolean canProgram;
|
||||
|
||||
public MinionItem(boolean canProgram) {
|
||||
super(new Item.Settings());
|
||||
this.canProgram = canProgram;
|
||||
public MinionItem(Settings settings) {
|
||||
super(settings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getPolymerItem(ItemStack itemStack, @Nullable ServerPlayerEntity player) {
|
||||
public @Nullable Identifier getPolymerItemModel(ItemStack stack, PacketContext context) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getPolymerItem(ItemStack itemStack, PacketContext player) {
|
||||
return Items.ARMOR_STAND;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getPolymerItemStack(ItemStack stack, TooltipType tooltipType, RegistryWrapper.WrapperLookup lookup, ServerPlayerEntity player) {
|
||||
ItemStack out = PolymerItemUtils.createItemStack(stack, lookup, player);
|
||||
public ItemStack getPolymerItemStack(ItemStack stack, TooltipType tooltipType, PacketContext player) {
|
||||
ItemStack out = PolymerItemUtils.createItemStack(stack, tooltipType, player);
|
||||
out.set(DataComponentTypes.ENCHANTMENT_GLINT_OVERRIDE, true);
|
||||
return out;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult useOnBlock(ItemUsageContext context) {
|
||||
String contents = context.getStack().getName().getLiteralString();
|
||||
String name;
|
||||
if(contents != null && contents.length() <= 16) {
|
||||
name = contents;
|
||||
} else {
|
||||
name = "Minion";
|
||||
public void appendTooltip(ItemStack stack, TooltipContext context, List<Text> tooltip, TooltipType type) {
|
||||
MinionData data = getData(stack);
|
||||
if(data != null) {
|
||||
tooltip.add(Text.translatable("minions.minion_item.tooltip", data.name()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult use(World world, PlayerEntity user, Hand hand) {
|
||||
if(user instanceof ServerPlayerEntity serverPlayer) {
|
||||
ItemStack stack = user.getStackInHand(hand);
|
||||
MinionLookGui.open(serverPlayer, stack);
|
||||
return ActionResult.SUCCESS;
|
||||
}
|
||||
|
||||
return ActionResult.SUCCESS_SERVER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult useOnBlock(ItemUsageContext context) {
|
||||
if(!context.getWorld().isClient) {
|
||||
MinionData data = getData(context.getStack());
|
||||
|
||||
if(data == null) {
|
||||
data = new MinionData(null, name, null);
|
||||
}
|
||||
|
||||
if (data.uuid == null) {
|
||||
MinionFakePlayer.createMinion(data, (ServerWorld) context.getWorld(), (ServerPlayerEntity) context.getPlayer(), canProgram, context.getBlockPos().toCenterPos().add(0,0.5,0), 0, 0);
|
||||
}else {
|
||||
data.name = name;
|
||||
MinionFakePlayer.spawnMinionAt(data, (ServerWorld) context.getWorld(), context.getBlockPos().toCenterPos().add(0,0.5,0), new Vec2f(0, 0));
|
||||
MinionPersistentState.INSTANCE.addMinion(data);
|
||||
}
|
||||
MinionData data = getDataOrDefault(context.getStack());
|
||||
MinionFakePlayer.spawnMinion(data, (ServerWorld) context.getWorld(), context.getBlockPos().toCenterPos().add(0,0.5,0), new Vec2f(0, 0));
|
||||
}
|
||||
context.getStack().decrement(1);
|
||||
return ActionResult.SUCCESS;
|
||||
}
|
||||
|
||||
public static void setData(MinionData data, ItemStack item) {
|
||||
NbtCompound nbt = item.getOrDefault(DataComponentTypes.CUSTOM_DATA, NbtComponent.DEFAULT).copyNbt();
|
||||
nbt.put("data", data.writeNbt());
|
||||
item.set(DataComponentTypes.CUSTOM_DATA, NbtComponent.of(nbt));
|
||||
item.set(MinionData.COMPONENT, data.uuid());
|
||||
MinionPersistentState.INSTANCE.updateMinionData(data);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static MinionData getData(ItemStack item) {
|
||||
NbtCompound nbt = item.getOrDefault(DataComponentTypes.CUSTOM_DATA, NbtComponent.DEFAULT).copyNbt();
|
||||
if (nbt.getType("data") == NbtElement.COMPOUND_TYPE) {
|
||||
return MinionData.readNbt(nbt.getCompound("data"));
|
||||
if(item.contains(MinionData.COMPONENT)) {
|
||||
return MinionPersistentState.INSTANCE.getMinionData(item.get(MinionData.COMPONENT));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean containsData(ItemStack item) {
|
||||
NbtComponent nbt = item.get(DataComponentTypes.CUSTOM_DATA);
|
||||
if (nbt == null) {
|
||||
return false;
|
||||
public static MinionData getDataOrDefault(ItemStack item) {
|
||||
MinionData data = getData(item);
|
||||
if(data == null) {
|
||||
data = MinionData.createDefault();
|
||||
setData(data, item);
|
||||
}
|
||||
return nbt.copyNbt().contains("data");
|
||||
return data;
|
||||
}
|
||||
|
||||
public static boolean containsData(ItemStack item) {
|
||||
return item.contains(MinionData.COMPONENT);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package io.github.skippyall.minions.minion;
|
||||
|
||||
import io.github.skippyall.minions.fakeplayer.MinionFakePlayer;
|
||||
import net.minecraft.nbt.NbtCompound;
|
||||
import net.minecraft.nbt.NbtElement;
|
||||
import net.minecraft.nbt.NbtList;
|
||||
@@ -9,8 +8,8 @@ import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.world.PersistentState;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class MinionPersistentState extends PersistentState {
|
||||
@@ -18,15 +17,16 @@ public class MinionPersistentState extends PersistentState {
|
||||
|
||||
public static MinionPersistentState INSTANCE;
|
||||
|
||||
private List<MinionData> minionData = new ArrayList<>();
|
||||
private final Map<UUID, MinionData> minionData = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public NbtCompound writeNbt(NbtCompound nbt, RegistryWrapper.WrapperLookup registryLookup) {
|
||||
NbtList list = new NbtList();
|
||||
for(MinionData data : minionData) {
|
||||
for(MinionData data : minionData.values()) {
|
||||
list.add(data.writeNbt());
|
||||
}
|
||||
nbt.put("minions", list);
|
||||
|
||||
return nbt;
|
||||
}
|
||||
|
||||
@@ -34,42 +34,35 @@ public class MinionPersistentState extends PersistentState {
|
||||
NbtList list = compound.getList("minions", NbtElement.COMPOUND_TYPE);
|
||||
MinionPersistentState instance = new MinionPersistentState();
|
||||
for(NbtElement element : list) {
|
||||
instance.addMinion(MinionData.readNbt((NbtCompound) element));
|
||||
if(element instanceof NbtCompound compound1) {
|
||||
MinionData data = MinionData.readNbt(compound1);
|
||||
instance.minionData.put(data.uuid(), data);
|
||||
}
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
public void addMinion(MinionFakePlayer minion) {
|
||||
addMinion(MinionData.fromMinion(minion));
|
||||
public MinionData getMinionData(UUID uuid) {
|
||||
return minionData.get(uuid);
|
||||
}
|
||||
|
||||
public void addMinion(MinionData data) {
|
||||
System.out.println("add Minion " + data.name);
|
||||
minionData.add(data);
|
||||
markDirty();
|
||||
}
|
||||
|
||||
public void removeMinion(MinionFakePlayer minionData) {
|
||||
removeMinion(minionData.getUuid());
|
||||
}
|
||||
|
||||
public void removeMinion(UUID minionUUID) {
|
||||
MinionData removal = null;
|
||||
for (MinionData data : minionData) {
|
||||
if (data.uuid.equals(minionUUID)) {
|
||||
removal = data;
|
||||
}
|
||||
}
|
||||
if (removal != null) {
|
||||
minionData.remove(removal);
|
||||
}
|
||||
markDirty();
|
||||
}
|
||||
|
||||
public List<MinionData> getMinionData() {
|
||||
public Map<UUID, MinionData> getMinionData() {
|
||||
return minionData;
|
||||
}
|
||||
|
||||
public void updateMinionData(MinionData data) {
|
||||
minionData.put(data.uuid(), data);
|
||||
markDirty();
|
||||
}
|
||||
|
||||
public boolean isMinion(UUID uuid) {
|
||||
return minionData.containsKey(uuid);
|
||||
}
|
||||
|
||||
public boolean isMinionNameTaken(String name) {
|
||||
return minionData.values().stream().anyMatch(data -> data.name().equals(name));
|
||||
}
|
||||
|
||||
public static void create(MinecraftServer server) {
|
||||
INSTANCE = server.getWorld(World.OVERWORLD).getPersistentStateManager().getOrCreate(TYPE, "minion");
|
||||
}
|
||||
|
||||
@@ -2,8 +2,14 @@ package io.github.skippyall.minions.minion;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.ProfileLookupCallback;
|
||||
import com.mojang.authlib.properties.PropertyMap;
|
||||
import com.mojang.authlib.yggdrasil.ProfileResult;
|
||||
import com.mojang.brigadier.StringReader;
|
||||
import io.github.skippyall.minions.input.Result;
|
||||
import net.minecraft.block.entity.SkullBlockEntity;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.StringHelper;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.UUID;
|
||||
@@ -13,59 +19,52 @@ import java.util.concurrent.ForkJoinPool;
|
||||
import static io.github.skippyall.minions.Minions.LOGGER;
|
||||
|
||||
public class MinionProfileUtils {
|
||||
public static CompletableFuture<@Nullable GameProfile> lookupSkinOwnerProfile(MinecraftServer server, String username) {
|
||||
CompletableFuture<GameProfile> future = new CompletableFuture<>();
|
||||
public static final String PREFIX = "+";
|
||||
|
||||
ForkJoinPool.commonPool().execute(() -> {
|
||||
try {
|
||||
server.getGameProfileRepo().findProfilesByNames(new String[]{username}, new ProfileLookupCallback() {
|
||||
@Override
|
||||
public void onProfileLookupSucceeded(GameProfile found) {
|
||||
LOGGER.info("SkinProfile: {}", found);
|
||||
try {
|
||||
getSkinOwnerProfile(server, found.getId()).thenAccept(future::complete);
|
||||
} catch (Throwable ex) {
|
||||
LOGGER.warn("Exception during Game Profile creation", ex);
|
||||
}
|
||||
}
|
||||
public static GameProfile makeNewMinionProfile(UUID uuidMinion, String username, PropertyMap skin) {
|
||||
if(uuidMinion == null) {
|
||||
uuidMinion = UUID.randomUUID();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProfileLookupFailed(String profileName, Exception exception) {
|
||||
LOGGER.warn("Lookup Error: ", exception);
|
||||
future.complete(null);
|
||||
}
|
||||
});
|
||||
} catch (Throwable e) {
|
||||
LOGGER.warn("Failed to get UUID for username " + username, e);
|
||||
future.complete(null);
|
||||
}
|
||||
});
|
||||
|
||||
return future;
|
||||
}
|
||||
|
||||
public static CompletableFuture<@Nullable GameProfile> getSkinOwnerProfile(MinecraftServer server, @Nullable UUID uuid) {
|
||||
CompletableFuture<GameProfile> future = new CompletableFuture<>();
|
||||
future.completeAsync(() -> {
|
||||
GameProfile profile = null;
|
||||
if(uuid != null) {
|
||||
ProfileResult result = server.getSessionService().fetchProfile(uuid, true);
|
||||
if (result != null) {
|
||||
profile = result.profile();
|
||||
LOGGER.info("Full SkinProfile: {}", profile);
|
||||
}
|
||||
}
|
||||
return profile;
|
||||
});
|
||||
return future;
|
||||
}
|
||||
|
||||
public static GameProfile makeNewMinionProfile(@Nullable UUID uuidMinion, String username, @Nullable GameProfile skinProfile) {
|
||||
GameProfile newProfile = new GameProfile(uuidMinion != null ? uuidMinion : UUID.randomUUID(), username);
|
||||
if (skinProfile != null) {
|
||||
newProfile.getProperties().putAll(skinProfile.getProperties());
|
||||
GameProfile newProfile = new GameProfile(uuidMinion, username);
|
||||
if (skin != null) {
|
||||
newProfile.getProperties().putAll(skin);
|
||||
}
|
||||
LOGGER.info("Minion Profile: {}", newProfile);
|
||||
return newProfile;
|
||||
}
|
||||
|
||||
public static Result<String, Text> checkMinionNameWithoutPrefix(String name) {
|
||||
for(char c : name.toCharArray()) {
|
||||
if(!StringReader.isAllowedInUnquotedString(c)) {
|
||||
return new Result.Error<>(Text.translatable("minions.generic.name.invalid_char"));
|
||||
}
|
||||
}
|
||||
|
||||
if((PREFIX + name).length() > 16) {
|
||||
return new Result.Error<>(Text.translatable("minions.generic.name.too_long"));
|
||||
}
|
||||
|
||||
if(!StringHelper.isValidPlayerName(PREFIX + name)) {
|
||||
return new Result.Error<>(Text.translatable("minions.generic.name.invalid"));
|
||||
}
|
||||
|
||||
if(MinionPersistentState.INSTANCE.isMinionNameTaken(PREFIX + name)) {
|
||||
return new Result.Error<>(Text.translatable("minions.generic.name.taken"));
|
||||
}
|
||||
|
||||
return new Result.Success<>(name);
|
||||
}
|
||||
|
||||
public static String newDefaultMinionName() {
|
||||
int i = 0;
|
||||
while (MinionPersistentState.INSTANCE.isMinionNameTaken("+Minion" + i)) {
|
||||
i++;
|
||||
}
|
||||
return "+Minion" + i;
|
||||
}
|
||||
|
||||
public static boolean isMinion(UUID uuid) {
|
||||
return MinionPersistentState.INSTANCE.isMinion(uuid);
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -1,4 +1,5 @@
|
||||
package io.github.skippyall.minions.fakeplayer;
|
||||
//code from https://github.com/gnembon/fabric-carpet
|
||||
package io.github.skippyall.minions.minion.fakeplayer;
|
||||
|
||||
import io.netty.channel.Channel;
|
||||
|
||||
+20
-13
@@ -1,4 +1,5 @@
|
||||
package io.github.skippyall.minions.fakeplayer;
|
||||
//partially code from https://github.com/gnembon/fabric-carpet
|
||||
package io.github.skippyall.minions.minion.fakeplayer;
|
||||
|
||||
|
||||
import java.util.EnumMap;
|
||||
@@ -82,6 +83,12 @@ public class EntityPlayerActionPack
|
||||
return this;
|
||||
}
|
||||
|
||||
public EntityPlayerActionPack stop(ActionType type) {
|
||||
Action previous = actions.remove(type);
|
||||
if (previous != null) type.stop(player, previous);
|
||||
return this;
|
||||
}
|
||||
|
||||
public EntityPlayerActionPack setSneaking(boolean doSneak)
|
||||
{
|
||||
sneaking = doSneak;
|
||||
@@ -292,7 +299,7 @@ public class EntityPlayerActionPack
|
||||
@Override
|
||||
boolean execute(ServerPlayerEntity player, Action action)
|
||||
{
|
||||
EntityPlayerActionPack ap = ((ServerPlayerInterface) player).getActionPack();
|
||||
EntityPlayerActionPack ap = ((ServerPlayerInterface) player).minions$getActionPack();
|
||||
if (ap.itemUseCooldown > 0)
|
||||
{
|
||||
ap.itemUseCooldown--;
|
||||
@@ -314,12 +321,12 @@ public class EntityPlayerActionPack
|
||||
BlockHitResult blockHit = (BlockHitResult) hit;
|
||||
BlockPos pos = blockHit.getBlockPos();
|
||||
Direction side = blockHit.getSide();
|
||||
if (pos.getY() < player.getWorld().getTopY() - (side == Direction.UP ? 1 : 0) && world.canPlayerModifyAt(player, pos))
|
||||
if (pos.getY() < player.getServerWorld().getTopYInclusive() - (side == Direction.UP ? 1 : 0) && world.canPlayerModifyAt(player, pos))
|
||||
{
|
||||
ActionResult result = player.interactionManager.interactBlock(player, world, player.getStackInHand(hand), hand, blockHit);
|
||||
if (result.isAccepted())
|
||||
if (result instanceof ActionResult.Success success)
|
||||
{
|
||||
if (result.shouldSwingHand()) player.swingHand(hand);
|
||||
if (success.swingSource() == ActionResult.SwingSource.SERVER) player.swingHand(hand);
|
||||
ap.itemUseCooldown = 3;
|
||||
return true;
|
||||
}
|
||||
@@ -361,7 +368,7 @@ public class EntityPlayerActionPack
|
||||
@Override
|
||||
void inactiveTick(ServerPlayerEntity player, Action action)
|
||||
{
|
||||
EntityPlayerActionPack ap = ((ServerPlayerInterface) player).getActionPack();
|
||||
EntityPlayerActionPack ap = ((ServerPlayerInterface) player).minions$getActionPack();
|
||||
ap.itemUseCooldown = 0;
|
||||
player.stopUsingItem();
|
||||
}
|
||||
@@ -383,7 +390,7 @@ public class EntityPlayerActionPack
|
||||
return true;
|
||||
}
|
||||
case BLOCK: {
|
||||
EntityPlayerActionPack ap = ((ServerPlayerInterface) player).getActionPack();
|
||||
EntityPlayerActionPack ap = ((ServerPlayerInterface) player).minions$getActionPack();
|
||||
if (ap.blockHitDelay > 0)
|
||||
{
|
||||
ap.blockHitDelay--;
|
||||
@@ -402,7 +409,7 @@ public class EntityPlayerActionPack
|
||||
boolean blockBroken = false;
|
||||
if (player.interactionManager.getGameMode().isCreative())
|
||||
{
|
||||
player.interactionManager.processBlockBreakingAction(pos, PlayerActionC2SPacket.Action.START_DESTROY_BLOCK, side, player.getWorld().getTopY(), -1);
|
||||
player.interactionManager.processBlockBreakingAction(pos, PlayerActionC2SPacket.Action.START_DESTROY_BLOCK, side, player.getWorld().getTopYInclusive(), -1);
|
||||
ap.blockHitDelay = 5;
|
||||
blockBroken = true;
|
||||
}
|
||||
@@ -410,9 +417,9 @@ public class EntityPlayerActionPack
|
||||
{
|
||||
if (ap.currentBlock != null)
|
||||
{
|
||||
player.interactionManager.processBlockBreakingAction(ap.currentBlock, PlayerActionC2SPacket.Action.ABORT_DESTROY_BLOCK, side, player.getWorld().getTopY(), -1);
|
||||
player.interactionManager.processBlockBreakingAction(ap.currentBlock, PlayerActionC2SPacket.Action.ABORT_DESTROY_BLOCK, side, player.getWorld().getTopYInclusive(), -1);
|
||||
}
|
||||
player.interactionManager.processBlockBreakingAction(pos, PlayerActionC2SPacket.Action.START_DESTROY_BLOCK, side, player.getWorld().getTopY(), -1);
|
||||
player.interactionManager.processBlockBreakingAction(pos, PlayerActionC2SPacket.Action.START_DESTROY_BLOCK, side, player.getWorld().getTopYInclusive(), -1);
|
||||
boolean notAir = !state.isAir();
|
||||
if (notAir && ap.curBlockDamageMP == 0)
|
||||
{
|
||||
@@ -435,7 +442,7 @@ public class EntityPlayerActionPack
|
||||
ap.curBlockDamageMP += state.calcBlockBreakingDelta(player, player.getWorld(), pos);
|
||||
if (ap.curBlockDamageMP >= 1)
|
||||
{
|
||||
player.interactionManager.processBlockBreakingAction(pos, PlayerActionC2SPacket.Action.STOP_DESTROY_BLOCK, side, player.getWorld().getTopY(), -1);
|
||||
player.interactionManager.processBlockBreakingAction(pos, PlayerActionC2SPacket.Action.STOP_DESTROY_BLOCK, side, player.getWorld().getTopYInclusive(), -1);
|
||||
ap.currentBlock = null;
|
||||
ap.blockHitDelay = 5;
|
||||
blockBroken = true;
|
||||
@@ -454,10 +461,10 @@ public class EntityPlayerActionPack
|
||||
@Override
|
||||
void inactiveTick(ServerPlayerEntity player, Action action)
|
||||
{
|
||||
EntityPlayerActionPack ap = ((ServerPlayerInterface) player).getActionPack();
|
||||
EntityPlayerActionPack ap = ((ServerPlayerInterface) player).minions$getActionPack();
|
||||
if (ap.currentBlock == null) return;
|
||||
player.getWorld().setBlockBreakingInfo(-1, ap.currentBlock, -1);
|
||||
player.interactionManager.processBlockBreakingAction(ap.currentBlock, PlayerActionC2SPacket.Action.ABORT_DESTROY_BLOCK, Direction.DOWN, player.getWorld().getTopY(), -1);
|
||||
player.interactionManager.processBlockBreakingAction(ap.currentBlock, PlayerActionC2SPacket.Action.ABORT_DESTROY_BLOCK, Direction.DOWN, player.getWorld().getTopYInclusive(), -1);
|
||||
ap.currentBlock = null;
|
||||
}
|
||||
},
|
||||
+2
-2
@@ -1,11 +1,11 @@
|
||||
package io.github.skippyall.minions.fakeplayer;
|
||||
//code from https://github.com/gnembon/fabric-carpet
|
||||
package io.github.skippyall.minions.minion.fakeplayer;
|
||||
|
||||
import io.netty.channel.embedded.EmbeddedChannel;
|
||||
import net.minecraft.network.ClientConnection;
|
||||
import net.minecraft.network.NetworkSide;
|
||||
import net.minecraft.network.NetworkState;
|
||||
import net.minecraft.network.listener.PacketListener;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
public class FakeClientConnection extends ClientConnection {
|
||||
public FakeClientConnection(NetworkSide p)
|
||||
+47
-89
@@ -1,7 +1,10 @@
|
||||
package io.github.skippyall.minions.fakeplayer;
|
||||
//partially code from https://github.com/gnembon/fabric-carpet
|
||||
package io.github.skippyall.minions.minion.fakeplayer;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.properties.PropertyMap;
|
||||
import io.github.skippyall.minions.Minions;
|
||||
import io.github.skippyall.minions.MinionsTickExecutor;
|
||||
import io.github.skippyall.minions.minion.MinionData;
|
||||
import io.github.skippyall.minions.gui.MinionGui;
|
||||
import io.github.skippyall.minions.minion.MinionItem;
|
||||
@@ -10,7 +13,7 @@ import io.github.skippyall.minions.minion.MinionProfileUtils;
|
||||
import io.github.skippyall.minions.gui.ModuleInventory;
|
||||
import io.github.skippyall.minions.program.runtime.MinionRuntime;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.component.DataComponentTypes;
|
||||
import net.minecraft.block.EndPortalBlock;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EquipmentSlot;
|
||||
import net.minecraft.entity.MovementType;
|
||||
@@ -24,7 +27,7 @@ import net.minecraft.network.DisconnectionInfo;
|
||||
import net.minecraft.network.NetworkSide;
|
||||
import net.minecraft.network.packet.c2s.common.SyncedClientOptions;
|
||||
import net.minecraft.network.packet.c2s.play.ClientStatusC2SPacket;
|
||||
import net.minecraft.network.packet.s2c.play.EntityPositionS2CPacket;
|
||||
import net.minecraft.network.packet.s2c.play.EntityPositionSyncS2CPacket;
|
||||
import net.minecraft.network.packet.s2c.play.EntitySetHeadYawS2CPacket;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.ServerTask;
|
||||
@@ -42,7 +45,7 @@ import net.minecraft.world.GameMode;
|
||||
import net.minecraft.world.TeleportTarget;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public class MinionFakePlayer extends ServerPlayerEntity {
|
||||
@@ -55,90 +58,52 @@ public class MinionFakePlayer extends ServerPlayerEntity {
|
||||
private final ModuleInventory moduleInventory = new ModuleInventory();
|
||||
private final MinionRuntime runtime = new MinionRuntime(this);
|
||||
|
||||
private UUID skinUuid = null;
|
||||
private final MinionData data;
|
||||
|
||||
public static void createMinion(MinionData data, ServerWorld level, ServerPlayerEntity owner, boolean canProgram, Vec3d pos, double yaw, double pitch) {
|
||||
public static void spawnMinion(MinionData data, ServerWorld level, @Nullable Vec3d pos, @Nullable Vec2f rot) {
|
||||
MinecraftServer server = level.getServer();
|
||||
|
||||
CompletableFuture<GameProfile> future;
|
||||
if(data.skinUuid != null) {
|
||||
future = MinionProfileUtils.getSkinOwnerProfile(server, data.skinUuid);
|
||||
} else {
|
||||
future = MinionProfileUtils.lookupSkinOwnerProfile(server, data.name);
|
||||
}
|
||||
PropertyMap skin = data.skin().orElse(null);
|
||||
|
||||
future.thenAccept(skinProfile -> {
|
||||
GameProfile profile = MinionProfileUtils.makeNewMinionProfile(null, data.name, skinProfile);
|
||||
Minions.addExecuteOnNextTick(() -> {
|
||||
MinionFakePlayer instance = new MinionFakePlayer(server, level, profile, SyncedClientOptions.createDefault());
|
||||
if(skinProfile != null) {
|
||||
instance.skinUuid = skinProfile.getId();
|
||||
}
|
||||
GameProfile profile = MinionProfileUtils.makeNewMinionProfile(data.uuid(), data.name(), skin);
|
||||
doSpawn(data, profile, server, level, pos, rot);
|
||||
|
||||
instance.programmable = canProgram;
|
||||
instance.fixStartingPosition = () -> instance.refreshPositionAndAngles(pos.x, pos.y, pos.z, (float) yaw, (float) pitch);
|
||||
server.getPlayerManager().onPlayerConnect(new FakeClientConnection(NetworkSide.SERVERBOUND), instance, new ConnectedClientData(profile, 0, instance.getClientOptions(), false));
|
||||
instance.teleport(level, pos.x, pos.y, pos.z, (float) yaw, (float) pitch);
|
||||
instance.setHealth(20.0F);
|
||||
instance.unsetRemoved();
|
||||
instance.getAttributeInstance(EntityAttributes.GENERIC_STEP_HEIGHT).setBaseValue(0.6F);
|
||||
instance.interactionManager.changeGameMode(GameMode.SURVIVAL);
|
||||
server.getPlayerManager().sendToDimension(new EntitySetHeadYawS2CPacket(instance, (byte) (instance.headYaw * 256 / 360)), level.getRegistryKey());//instance.dimension);
|
||||
server.getPlayerManager().sendToDimension(new EntityPositionS2CPacket(instance), level.getRegistryKey());//instance.dimension);
|
||||
//instance.world.getChunkManager(). updatePosition(instance);
|
||||
instance.dataTracker.set(PLAYER_MODEL_PARTS, (byte) 0x7f); // show all model layers (incl. capes)
|
||||
instance.getAbilities().flying = false;
|
||||
MinionPersistentState.INSTANCE.addMinion(instance);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
public static void spawnMinionAt(MinionData data, ServerWorld level, @Nullable Vec3d pos, @Nullable Vec2f rot) {
|
||||
MinecraftServer server = level.getServer();
|
||||
private static void doSpawn(MinionData data, GameProfile profile, MinecraftServer server, ServerWorld level, @Nullable Vec3d pos, @Nullable Vec2f rot) {
|
||||
|
||||
CompletableFuture<GameProfile> future;
|
||||
if(data.skinUuid != null) {
|
||||
future = MinionProfileUtils.getSkinOwnerProfile(server, data.skinUuid);
|
||||
} else {
|
||||
future = MinionProfileUtils.lookupSkinOwnerProfile(server, data.name);
|
||||
MinionFakePlayer instance = new MinionFakePlayer(server, level, profile, SyncedClientOptions.createDefault(), data);
|
||||
MinionPersistentState.INSTANCE.updateMinionData(data.withSpawned(true));
|
||||
|
||||
if(pos != null && rot != null) {
|
||||
instance.fixStartingPosition = () -> instance.refreshPositionAndAngles(pos.x, pos.y, pos.z, rot.x, rot.y);
|
||||
}
|
||||
|
||||
future.thenAccept((skinProfile) -> {
|
||||
GameProfile profile = MinionProfileUtils.makeNewMinionProfile(data.uuid, data.name, skinProfile);
|
||||
Minions.addExecuteOnNextTick(() -> {
|
||||
MinionFakePlayer instance = new MinionFakePlayer(server, level, profile, SyncedClientOptions.createDefault());
|
||||
if (skinProfile != null) {
|
||||
instance.skinUuid = skinProfile.getId();
|
||||
}
|
||||
if(pos != null && rot != null) {
|
||||
instance.fixStartingPosition = () -> instance.refreshPositionAndAngles(pos.x, pos.y, pos.z, rot.x, rot.y);
|
||||
}
|
||||
server.getPlayerManager().onPlayerConnect(new FakeClientConnection(NetworkSide.SERVERBOUND), instance, new ConnectedClientData(profile, 0, instance.getClientOptions(), false));
|
||||
System.out.println(instance.getPos());
|
||||
if(pos != null && rot != null) {
|
||||
instance.teleport(level, pos.x, pos.y, pos.z, rot.x, rot.y);
|
||||
}
|
||||
instance.setVelocity(0,0,0);
|
||||
instance.setHealth(20.0F);
|
||||
instance.unsetRemoved();
|
||||
instance.interactionManager.changeGameMode(GameMode.SURVIVAL);
|
||||
server.getPlayerManager().sendToDimension(new EntitySetHeadYawS2CPacket(instance, (byte) (instance.headYaw * 256 / 360)), level.getRegistryKey());//instance.dimension);
|
||||
server.getPlayerManager().sendToDimension(new EntityPositionS2CPacket(instance), level.getRegistryKey());//instance.dimension);
|
||||
//instance.world.getChunkManager(). updatePosition(instance);
|
||||
instance.dataTracker.set(PLAYER_MODEL_PARTS, (byte) 0x7f); // show all model layers (incl. capes)
|
||||
instance.getAbilities().flying = false;
|
||||
});
|
||||
});
|
||||
server.getPlayerManager().onPlayerConnect(new FakeClientConnection(NetworkSide.SERVERBOUND), instance, new ConnectedClientData(profile, 0, instance.getClientOptions(), false));
|
||||
System.out.println(instance.getPos());
|
||||
if(pos != null && rot != null) {
|
||||
instance.teleport(level, pos.x, pos.y, pos.z, Set.of(), rot.x, rot.y, true);
|
||||
}
|
||||
instance.setVelocity(0,0,0);
|
||||
instance.setHealth(20.0F);
|
||||
instance.unsetRemoved();
|
||||
instance.getAttributeInstance(EntityAttributes.STEP_HEIGHT).setBaseValue(0.6F);
|
||||
instance.interactionManager.changeGameMode(GameMode.SURVIVAL);
|
||||
server.getPlayerManager().sendToDimension(new EntitySetHeadYawS2CPacket(instance, (byte) (instance.headYaw * 256 / 360)), level.getRegistryKey());//instance.dimension);
|
||||
server.getPlayerManager().sendToDimension(EntityPositionSyncS2CPacket.create(instance), level.getRegistryKey());//instance.dimension);
|
||||
//instance.world.getChunkManager(). updatePosition(instance);
|
||||
instance.dataTracker.set(PLAYER_MODEL_PARTS, (byte) 0x7f); // show all model layers (incl. capes)
|
||||
instance.getAbilities().flying = false;
|
||||
}
|
||||
|
||||
public static MinionFakePlayer respawnFake(MinecraftServer server, ServerWorld level, GameProfile profile, SyncedClientOptions cli)
|
||||
public static MinionFakePlayer respawnFake(MinecraftServer server, ServerWorld level, GameProfile profile, SyncedClientOptions cli, MinionData data)
|
||||
{
|
||||
return new MinionFakePlayer(server, level, profile, cli);
|
||||
return new MinionFakePlayer(server, level, profile, cli, data);
|
||||
}
|
||||
|
||||
private MinionFakePlayer(MinecraftServer server, ServerWorld worldIn, GameProfile profile, SyncedClientOptions cli)
|
||||
private MinionFakePlayer(MinecraftServer server, ServerWorld worldIn, GameProfile profile, SyncedClientOptions cli, MinionData data)
|
||||
{
|
||||
super(server, worldIn, profile, cli);
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public boolean isProgrammable() {
|
||||
@@ -158,7 +123,7 @@ public class MinionFakePlayer extends ServerPlayerEntity {
|
||||
}
|
||||
|
||||
public EntityPlayerActionPack getMinionActionPack() {
|
||||
return ((ServerPlayerInterface)this).getActionPack();
|
||||
return ((ServerPlayerInterface)this).minions$getActionPack();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -198,7 +163,7 @@ public class MinionFakePlayer extends ServerPlayerEntity {
|
||||
}));
|
||||
}
|
||||
|
||||
MinionPersistentState.INSTANCE.removeMinion(this);
|
||||
MinionPersistentState.INSTANCE.updateMinionData(data.withSpawned(false));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -259,7 +224,7 @@ public class MinionFakePlayer extends ServerPlayerEntity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Entity teleportTo(TeleportTarget target)
|
||||
public ServerPlayerEntity teleportTo(TeleportTarget target)
|
||||
{
|
||||
super.teleportTo(target);
|
||||
if (notInAnyWorld) {
|
||||
@@ -314,20 +279,21 @@ public class MinionFakePlayer extends ServerPlayerEntity {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drop(ServerWorld world, DamageSource damageSource) {
|
||||
public void drop(ServerWorld world, DamageSource damageSource) {
|
||||
super.drop(world, damageSource);
|
||||
dropStack(toItemStack());
|
||||
dropStack(world, toItemStack()).setNeverDespawn();
|
||||
}
|
||||
|
||||
private ItemStack toItemStack() {
|
||||
ItemStack stack = new ItemStack(Minions.MINION_ITEM);
|
||||
MinionItem.setData(MinionData.fromMinion(this), stack);
|
||||
if (!getMinionName().equals("Minion")) {
|
||||
stack.set(DataComponentTypes.CUSTOM_NAME, Text.of(getMinionName()));
|
||||
}
|
||||
MinionItem.setData(data, stack);
|
||||
return stack;
|
||||
}
|
||||
|
||||
public MinionData getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeCustomDataToNbt(NbtCompound nbt) {
|
||||
super.writeCustomDataToNbt(nbt);
|
||||
@@ -341,12 +307,4 @@ public class MinionFakePlayer extends ServerPlayerEntity {
|
||||
moduleInventory.readNbt(nbt.getCompound("modules"), getRegistryManager());
|
||||
programmable = nbt.getBoolean("programmable");
|
||||
}
|
||||
|
||||
public String getMinionName() {
|
||||
return getGameProfile().getName();
|
||||
}
|
||||
|
||||
public UUID getSkinUuid() {
|
||||
return skinUuid;
|
||||
}
|
||||
}
|
||||
+5
-3
@@ -1,5 +1,7 @@
|
||||
package io.github.skippyall.minions.fakeplayer;
|
||||
//code from https://github.com/gnembon/fabric-carpet
|
||||
package io.github.skippyall.minions.minion.fakeplayer;
|
||||
|
||||
import net.minecraft.entity.player.PlayerPosition;
|
||||
import net.minecraft.network.ClientConnection;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.network.packet.s2c.play.PositionFlag;
|
||||
@@ -33,9 +35,9 @@ public class NetHandlerPlayServerFake extends ServerPlayNetworkHandler
|
||||
}
|
||||
|
||||
@Override
|
||||
public void requestTeleport(double d, double e, double f, float g, float h, Set<PositionFlag> set)
|
||||
public void requestTeleport(PlayerPosition pos, Set<PositionFlag> set)
|
||||
{
|
||||
super.requestTeleport(d, e, f, g, h, set);
|
||||
super.requestTeleport(pos, set);
|
||||
if (player.getServerWorld().getPlayerByUuid(player.getUuid()) != null) {
|
||||
syncWithPlayerPosition();
|
||||
player.getServerWorld().getChunkManager().updatePosition(player);
|
||||
@@ -0,0 +1,7 @@
|
||||
//code from https://github.com/gnembon/fabric-carpet
|
||||
package io.github.skippyall.minions.minion.fakeplayer;
|
||||
|
||||
public interface ServerPlayerInterface
|
||||
{
|
||||
EntityPlayerActionPack minions$getActionPack();
|
||||
}
|
||||
+2
-1
@@ -1,4 +1,5 @@
|
||||
package io.github.skippyall.minions.fakeplayer;
|
||||
//code from https://github.com/gnembon/fabric-carpet
|
||||
package io.github.skippyall.minions.minion.fakeplayer;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.function.Predicate;
|
||||
@@ -0,0 +1,27 @@
|
||||
package io.github.skippyall.minions.minion.skin;
|
||||
|
||||
import com.mojang.authlib.properties.Property;
|
||||
import com.mojang.authlib.properties.PropertyMap;
|
||||
import io.github.skippyall.minions.input.TextInput;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public class Base64SkinProvider implements SkinProvider {
|
||||
@Override
|
||||
public CompletableFuture<Optional<PropertyMap>> openSkinMenu(ServerPlayerEntity player) {
|
||||
return TextInput.inputString(player, Text.translatable("minions.gui.look.skin.base64.title"), "")
|
||||
.thenApply(base64String -> {
|
||||
PropertyMap map = new PropertyMap();
|
||||
map.put("textures", new Property("textures", base64String));
|
||||
return Optional.of(map);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public Text getDisplayName() {
|
||||
return Text.translatable("minions.gui.look.skin.base64");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package io.github.skippyall.minions.minion.skin;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.properties.PropertyMap;
|
||||
import io.github.skippyall.minions.input.TextInput;
|
||||
import net.minecraft.block.entity.SkullBlockEntity;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public class NameSkinProvider implements SkinProvider {
|
||||
@Override
|
||||
public CompletableFuture<Optional<PropertyMap>> openSkinMenu(ServerPlayerEntity player) {
|
||||
return TextInput.inputString(player, Text.translatable("minions.gui.look.skin.name.title"), "")
|
||||
.thenCompose(SkullBlockEntity::fetchProfileByName)
|
||||
.thenApply(gameProfile -> gameProfile.map(GameProfile::getProperties));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Text getDisplayName() {
|
||||
return Text.translatable("minions.gui.look.skin.name");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package io.github.skippyall.minions.minion.skin;
|
||||
|
||||
import com.mojang.authlib.properties.PropertyMap;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public interface SkinProvider {
|
||||
CompletableFuture<Optional<PropertyMap>> openSkinMenu(ServerPlayerEntity player);
|
||||
|
||||
Text getDisplayName();
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package io.github.skippyall.minions.minion.skin;
|
||||
|
||||
import com.mojang.serialization.Lifecycle;
|
||||
import io.github.skippyall.minions.Minions;
|
||||
import net.minecraft.registry.Registry;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.SimpleRegistry;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
public class SkinProviders {
|
||||
public static final Registry<SkinProvider> SKIN_PROVIDERS = new SimpleRegistry<>(RegistryKey.ofRegistry(Identifier.of(Minions.MOD_ID, "skin_providers")), Lifecycle.stable());
|
||||
|
||||
public static NameSkinProvider NAME = register(new NameSkinProvider(), "name");
|
||||
public static UUIDSkinProvider UUID = register(new UUIDSkinProvider(), "uuid");
|
||||
public static Base64SkinProvider BASE64 = register(new Base64SkinProvider(), "base64");
|
||||
|
||||
|
||||
public static <T extends SkinProvider> T register(T skinProvider, String path) {
|
||||
return Registry.register(SKIN_PROVIDERS, Identifier.of(Minions.MOD_ID, path), skinProvider);
|
||||
}
|
||||
|
||||
public static void register() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package io.github.skippyall.minions.minion.skin;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.properties.PropertyMap;
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
import io.github.skippyall.minions.input.TextInput;
|
||||
import io.github.skippyall.minions.minion.MinionProfileUtils;
|
||||
import net.minecraft.block.entity.SkullBlockEntity;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Uuids;
|
||||
import net.minecraft.util.dynamic.Codecs;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public class UUIDSkinProvider implements SkinProvider {
|
||||
@Override
|
||||
public CompletableFuture<Optional<PropertyMap>> openSkinMenu(ServerPlayerEntity player) {
|
||||
return TextInput.inputString(player, Text.translatable("minions.gui.look.skin.uuid.title"), "")
|
||||
.thenCompose(uuidString -> SkullBlockEntity.fetchProfileByUuid(UUID.fromString(uuidString)))
|
||||
.thenApply(gameProfile -> gameProfile.map(GameProfile::getProperties));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Text getDisplayName() {
|
||||
return Text.translatable("minions.gui.look.skin.uuid");
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
package io.github.skippyall.minions.mixinhelper;
|
||||
|
||||
public interface ChunkTicketManager$DistanceFromNearestPlayerTrackerAccessor {
|
||||
void minions$markAsMinionless();
|
||||
void minions$markAsTarget();
|
||||
int minions$getTickedChunkCount();
|
||||
|
||||
boolean minions$isRealPlayerInChunk(long chunkPos);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package io.github.skippyall.minions.mixinhelper;
|
||||
|
||||
import it.unimi.dsi.fastutil.objects.ObjectSet;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.server.world.ChunkTicketManager;
|
||||
|
||||
public interface ChunkTicketManagerAccessor {
|
||||
ObjectSet<ServerPlayerEntity> getPlayers(long chunkpos);
|
||||
|
||||
ChunkTicketManager.DistanceFromNearestPlayerTracker getMinionless();
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package io.github.skippyall.minions.mixinhelpers;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class EntityViewMixinHelper {
|
||||
public static final ThreadLocal<Predicate<Entity>> ADDITIONAL_PREDICATE = ThreadLocal.withInitial(() -> entity -> true);
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
//code from https://github.com/gnembon/fabric-carpet
|
||||
package io.github.skippyall.minions.mixins;
|
||||
|
||||
import io.github.skippyall.minions.fakeplayer.ClientConnectionInterface;
|
||||
import io.github.skippyall.minions.minion.fakeplayer.ClientConnectionInterface;
|
||||
import io.netty.channel.Channel;
|
||||
import net.minecraft.network.ClientConnection;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package io.github.skippyall.minions.mixins;
|
||||
|
||||
import io.github.skippyall.minions.mixinhelpers.EntityViewMixinHelper;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.world.EntityView;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyArg;
|
||||
|
||||
import java.util.function.Predicate;
|
||||
|
||||
@Mixin(EntityView.class)
|
||||
public interface EntityViewMixin {
|
||||
@ModifyArg(method = "getClosestPlayer(DDDDZ)Lnet/minecraft/entity/player/PlayerEntity;", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/EntityView;getClosestPlayer(DDDDLjava/util/function/Predicate;)Lnet/minecraft/entity/player/PlayerEntity;"))
|
||||
private @Nullable Predicate<Entity> addMinionPredicate(@Nullable Predicate<Entity> targetPredicate) {
|
||||
Predicate<Entity> predicate = EntityViewMixinHelper.ADDITIONAL_PREDICATE.get();
|
||||
if(targetPredicate != null) {
|
||||
return predicate.and(targetPredicate);
|
||||
} else {
|
||||
return predicate;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package io.github.skippyall.minions.mixins;
|
||||
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import eu.pb4.graves.grave.Grave;
|
||||
import io.github.skippyall.minions.minion.fakeplayer.MinionFakePlayer;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyArg;
|
||||
|
||||
@Mixin(Grave.class)
|
||||
public class GraveCompatMixin {
|
||||
@ModifyArg(method = "createBlock", at = @At(value = "INVOKE", target = "Leu/pb4/graves/grave/Grave;<init>(JLcom/mojang/authlib/GameProfile;BLnet/minecraft/util/Arm;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/Identifier;Leu/pb4/graves/grave/GraveType;JJILnet/minecraft/text/Text;Ljava/util/Collection;Ljava/util/Collection;ZI)V"))
|
||||
private static boolean createGrave(boolean profile, @Local(argsOnly = true) ServerPlayerEntity player) {
|
||||
if(player instanceof MinionFakePlayer) {
|
||||
return false;
|
||||
}
|
||||
return profile;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package io.github.skippyall.minions.mixins;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
|
||||
import io.github.skippyall.minions.fakeplayer.MinionFakePlayer;
|
||||
import io.github.skippyall.minions.minion.fakeplayer.MinionFakePlayer;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
||||
@@ -1,29 +1,36 @@
|
||||
package io.github.skippyall.minions.mixins;
|
||||
|
||||
import io.github.skippyall.minions.fakeplayer.MinionFakePlayer;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
||||
import io.github.skippyall.minions.minion.fakeplayer.MinionFakePlayer;
|
||||
import io.github.skippyall.minions.mixinhelpers.EntityViewMixinHelper;
|
||||
import io.github.skippyall.minions.module.MobSpawningModule;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.mob.MobEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NbtCompound;
|
||||
import net.minecraft.predicate.entity.EntityPredicates;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.world.World;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
@Mixin(MobEntity.class)
|
||||
public abstract class MobEntityMixin {
|
||||
@Redirect(method = "checkDespawn", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;getClosestPlayer(Lnet/minecraft/entity/Entity;D)Lnet/minecraft/entity/player/PlayerEntity;"))
|
||||
public PlayerEntity checkMobDespawningMinion(World instance, Entity entity, double maxDistance) {
|
||||
return instance.getClosestPlayer(entity.getX(), entity.getY(), entity.getZ(), maxDistance, EntityPredicates.EXCEPT_SPECTATOR.and(entity1 -> {
|
||||
if(entity1 instanceof ServerPlayerEntity player) {
|
||||
if(player instanceof MinionFakePlayer minion) {
|
||||
return MobSpawningModule.canMinionDespawnMobs(minion);
|
||||
}
|
||||
@WrapOperation(method = "checkDespawn", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;getClosestPlayer(Lnet/minecraft/entity/Entity;D)Lnet/minecraft/entity/player/PlayerEntity;"))
|
||||
public PlayerEntity checkMobDespawningMinion(World instance, Entity entity, double maxDistance, Operation<PlayerEntity> original) {
|
||||
EntityViewMixinHelper.ADDITIONAL_PREDICATE.set(entity2 -> {
|
||||
if(entity2 instanceof MinionFakePlayer minion) {
|
||||
return MobSpawningModule.canMinionDespawnMobs(minion);
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}));
|
||||
});
|
||||
PlayerEntity player = original.call(instance, entity, maxDistance);
|
||||
EntityViewMixinHelper.ADDITIONAL_PREDICATE.remove();
|
||||
return player;
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
package io.github.skippyall.minions.mixins;
|
||||
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import io.github.skippyall.minions.fakeplayer.MinionFakePlayer;
|
||||
import io.github.skippyall.minions.minion.fakeplayer.MinionFakePlayer;
|
||||
import net.minecraft.network.packet.s2c.play.PlayerListS2CPacket;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
@@ -10,7 +10,7 @@ import org.spongepowered.asm.mixin.injection.ModifyArg;
|
||||
|
||||
@Mixin(PlayerListS2CPacket.Entry.class)
|
||||
public class PlayerListEntryS2CPacket$EntryMixin {
|
||||
@ModifyArg(method = "<init>(Lnet/minecraft/server/network/ServerPlayerEntity;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/packet/s2c/play/PlayerListS2CPacket$Entry;<init>(Ljava/util/UUID;Lcom/mojang/authlib/GameProfile;ZILnet/minecraft/world/GameMode;Lnet/minecraft/text/Text;Lnet/minecraft/network/encryption/PublicPlayerSession$Serialized;)V"))
|
||||
@ModifyArg(method = "<init>(Lnet/minecraft/server/network/ServerPlayerEntity;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/packet/s2c/play/PlayerListS2CPacket$Entry;<init>(Ljava/util/UUID;Lcom/mojang/authlib/GameProfile;ZILnet/minecraft/world/GameMode;Lnet/minecraft/text/Text;ILnet/minecraft/network/encryption/PublicPlayerSession$Serialized;)V"))
|
||||
private static boolean removeMinionFromTabList(boolean original, @Local(argsOnly = true) ServerPlayerEntity player) {
|
||||
if(player instanceof MinionFakePlayer) {
|
||||
return false;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
//partially code from https://github.com/gnembon/fabric-carpet
|
||||
package io.github.skippyall.minions.mixins;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.ModifyReceiver;
|
||||
@@ -5,8 +6,8 @@ import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import io.github.skippyall.minions.fakeplayer.MinionFakePlayer;
|
||||
import io.github.skippyall.minions.fakeplayer.NetHandlerPlayServerFake;
|
||||
import io.github.skippyall.minions.minion.fakeplayer.MinionFakePlayer;
|
||||
import io.github.skippyall.minions.minion.fakeplayer.NetHandlerPlayServerFake;
|
||||
import net.minecraft.nbt.NbtCompound;
|
||||
import net.minecraft.network.ClientConnection;
|
||||
import net.minecraft.network.packet.c2s.common.SyncedClientOptions;
|
||||
@@ -51,7 +52,7 @@ public class PlayerListMixin {
|
||||
@WrapOperation(method = "respawnPlayer", at = @At(value = "NEW", target = "(Lnet/minecraft/server/MinecraftServer;Lnet/minecraft/server/world/ServerWorld;Lcom/mojang/authlib/GameProfile;Lnet/minecraft/network/packet/c2s/common/SyncedClientOptions;)Lnet/minecraft/server/network/ServerPlayerEntity;"))
|
||||
public ServerPlayerEntity makePlayerForRespawn(MinecraftServer minecraftServer, ServerWorld serverLevel, GameProfile gameProfile, SyncedClientOptions clientInformation, Operation<ServerPlayerEntity> original, ServerPlayerEntity serverPlayer, boolean bl) {
|
||||
if (serverPlayer instanceof MinionFakePlayer minion) {
|
||||
return MinionFakePlayer.respawnFake(minecraftServer, serverLevel, gameProfile, clientInformation);
|
||||
return MinionFakePlayer.respawnFake(minecraftServer, serverLevel, gameProfile, clientInformation, minion.getData());
|
||||
}
|
||||
return original.call(minecraftServer, serverLevel, gameProfile, clientInformation);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package io.github.skippyall.minions.mixins;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
||||
import io.github.skippyall.minions.fakeplayer.MinionFakePlayer;
|
||||
import io.github.skippyall.minions.minion.fakeplayer.MinionFakePlayer;
|
||||
import net.minecraft.server.PlayerManager;
|
||||
import net.minecraft.server.network.ServerPlayNetworkHandler;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package io.github.skippyall.minions.mixins;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import io.github.skippyall.minions.fakeplayer.EntityPlayerActionPack;
|
||||
import io.github.skippyall.minions.fakeplayer.ServerPlayerInterface;
|
||||
import io.github.skippyall.minions.minion.fakeplayer.EntityPlayerActionPack;
|
||||
import io.github.skippyall.minions.minion.fakeplayer.ServerPlayerInterface;
|
||||
import net.minecraft.network.packet.c2s.common.SyncedClientOptions;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
@@ -18,7 +18,7 @@ public abstract class ServerPlayerMixin implements ServerPlayerInterface {
|
||||
@Unique
|
||||
public EntityPlayerActionPack actionPack;
|
||||
@Override
|
||||
public EntityPlayerActionPack getActionPack()
|
||||
public EntityPlayerActionPack minions$getActionPack()
|
||||
{
|
||||
return actionPack;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package io.github.skippyall.minions.mixins;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
||||
import io.github.skippyall.minions.fakeplayer.MinionFakePlayer;
|
||||
import io.github.skippyall.minions.minion.fakeplayer.MinionFakePlayer;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.server.world.SleepManager;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package io.github.skippyall.minions.mixins;
|
||||
|
||||
import io.github.skippyall.minions.fakeplayer.MinionFakePlayer;
|
||||
import io.github.skippyall.minions.minion.fakeplayer.MinionFakePlayer;
|
||||
import io.github.skippyall.minions.module.MobSpawningModule;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.predicate.entity.EntityPredicates;
|
||||
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package io.github.skippyall.minions.mixins.antimobcap;
|
||||
|
||||
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.CallbackInfo;
|
||||
|
||||
@Mixin(net.minecraft.world.ChunkPosDistanceLevelPropagator.class)
|
||||
public class ChunkPosDistanceLevelPropagatorMixin {
|
||||
@Inject(method = "updateLevel", at = @At("HEAD"))
|
||||
public void minions$updateLevel(long chunkPos, int distance, boolean decrease, CallbackInfo info) {
|
||||
|
||||
}
|
||||
}
|
||||
+85
@@ -0,0 +1,85 @@
|
||||
package io.github.skippyall.minions.mixins.antimobcap;
|
||||
|
||||
import io.github.skippyall.minions.minion.fakeplayer.MinionFakePlayer;
|
||||
import io.github.skippyall.minions.mixinhelper.ChunkTicketManager$DistanceFromNearestPlayerTrackerAccessor;
|
||||
import io.github.skippyall.minions.mixinhelper.ChunkTicketManagerAccessor;
|
||||
import io.github.skippyall.minions.module.MobSpawningModule;
|
||||
import it.unimi.dsi.fastutil.longs.Long2ByteMap;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectSet;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.server.world.ChunkTicketManager;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(value = ChunkTicketManager.DistanceFromNearestPlayerTracker.class)
|
||||
public abstract class ChunkTicketManager$DistanceFromNearestPlayerTrackerMixin extends ChunkPosDistanceLevelPropagatorMixin implements ChunkTicketManager$DistanceFromNearestPlayerTrackerAccessor {
|
||||
@Final
|
||||
@Shadow
|
||||
ChunkTicketManager field_17462;
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
protected Long2ByteMap distanceFromNearestPlayer;
|
||||
|
||||
@Shadow protected abstract boolean isPlayerInChunk(long chunkPos);
|
||||
|
||||
@Unique
|
||||
boolean minions$minionless, minions$target;
|
||||
|
||||
@Inject(method = "isPlayerInChunk", at = @At("RETURN"), cancellable = true)
|
||||
public void minions$filterMinions(long chunkPos, CallbackInfoReturnable<Boolean> cir) {
|
||||
if (minions$minionless) {
|
||||
cir.setReturnValue(minions$isRealPlayerInChunk(chunkPos));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean minions$isRealPlayerInChunk(long chunkPos) {
|
||||
ObjectSet<ServerPlayerEntity> players = ((ChunkTicketManagerAccessor)field_17462).getPlayers(chunkPos);
|
||||
boolean contains = false;
|
||||
if(players != null) {
|
||||
contains = players.stream().anyMatch(player -> {
|
||||
if (player instanceof MinionFakePlayer minion) {
|
||||
return MobSpawningModule.canMinionSpawnMobs(minion);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
return contains;
|
||||
}
|
||||
|
||||
@Inject(method = "updateLevels", at = @At("HEAD"))
|
||||
public void minions$sync(CallbackInfo info) {
|
||||
if (minions$target) {
|
||||
((ChunkTicketManagerAccessor)field_17462).getMinionless().updateLevels();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void minions$updateLevel(long chunkPos, int distance, boolean decrease, CallbackInfo info) {
|
||||
if (minions$target && (distance == Integer.MAX_VALUE || minions$isRealPlayerInChunk(chunkPos))) {
|
||||
((ChunkTicketManagerAccessor)field_17462).getMinionless().updateLevel(chunkPos, distance, decrease);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void minions$markAsMinionless() {
|
||||
minions$minionless = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void minions$markAsTarget() {
|
||||
minions$target = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int minions$getTickedChunkCount() {
|
||||
return distanceFromNearestPlayer.size();
|
||||
}
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
package io.github.skippyall.minions.mixins.antimobcap;
|
||||
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import io.github.skippyall.minions.mixinhelper.ChunkTicketManager$DistanceFromNearestPlayerTrackerAccessor;
|
||||
import io.github.skippyall.minions.mixinhelper.ChunkTicketManagerAccessor;
|
||||
import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectSet;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.server.world.ChunkTicketManager;
|
||||
import net.minecraft.util.math.ChunkSectionPos;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
@Mixin(ChunkTicketManager.class)
|
||||
public class ChunkTicketManagerMixin implements ChunkTicketManagerAccessor {
|
||||
@Shadow @Final private Long2ObjectMap<ObjectSet<ServerPlayerEntity>> playersByChunkPos;
|
||||
@Shadow @Final private ChunkTicketManager.DistanceFromNearestPlayerTracker distanceFromNearestPlayerTracker;
|
||||
ChunkTicketManager.DistanceFromNearestPlayerTracker minionless;
|
||||
|
||||
@Inject(method = "<init>", at = @At("RETURN"))
|
||||
public void createMinionlessClone(Executor workerExecutor, Executor mainThreadExecutor, CallbackInfo ci) {
|
||||
ChunkTicketManager manager = ((ChunkTicketManager)(Object)this);
|
||||
minionless = manager.new DistanceFromNearestPlayerTracker(8);
|
||||
((ChunkTicketManager$DistanceFromNearestPlayerTrackerAccessor)minionless).minions$markAsMinionless();
|
||||
((ChunkTicketManager$DistanceFromNearestPlayerTrackerAccessor)distanceFromNearestPlayerTracker).minions$markAsTarget();
|
||||
}
|
||||
|
||||
public ObjectSet<ServerPlayerEntity> getPlayers(long chunkpos) {
|
||||
return playersByChunkPos.get(chunkpos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChunkTicketManager.DistanceFromNearestPlayerTracker getMinionless() {
|
||||
return minionless;
|
||||
}
|
||||
|
||||
@Inject(method = "handleChunkLeave", at = @At(value = "INVOKE", target = "Lit/unimi/dsi/fastutil/objects/ObjectSet;remove(Ljava/lang/Object;)Z", shift = At.Shift.AFTER, remap = false))
|
||||
public void minion$updateMinionlessIfNoMinionInChunk(ChunkSectionPos pos, ServerPlayerEntity player, CallbackInfo ci, @Local long chunk) {
|
||||
if (!((ChunkTicketManager$DistanceFromNearestPlayerTrackerAccessor)minionless).minions$isRealPlayerInChunk(chunk)) {
|
||||
minionless.updateLevel(chunk, Integer.MAX_VALUE, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package io.github.skippyall.minions.mixins.antimobcap;
|
||||
|
||||
import net.minecraft.server.world.ChunkTicketManager;
|
||||
import net.minecraft.server.world.ServerChunkManager;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
@Mixin(ServerChunkManager.class)
|
||||
public interface ServerChunkManagerAccessor {
|
||||
@Accessor
|
||||
ChunkTicketManager getTicketManager();
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
package io.github.skippyall.minions.mixins.antimobcap;
|
||||
|
||||
import io.github.skippyall.minions.mixinhelper.ChunkTicketManager$DistanceFromNearestPlayerTrackerAccessor;
|
||||
import io.github.skippyall.minions.mixinhelper.ChunkTicketManagerAccessor;
|
||||
import net.minecraft.server.world.ChunkTicketManager;
|
||||
import net.minecraft.server.world.ServerChunkManager;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyArg;
|
||||
|
||||
@Mixin(ServerChunkManager.class)
|
||||
public class ServerChunkManagerMixin {
|
||||
@Shadow
|
||||
@Final
|
||||
private ChunkTicketManager ticketManager;
|
||||
|
||||
@ModifyArg(method = "tickChunks(Lnet/minecraft/util/profiler/Profiler;JLjava/util/List;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/SpawnHelper;setupSpawn(ILjava/lang/Iterable;Lnet/minecraft/world/SpawnHelper$ChunkSource;Lnet/minecraft/world/SpawnDensityCapper;)Lnet/minecraft/world/SpawnHelper$Info;"))
|
||||
public int useMinionless(int spawningChunkCount) {
|
||||
return ((ChunkTicketManager$DistanceFromNearestPlayerTrackerAccessor)((ChunkTicketManagerAccessor)ticketManager).getMinionless()).minions$getTickedChunkCount();
|
||||
}
|
||||
}
|
||||
@@ -2,9 +2,10 @@ package io.github.skippyall.minions.module;
|
||||
|
||||
import eu.pb4.sgui.api.elements.GuiElementBuilder;
|
||||
import eu.pb4.sgui.api.gui.SimpleGui;
|
||||
import io.github.skippyall.minions.command.CommandExecutor;
|
||||
import io.github.skippyall.minions.fakeplayer.EntityPlayerActionPack;
|
||||
import io.github.skippyall.minions.fakeplayer.MinionFakePlayer;
|
||||
import io.github.skippyall.minions.module.command.CommandExecutor;
|
||||
import io.github.skippyall.minions.input.TextInput;
|
||||
import io.github.skippyall.minions.minion.fakeplayer.EntityPlayerActionPack;
|
||||
import io.github.skippyall.minions.minion.fakeplayer.MinionFakePlayer;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.screen.ScreenHandlerType;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
@@ -15,8 +16,19 @@ public class ActionModules {
|
||||
minion.getMinionActionPack().start(actionType, EntityPlayerActionPack.Action.once());
|
||||
}
|
||||
|
||||
public static void intervalExecutor(EntityPlayerActionPack.ActionType actionType, ServerPlayerEntity player, MinionFakePlayer minion) {
|
||||
minion.getMinionActionPack().start(actionType, EntityPlayerActionPack.Action.interval());
|
||||
public static void executeContinuous(EntityPlayerActionPack.ActionType actionType, ServerPlayerEntity player, MinionFakePlayer minion) {
|
||||
minion.getMinionActionPack().start(actionType, EntityPlayerActionPack.Action.continuous());
|
||||
}
|
||||
|
||||
public static void executeInterval(EntityPlayerActionPack.ActionType actionType, ServerPlayerEntity player, MinionFakePlayer minion) {
|
||||
TextInput.inputFloat(player, Text.translatable("minions.command.action.interval.enter"), "3.5").thenAccept(interval -> {
|
||||
int ticks = Math.round(interval * 20);
|
||||
minion.getMinionActionPack().start(actionType, EntityPlayerActionPack.Action.interval(ticks));
|
||||
});
|
||||
}
|
||||
|
||||
public static void executeStop(EntityPlayerActionPack.ActionType actionType, ServerPlayerEntity player, MinionFakePlayer minion) {
|
||||
minion.getMinionActionPack().stop(actionType);
|
||||
}
|
||||
|
||||
public static CommandExecutor detailSelectionExecutor(EntityPlayerActionPack.ActionType actionType, Text actionName) {
|
||||
@@ -29,6 +41,22 @@ public class ActionModules {
|
||||
.setName(Text.translatable("minions.command.action.once", actionName))
|
||||
.setCallback(() -> executeOnce(actionType, player, minion))
|
||||
);
|
||||
gui.setSlot(3, new GuiElementBuilder()
|
||||
.setItem(Items.REPEATING_COMMAND_BLOCK)
|
||||
.setName(Text.translatable("minions.command.action.continuous", actionName))
|
||||
.setCallback(() -> executeContinuous(actionType, player, minion))
|
||||
);
|
||||
gui.setSlot(5, new GuiElementBuilder()
|
||||
.setItem(Items.CHAIN_COMMAND_BLOCK)
|
||||
.setName(Text.translatable("minions.command.action.interval", actionName))
|
||||
.setCallback(() -> executeInterval(actionType, player, minion))
|
||||
);
|
||||
gui.setSlot(4, new GuiElementBuilder()
|
||||
.setItem(Items.BARRIER)
|
||||
.setName(Text.translatable("minions.command.action.stop", actionName))
|
||||
.setCallback(() -> executeStop(actionType, player, minion))
|
||||
);
|
||||
gui.open();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package io.github.skippyall.minions.module;
|
||||
|
||||
import io.github.skippyall.minions.Minions;
|
||||
import io.github.skippyall.minions.module.command.SimpleCommand;
|
||||
import io.github.skippyall.minions.minion.fakeplayer.EntityPlayerActionPack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static io.github.skippyall.minions.module.Modules.register;
|
||||
|
||||
public class AttackModule {
|
||||
public static final SimpleCommand ATTACK_COMMAND = new SimpleCommand(
|
||||
Text.translatable("minions.command.attack.name"),
|
||||
Text.translatable("minions.command.attack.description"),
|
||||
Items.DIAMOND_PICKAXE,
|
||||
ActionModules.detailSelectionExecutor(EntityPlayerActionPack.ActionType.ATTACK, Text.translatable("minions.command.attack.name"))
|
||||
);
|
||||
|
||||
public static final SimpleModuleItem ATTACK_MODULE = register(
|
||||
Identifier.of(Minions.MOD_ID, "attack_module"),
|
||||
List.of(),
|
||||
List.of(ATTACK_COMMAND),
|
||||
Items.DIAMOND_PICKAXE
|
||||
);
|
||||
|
||||
public static void registerMe() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package io.github.skippyall.minions.module;
|
||||
|
||||
import io.github.skippyall.minions.Minions;
|
||||
import io.github.skippyall.minions.command.SimpleCommand;
|
||||
import io.github.skippyall.minions.module.command.SimpleCommand;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Identifier;
|
||||
@@ -13,10 +13,10 @@ import static io.github.skippyall.minions.module.Modules.register;
|
||||
|
||||
public class ChatModule {
|
||||
public static final SimpleModuleItem CHAT_MODULE = register(Identifier.of(Minions.MOD_ID, "chat_module"),
|
||||
new SimpleModuleItem(new ArrayList<>(), Arrays.asList(
|
||||
new ArrayList<>(), Arrays.asList(
|
||||
new SimpleCommand(Text.of("Message"), Text.of("Send Message in Public Chat"), Items.PAPER, (player, minion) -> minion.getServer().getPlayerManager().broadcast(Text.of("message"), true)),
|
||||
new SimpleCommand(Text.of("Prvt-Message"), Text.of("Send Message to one Person"), Items.TRIAL_KEY, (player, minion) -> {})
|
||||
), Items.PAPER));
|
||||
), Items.PAPER);
|
||||
|
||||
public static void registerMe() {}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package io.github.skippyall.minions.module;
|
||||
|
||||
import io.github.skippyall.minions.Minions;
|
||||
import io.github.skippyall.minions.module.command.SimpleCommand;
|
||||
import io.github.skippyall.minions.minion.fakeplayer.EntityPlayerActionPack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static io.github.skippyall.minions.module.Modules.register;
|
||||
|
||||
public class InteractModule {
|
||||
public static final SimpleCommand INTERACT_COMMAND = new SimpleCommand(
|
||||
Text.translatable("minions.command.interact.name"),
|
||||
Text.translatable("minions.command.interact.description"),
|
||||
Items.LEVER,
|
||||
ActionModules.detailSelectionExecutor(EntityPlayerActionPack.ActionType.USE, Text.translatable("minions.command.interact.name"))
|
||||
);
|
||||
|
||||
public static final SimpleModuleItem INTERACT_MODULE = register(
|
||||
Identifier.of(Minions.MOD_ID, "interact_module"),
|
||||
List.of(),
|
||||
List.of(INTERACT_COMMAND),
|
||||
Items.LEVER
|
||||
);
|
||||
|
||||
public static void registerMe() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package io.github.skippyall.minions.module;
|
||||
|
||||
import io.github.skippyall.minions.Minions;
|
||||
import io.github.skippyall.minions.fakeplayer.MinionFakePlayer;
|
||||
import io.github.skippyall.minions.minion.fakeplayer.MinionFakePlayer;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
@@ -10,7 +10,13 @@ import java.util.List;
|
||||
import static io.github.skippyall.minions.module.Modules.register;
|
||||
|
||||
public class MobSpawningModule {
|
||||
public static final SimpleModuleItem MOB_SPAWNING_MODULE = register(Identifier.of(Minions.MOD_ID, "mob_spawning_module"), new SimpleModuleItem(List.of(), List.of(), Items.SPAWNER));
|
||||
public static final SimpleModuleItem MOB_SPAWNING_MODULE =
|
||||
register(
|
||||
Identifier.of(Minions.MOD_ID, "mob_spawning_module"),
|
||||
List.of(),
|
||||
List.of(),
|
||||
Items.SPAWNER
|
||||
);
|
||||
|
||||
public static boolean canMinionSpawnMobs(MinionFakePlayer minion) {
|
||||
return minion.getModuleInventory().hasModule(MOB_SPAWNING_MODULE);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package io.github.skippyall.minions.module;
|
||||
|
||||
import io.github.skippyall.minions.command.Command;
|
||||
import io.github.skippyall.minions.module.command.Command;
|
||||
import io.github.skippyall.minions.program.block.CodeBlock;
|
||||
import net.minecraft.item.ItemConvertible;
|
||||
|
||||
|
||||
@@ -1,19 +1,31 @@
|
||||
package io.github.skippyall.minions.module;
|
||||
|
||||
import io.github.skippyall.minions.module.command.Command;
|
||||
import io.github.skippyall.minions.program.block.CodeBlock;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.registry.Registries;
|
||||
import net.minecraft.registry.Registry;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Modules {
|
||||
public static void register() {
|
||||
ChatModule.registerMe();
|
||||
MountModule.registerMe();
|
||||
MoveModule.registerMe();
|
||||
MobSpawningModule.registerMe();
|
||||
InteractModule.registerMe();
|
||||
AttackModule.registerMe();
|
||||
}
|
||||
|
||||
public static <T extends Item & ModuleItem> T register(Identifier id, T item) {
|
||||
return Registry.register(Registries.ITEM, id, item);
|
||||
}
|
||||
|
||||
public static SimpleModuleItem register(Identifier id, List<CodeBlock<?,?>> codeBlocks, List<Command> commands, Item vanillaItem) {
|
||||
return Registry.register(Registries.ITEM, id, new SimpleModuleItem(codeBlocks, commands, new Item.Settings().registryKey(RegistryKey.of(RegistryKeys.ITEM, id)), vanillaItem));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,24 +1,41 @@
|
||||
package io.github.skippyall.minions.module;
|
||||
|
||||
import io.github.skippyall.minions.Minions;
|
||||
import io.github.skippyall.minions.command.SimpleCommand;
|
||||
import io.github.skippyall.minions.module.command.SimpleCommand;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static io.github.skippyall.minions.module.Modules.register;
|
||||
|
||||
public class MountModule {
|
||||
public static final SimpleModuleItem MOUNT_MODULE = register(Identifier.of(Minions.MOD_ID, "mount_module"),
|
||||
new SimpleModuleItem(new ArrayList<>(), Arrays.asList(
|
||||
new SimpleCommand(Text.of("Mount"), Text.of("Mount the minion to the nearest mountable Entity"), Items.MINECART, (player, minion) -> minion.getMinionActionPack().mount(true)),
|
||||
new SimpleCommand(Text.of("Dismount"), Text.of("Dismount the minion"), Items.BARRIER, (player, minion) -> minion.getMinionActionPack().dismount())
|
||||
), Items.MINECART)
|
||||
public static final SimpleCommand MOUNT_COMMAND = new SimpleCommand(
|
||||
Text.of("Mount"),
|
||||
Text.of("Mount the minion to the nearest mountable Entity"),
|
||||
Items.MINECART,
|
||||
(player, minion) -> minion.getMinionActionPack().mount(true)
|
||||
);
|
||||
|
||||
public static void registerMe() {}
|
||||
public static final SimpleCommand DISMOUNT_COMMAND = new SimpleCommand(
|
||||
Text.of("Dismount"),
|
||||
Text.of("Dismount the minion"),
|
||||
Items.BARRIER,
|
||||
(player, minion) -> minion.getMinionActionPack().dismount()
|
||||
);
|
||||
|
||||
public static final SimpleModuleItem MOUNT_MODULE =
|
||||
register(Identifier.of(Minions.MOD_ID, "mount_module"),
|
||||
List.of(),
|
||||
List.of(
|
||||
MOUNT_COMMAND,
|
||||
DISMOUNT_COMMAND
|
||||
),
|
||||
Items.MINECART
|
||||
);
|
||||
|
||||
public static void registerMe() {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package io.github.skippyall.minions.module;
|
||||
|
||||
import io.github.skippyall.minions.Minions;
|
||||
import io.github.skippyall.minions.command.SimpleCommand;
|
||||
import io.github.skippyall.minions.module.command.SimpleCommand;
|
||||
import io.github.skippyall.minions.input.TextInput;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.text.Text;
|
||||
@@ -12,43 +12,65 @@ import java.util.List;
|
||||
import static io.github.skippyall.minions.module.Modules.register;
|
||||
|
||||
public class MoveModule {
|
||||
public static final SimpleCommand WALK_COMMAND = new SimpleCommand(Text.literal("Walk"), Text.literal("Walk a specific amount of blocks forward"), Items.IRON_BOOTS, (player, minion) -> {
|
||||
TextInput.inputText(player, Text.literal("Amount of Blocks"), "1")
|
||||
.thenAccept(string -> {
|
||||
try {
|
||||
float blocks = Float.parseFloat(string);
|
||||
minion.moveForward(blocks);
|
||||
} catch (NumberFormatException e) {
|
||||
player.sendMessage(Text.literal("No valid number"));
|
||||
}
|
||||
});
|
||||
});
|
||||
public static final SimpleCommand WALK_COMMAND =
|
||||
new SimpleCommand(
|
||||
Text.literal("Walk"),
|
||||
Text.literal("Walk a specific amount of blocks forward"),
|
||||
Items.IRON_BOOTS,
|
||||
(player, minion) -> TextInput.inputFloat(player, Text.literal("Amount of Blocks"), "1")
|
||||
.thenAccept(minion::moveForward)
|
||||
);
|
||||
|
||||
public static final SimpleCommand TURN_RIGHT_COMMAND = new SimpleCommand(Text.literal("Turn Right"), Text.literal("Turn a specific amount of degrees right"), Items.COMPASS, ((player, minion) -> {
|
||||
TextInput.inputText(player, Text.literal("Degrees"), "90")
|
||||
.thenAccept(string -> {
|
||||
try {
|
||||
float degrees = Float.parseFloat(string);
|
||||
minion.getMinionActionPack().turn(degrees, 0);
|
||||
} catch (NumberFormatException e) {
|
||||
player.sendMessage(Text.literal("No valid number"));
|
||||
}
|
||||
});
|
||||
}));
|
||||
public static final SimpleCommand TURN_RIGHT_COMMAND =
|
||||
new SimpleCommand(
|
||||
Text.literal("Turn Right"),
|
||||
Text.literal("Turn a specific amount of degrees right"),
|
||||
Items.COMPASS,
|
||||
(player, minion) -> TextInput.inputFloat(player, Text.literal("Degrees"), "90")
|
||||
.thenAccept(degrees -> minion.getMinionActionPack().turn(degrees, 0))
|
||||
);
|
||||
|
||||
public static final SimpleCommand TURN_LEFT_COMMAND = new SimpleCommand(Text.literal("Turn Left"), Text.literal("Turn a specific amount of degrees left"), Items.COMPASS, ((player, minion) -> {
|
||||
TextInput.inputText(player, Text.literal("Degrees"), "90")
|
||||
.thenAccept(string -> {
|
||||
try {
|
||||
float degrees = Float.parseFloat(string);
|
||||
minion.getMinionActionPack().turn(-degrees, 0);
|
||||
} catch (NumberFormatException e) {
|
||||
player.sendMessage(Text.literal("No valid number"));
|
||||
}
|
||||
});
|
||||
}));
|
||||
public static final SimpleCommand TURN_LEFT_COMMAND =
|
||||
new SimpleCommand(
|
||||
Text.literal("Turn Left"),
|
||||
Text.literal("Turn a specific amount of degrees left"),
|
||||
Items.COMPASS,
|
||||
(player, minion) -> TextInput.inputFloat(player, Text.literal("Degrees"), "90")
|
||||
.thenAccept(degrees -> minion.getMinionActionPack().turn(-degrees, 0))
|
||||
);
|
||||
|
||||
public static final SimpleModuleItem MOVE_MODULE = register(Identifier.of(Minions.MOD_ID, "move_module"), new SimpleModuleItem(List.of(), List.of(WALK_COMMAND, TURN_RIGHT_COMMAND, TURN_LEFT_COMMAND), Items.IRON_BOOTS));
|
||||
public static final SimpleCommand TURN_UP_COMMAND =
|
||||
new SimpleCommand(
|
||||
Text.literal("Turn Up"),
|
||||
Text.literal("Turn a specific amount of degrees up"),
|
||||
Items.COMPASS,
|
||||
(player, minion) -> TextInput.inputFloat(player, Text.literal("Degrees"), "90")
|
||||
.thenAccept(degrees -> minion.getMinionActionPack().turn(0, -degrees))
|
||||
);
|
||||
|
||||
public static final SimpleCommand TURN_DOWN_COMMAND =
|
||||
new SimpleCommand(
|
||||
Text.literal("Turn Down"),
|
||||
Text.literal("Turn a specific amount of degrees down"),
|
||||
Items.COMPASS,
|
||||
(player, minion) -> TextInput.inputFloat(player, Text.literal("Degrees"), "90")
|
||||
.thenAccept(degrees -> minion.getMinionActionPack().turn(0, degrees))
|
||||
);
|
||||
|
||||
|
||||
|
||||
public static final SimpleModuleItem MOVE_MODULE =
|
||||
register(Identifier.of(Minions.MOD_ID, "move_module"),
|
||||
List.of(),
|
||||
List.of(
|
||||
WALK_COMMAND,
|
||||
TURN_RIGHT_COMMAND,
|
||||
TURN_LEFT_COMMAND,
|
||||
TURN_UP_COMMAND,
|
||||
TURN_DOWN_COMMAND
|
||||
),
|
||||
Items.IRON_BOOTS
|
||||
);
|
||||
|
||||
public static void registerMe() {}
|
||||
}
|
||||
|
||||
@@ -1,25 +1,20 @@
|
||||
package io.github.skippyall.minions.module;
|
||||
|
||||
import eu.pb4.polymer.core.api.item.PolymerItem;
|
||||
import io.github.skippyall.minions.command.Command;
|
||||
import eu.pb4.polymer.core.api.item.SimplePolymerItem;
|
||||
import io.github.skippyall.minions.module.command.Command;
|
||||
import io.github.skippyall.minions.program.block.CodeBlock;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SimpleModuleItem extends Item implements PolymerItem, ModuleItem {
|
||||
public class SimpleModuleItem extends SimplePolymerItem implements ModuleItem {
|
||||
private final List<CodeBlock<?,?>> codeBlocks;
|
||||
private final List<Command> commands;
|
||||
private final Item vanillaItem;
|
||||
|
||||
public SimpleModuleItem(List<CodeBlock<?,?>> codeBlocks, List<Command> commands, Item vanillaItem) {
|
||||
super(new Item.Settings().maxCount(1));
|
||||
public SimpleModuleItem(List<CodeBlock<?,?>> codeBlocks, List<Command> commands, Settings settings, Item vanillaItem) {
|
||||
super(settings.maxCount(1), vanillaItem);
|
||||
this.codeBlocks = codeBlocks;
|
||||
this.commands = commands;
|
||||
this.vanillaItem = vanillaItem;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -31,9 +26,4 @@ public class SimpleModuleItem extends Item implements PolymerItem, ModuleItem {
|
||||
public List<Command> getCommands() {
|
||||
return commands;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getPolymerItem(ItemStack itemStack, @Nullable ServerPlayerEntity player) {
|
||||
return vanillaItem;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package io.github.skippyall.minions.command;
|
||||
package io.github.skippyall.minions.module.command;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.text.Text;
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package io.github.skippyall.minions.command;
|
||||
package io.github.skippyall.minions.module.command;
|
||||
|
||||
import io.github.skippyall.minions.fakeplayer.MinionFakePlayer;
|
||||
import io.github.skippyall.minions.minion.fakeplayer.MinionFakePlayer;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
|
||||
public interface CommandExecutor {
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package io.github.skippyall.minions.command;
|
||||
package io.github.skippyall.minions.module.command;
|
||||
|
||||
import io.github.skippyall.minions.fakeplayer.MinionFakePlayer;
|
||||
import io.github.skippyall.minions.minion.fakeplayer.MinionFakePlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.text.Text;
|
||||
@@ -1,40 +0,0 @@
|
||||
package io.github.skippyall.minions.networking;
|
||||
|
||||
import io.github.skippyall.minions.Minions;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.fabric.api.client.networking.v1.ClientConfigurationNetworking;
|
||||
import net.fabricmc.fabric.api.networking.v1.PacketSender;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.network.ClientConfigurationNetworkHandler;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.network.PacketByteBuf;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.network.ServerConfigurationNetworkHandler;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
public class ClientToServerNetworking {
|
||||
/*public static final Identifier RL = Identifier.of(Minions.MOD_ID, "network");
|
||||
@Environment(EnvType.CLIENT)
|
||||
public static void sendJoinPacket(PlayerEntity player) {
|
||||
PacketByteBuf pbf = new PacketByteBuf(Unpooled.buffer());
|
||||
pbf.writeString("BN|Init|V0.1");
|
||||
ClientConfigurationNetworking.send(RL, pbf);
|
||||
}
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public static void onConfigurationInit(ClientConfigurationNetworkHandler handler, MinecraftClient client) {
|
||||
sendJoinPacket(client.player);
|
||||
}
|
||||
|
||||
@Environment(EnvType.SERVER)
|
||||
public static void receive(MinecraftServer server, ServerConfigurationNetworkHandler handler, PacketByteBuf buf, PacketSender responseSender) {
|
||||
String message = buf.readString();
|
||||
if (!message.startsWith("BN|")) {
|
||||
Minions.LOGGER.debug("Message with wrong format: " + message);
|
||||
}
|
||||
String[] parts = message.split("|");
|
||||
|
||||
}*/
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package io.github.skippyall.minions.networking;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
|
||||
public class VersionChecker {
|
||||
protected static List<UUID> hasSupportedMod = new ArrayList<>();
|
||||
public static boolean supportVersion(String version) {
|
||||
return version.equals("v0.1");
|
||||
}
|
||||
|
||||
public static boolean useSupportedMod(PlayerEntity p) {
|
||||
return hasSupportedMod.contains(p.getUuid());
|
||||
}
|
||||
|
||||
public static void resetPlayer(UUID uuid) {
|
||||
hasSupportedMod.remove(uuid);
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
package io.github.skippyall.minions.program.block;
|
||||
|
||||
import io.github.skippyall.minions.fakeplayer.EntityPlayerActionPack;
|
||||
import io.github.skippyall.minions.fakeplayer.MinionFakePlayer;
|
||||
import io.github.skippyall.minions.fakeplayer.ServerPlayerInterface;
|
||||
import io.github.skippyall.minions.minion.fakeplayer.EntityPlayerActionPack;
|
||||
import io.github.skippyall.minions.minion.fakeplayer.MinionFakePlayer;
|
||||
import io.github.skippyall.minions.minion.fakeplayer.ServerPlayerInterface;
|
||||
import io.github.skippyall.minions.program.runtime.MinionRuntime;
|
||||
import io.github.skippyall.minions.program.runtime.ProgramRuntime;
|
||||
import io.github.skippyall.minions.program.statement.Statement;
|
||||
@@ -19,7 +19,7 @@ public class GoBlock extends CodeBlock<Void, Tuple2<Float, Float>> {
|
||||
public Void execute(ProgramRuntime runtime, Tuple2<Float, Float> args, Statement<Void, Tuple2<Float, Float>>.Run run) {
|
||||
if(runtime instanceof MinionRuntime minionRuntime) {
|
||||
MinionFakePlayer minion = minionRuntime.getMinion();
|
||||
EntityPlayerActionPack action = ((ServerPlayerInterface) minion).getActionPack();
|
||||
EntityPlayerActionPack action = ((ServerPlayerInterface) minion).minions$getActionPack();
|
||||
minion.moveForward(args.v0());
|
||||
minion.moveSideways(args.v1());
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package io.github.skippyall.minions.program.block;
|
||||
|
||||
import io.github.skippyall.minions.fakeplayer.EntityPlayerActionPack;
|
||||
import io.github.skippyall.minions.fakeplayer.MinionFakePlayer;
|
||||
import io.github.skippyall.minions.minion.fakeplayer.EntityPlayerActionPack;
|
||||
import io.github.skippyall.minions.minion.fakeplayer.MinionFakePlayer;
|
||||
import io.github.skippyall.minions.program.runtime.MinionRuntime;
|
||||
import io.github.skippyall.minions.program.runtime.ProgramRuntime;
|
||||
import io.github.skippyall.minions.program.statement.Statement;
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
package io.github.skippyall.minions.program.runtime;
|
||||
|
||||
import io.github.skippyall.minions.fakeplayer.MinionFakePlayer;
|
||||
import net.fabricmc.fabric.api.entity.event.v1.ServerEntityCombatEvents;
|
||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
|
||||
import net.fabricmc.fabric.api.event.player.AttackEntityCallback;
|
||||
import net.fabricmc.fabric.api.message.v1.ServerMessageEvents;
|
||||
import io.github.skippyall.minions.minion.fakeplayer.MinionFakePlayer;
|
||||
|
||||
public class MinionRuntime extends ProgramRuntime {
|
||||
private final MinionFakePlayer minion;
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
package io.github.skippyall.minions.server;
|
||||
|
||||
import io.github.skippyall.minions.networking.ClientToServerNetworking;
|
||||
import io.github.skippyall.minions.networking.VersionChecker;
|
||||
import net.fabricmc.api.DedicatedServerModInitializer;
|
||||
import net.fabricmc.fabric.api.networking.v1.ServerConfigurationConnectionEvents;
|
||||
import net.fabricmc.fabric.api.networking.v1.ServerConfigurationNetworking;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.network.ServerConfigurationNetworkHandler;
|
||||
|
||||
public class MinionsServer implements DedicatedServerModInitializer {
|
||||
@Override
|
||||
public void onInitializeServer() {
|
||||
/*ServerConfigurationNetworking.registerGlobalReceiver(ClientToServerNetworking.RL, ClientToServerNetworking::receive);
|
||||
ServerConfigurationConnectionEvents.CONFIGURE.register(new ServerConfigurationConnectionEvents.Configure() {
|
||||
@Override
|
||||
public void onSendConfiguration(ServerConfigurationNetworkHandler handler, MinecraftServer server) {
|
||||
VersionChecker.resetPlayer(handler.getDebugProfile().getId());
|
||||
}
|
||||
});*/
|
||||
|
||||
}
|
||||
}
|
||||
@@ -7,8 +7,40 @@
|
||||
"minions.gui.module_commands.title": "Commands",
|
||||
"minions.gui.commands.title": "%s's Commands",
|
||||
"minions.gui.modules.title": "%s's Modules",
|
||||
"minions.gui.ok": "OK",
|
||||
"minions.gui.look.skin.name": "Name",
|
||||
"minions.gui.look.skin.name.title": "Enter a player name",
|
||||
"minions.gui.look.skin.uuid": "UUID",
|
||||
"minions.gui.look.skin.uuid.title": "Enter a player UUID",
|
||||
"minions.gui.look.skin.base64": "Base64",
|
||||
"minions.gui.look.skin.base64.title": "Enter a skin in base64 encoding",
|
||||
"minions.gui.look.rename.title": "Enter a name",
|
||||
|
||||
"minions.command.input.int.fail": "Not an integer",
|
||||
"minions.command.input.float.fail": "Not a number",
|
||||
"minions.command.action.details": "Set how to %s",
|
||||
"minions.command.action.once": "%s once",
|
||||
"minions.command.action.continuous": "%s continuously",
|
||||
"minions.command.action.interval": "%s every x seconds"
|
||||
"minions.command.action.interval": "%s every x seconds",
|
||||
"minions.command.action.stop": "Stop %s",
|
||||
"minions.command.action.interval.enter": "Enter an interval in seconds",
|
||||
"minions.command.interact.name": "Interact",
|
||||
"minions.command.interact.description": "Use and place blocks",
|
||||
"minions.command.attack.name": "Attack",
|
||||
"minions.command.attack.description": "Attack and mine blocks",
|
||||
|
||||
"item.minions.attack_module": "Attack Module",
|
||||
"item.minions.interact_module": "Interact Module",
|
||||
"item.minions.mob_spawning_module": "Mob Spawning Module",
|
||||
"item.minions.mount_module": "Mount Module",
|
||||
"item.minions.move_module": "Move Module",
|
||||
"item.minions.minion": "Minion",
|
||||
"item.minions.basic_upgrade_base": "Basic Upgrade Base",
|
||||
"item.minions.advanced_upgrade_base": "Advanced Upgrade Base",
|
||||
|
||||
"minions.minion_item.tooltip": "Name: %s",
|
||||
"minions.generic.name.invalid_char": "Name contains invalid character",
|
||||
"minions.generic.name.too_long": "Name is too long",
|
||||
"minions.generic.name.invalid": "Name is invalid",
|
||||
"minions.generic.name.taken": "This name is already used"
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"type": "minecraft:crafting_shaped",
|
||||
"pattern": [
|
||||
"DND",
|
||||
"NBN",
|
||||
"DND"
|
||||
],
|
||||
"key": {
|
||||
"D": "minecraft:diamond",
|
||||
"N": "minecraft:netherite_scrap",
|
||||
"B": "minions:basic_upgrade_base"
|
||||
},
|
||||
"result": {
|
||||
"id": "minions:advanced_upgrade_base",
|
||||
"count": 1
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"type": "minecraft:smithing_transform",
|
||||
"base": "minions:advanced_upgrade_base",
|
||||
"addition": "minecraft:diamond_pickaxe",
|
||||
"template": "minecraft:netherite_upgrade_smithing_template",
|
||||
"result": {
|
||||
"id": "minions:attack_module"
|
||||
}
|
||||
}
|
||||
+3
-9
@@ -6,15 +6,9 @@
|
||||
"RGR"
|
||||
],
|
||||
"key": {
|
||||
"R": {
|
||||
"item":"minecraft:redstone_block"
|
||||
},
|
||||
"G": {
|
||||
"item": "minecraft:gold_ingot"
|
||||
},
|
||||
"D": {
|
||||
"item": "minecraft:diamond_block"
|
||||
}
|
||||
"R": "minecraft:redstone_block",
|
||||
"G": "minecraft:gold_ingot",
|
||||
"D": "minecraft:diamond"
|
||||
},
|
||||
"result": {
|
||||
"id": "minions:basic_upgrade_base",
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"type": "minecraft:smithing_transform",
|
||||
"base": "minions:advanced_upgrade_base",
|
||||
"addition": "minecraft:lever",
|
||||
"template": "minecraft:netherite_upgrade_smithing_template",
|
||||
"result": {
|
||||
"id": "minions:interact_module"
|
||||
}
|
||||
}
|
||||
@@ -3,21 +3,13 @@
|
||||
"pattern": [
|
||||
" H ",
|
||||
"RAR",
|
||||
" L "
|
||||
" N "
|
||||
],
|
||||
"key": {
|
||||
"H": {
|
||||
"tag": "minecraft:skulls"
|
||||
},
|
||||
"R": {
|
||||
"item": "minecraft:redstone_torch"
|
||||
},
|
||||
"A": {
|
||||
"item": "minecraft:armor_stand"
|
||||
},
|
||||
"L": {
|
||||
"item":"minecraft:lodestone"
|
||||
}
|
||||
"H": "#minecraft:skulls",
|
||||
"R": "minecraft:redstone_torch",
|
||||
"A": "minecraft:armor_stand",
|
||||
"N": "minecraft:netherite_ingot"
|
||||
},
|
||||
"result": {
|
||||
"id": "minions:minion",
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"type": "minecraft:smithing_transform",
|
||||
"base": "minions:basic_upgrade_base",
|
||||
"addition": "minecraft:rotten_flesh",
|
||||
"template": "minecraft:netherite_upgrade_smithing_template",
|
||||
"result": {
|
||||
"id": "minions:mob_spawning_module"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"type": "minecraft:smithing_transform",
|
||||
"base": "minions:basic_upgrade_base",
|
||||
"addition": "minecraft:minecart",
|
||||
"template": "minecraft:netherite_upgrade_smithing_template",
|
||||
"result": {
|
||||
"id": "minions:mount_module"
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
{
|
||||
"type": "minecraft:smithing_transform",
|
||||
"base": {
|
||||
"item": "minions:basic_upgrade_base"
|
||||
},
|
||||
"addition": {
|
||||
"item": "minecraft:minecart"
|
||||
},
|
||||
"template": {
|
||||
"item": "minecraft:netherite_upgrade_smithing_template"
|
||||
},
|
||||
"result": {
|
||||
"id": "minions:mount_module"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"type": "minecraft:smithing_transform",
|
||||
"base": "minions:basic_upgrade_base",
|
||||
"addition": "minecraft:iron_boots",
|
||||
"template": "minecraft:netherite_upgrade_smithing_template",
|
||||
"result": {
|
||||
"id": "minions:move_module"
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
{
|
||||
"type": "minecraft:smithing_transform",
|
||||
"base": {
|
||||
"item": "minions:basic_upgrade_base"
|
||||
},
|
||||
"addition": {
|
||||
"item": "minecraft:iron_boots"
|
||||
},
|
||||
"template": {
|
||||
"item": "minecraft:netherite_upgrade_smithing_template"
|
||||
},
|
||||
"result": {
|
||||
"id": "minions:move_module"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"values": [
|
||||
"#minecraft:is_fire",
|
||||
"#minecraft:is_explosion"
|
||||
]
|
||||
}
|
||||
@@ -12,23 +12,18 @@
|
||||
"icon": "assets/minions/icon.png",
|
||||
"environment": "*",
|
||||
"entrypoints": {
|
||||
"client": [
|
||||
"io.github.skippyall.minions.client.MinionsClient"
|
||||
],
|
||||
"main": [
|
||||
"io.github.skippyall.minions.Minions"
|
||||
],
|
||||
"server": [
|
||||
"io.github.skippyall.minions.server.MinionsServer"
|
||||
]
|
||||
},
|
||||
"mixins": [
|
||||
"minions.mixins.json"
|
||||
],
|
||||
"accessWidener" : "minions.accesswidener",
|
||||
"depends": {
|
||||
"fabricloader": "*",
|
||||
"fabric": "*",
|
||||
"minecraft": "~1.21",
|
||||
"minecraft": "~1.21.3",
|
||||
"polymer-core": "*"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
accessWidener v2 named
|
||||
|
||||
accessible class net/minecraft/server/world/ChunkTicketManager$DistanceFromNearestPlayerTracker
|
||||
accessible method net/minecraft/server/world/ChunkTicketManager$DistanceFromNearestPlayerTracker <init> (Lnet/minecraft/server/world/ChunkTicketManager;I)V
|
||||
@@ -7,6 +7,8 @@
|
||||
"ChunkTicketManagerFixMixin",
|
||||
"ConnectionMixin",
|
||||
"EntityAccessor",
|
||||
"GraveCompatMixin",
|
||||
"EntityViewMixin",
|
||||
"MinecraftServerMixin",
|
||||
"MobEntityMixin",
|
||||
"PlayerListEntryS2CPacket$EntryMixin",
|
||||
@@ -14,7 +16,12 @@
|
||||
"ServerPlayerMixin",
|
||||
"ServerPlayNetworkHandlerMixin",
|
||||
"SleepManagerMixin",
|
||||
"SpawnHelperMixin"
|
||||
"SpawnHelperMixin",
|
||||
"antimobcap.ChunkPosDistanceLevelPropagatorMixin",
|
||||
"antimobcap.ChunkTicketManager$DistanceFromNearestPlayerTrackerMixin",
|
||||
"antimobcap.ChunkTicketManagerMixin",
|
||||
"antimobcap.ServerChunkManagerAccessor",
|
||||
"antimobcap.ServerChunkManagerMixin"
|
||||
],
|
||||
"client": [],
|
||||
"server": [],
|
||||
|
||||
Reference in New Issue
Block a user