e
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
package io.github.skippyall.minions.module;
|
||||
|
||||
import io.github.skippyall.minions.Minions;
|
||||
import io.github.skippyall.minions.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 ChatModule {
|
||||
public static final SimpleModuleItem CHAT_MODULE = register(Identifier.of(Minions.MOD_ID, "chat_module"),
|
||||
new SimpleModuleItem(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));
|
||||
|
||||
public static void registerMe() {}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package io.github.skippyall.minions.module;
|
||||
|
||||
import io.github.skippyall.minions.fakeplayer.MinionFakePlayer;
|
||||
|
||||
public class MobSpawningModule {
|
||||
|
||||
|
||||
public static boolean canMinionSpawnMobs(MinionFakePlayer minion) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean canMinionDespawnMobs(MinionFakePlayer minion) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package io.github.skippyall.minions.module;
|
||||
|
||||
import io.github.skippyall.minions.command.Command;
|
||||
import io.github.skippyall.minions.program.block.CodeBlock;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ModuleItem {
|
||||
|
||||
List<CodeBlock<?,?>> getCodeBlocks();
|
||||
|
||||
List<Command> getCommands();
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package io.github.skippyall.minions.module;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.registry.Registries;
|
||||
import net.minecraft.registry.Registry;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
public class Modules {
|
||||
MoveModule MOVE = new MoveModule();
|
||||
|
||||
public static void register() {
|
||||
ChatModule.registerMe();
|
||||
MountModule.registerMe();
|
||||
MoveModule.registerMe();
|
||||
}
|
||||
|
||||
public static <T extends Item & ModuleItem> T register(Identifier id, T item) {
|
||||
return Registry.register(Registries.ITEM, id, item);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package io.github.skippyall.minions.module;
|
||||
|
||||
import io.github.skippyall.minions.Minions;
|
||||
import io.github.skippyall.minions.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 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 void registerMe() {}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package io.github.skippyall.minions.module;
|
||||
|
||||
import io.github.skippyall.minions.Minions;
|
||||
import io.github.skippyall.minions.command.SimpleCommand;
|
||||
import io.github.skippyall.minions.input.TextInput;
|
||||
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 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 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_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 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 void registerMe() {}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package io.github.skippyall.minions.module;
|
||||
|
||||
import eu.pb4.polymer.core.api.item.PolymerItem;
|
||||
import io.github.skippyall.minions.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 {
|
||||
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));
|
||||
this.codeBlocks = codeBlocks;
|
||||
this.commands = commands;
|
||||
this.vanillaItem = vanillaItem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CodeBlock<?, ?>> getCodeBlocks() {
|
||||
return codeBlocks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Command> getCommands() {
|
||||
return commands;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getPolymerItem(ItemStack itemStack, @Nullable ServerPlayerEntity player) {
|
||||
return vanillaItem;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user