From e4a966e7af3f41c01b0dd7774241c22ac73f666c Mon Sep 17 00:00:00 2001 From: Matt Worzala Date: Tue, 26 Jan 2021 08:47:15 -0500 Subject: [PATCH] remove cube batch command --- .gitignore | 1 + src/test/java/demo/Main.java | 1 - .../java/demo/commands/CubeBatchCommand.java | 191 ------------------ 3 files changed, 1 insertion(+), 192 deletions(-) delete mode 100644 src/test/java/demo/commands/CubeBatchCommand.java diff --git a/.gitignore b/.gitignore index f7e4a1cff..5156401ca 100644 --- a/.gitignore +++ b/.gitignore @@ -53,6 +53,7 @@ gradle-app.setting # When running the demo we generate the extensions folder /extensions/ +/.mixin.out/ # When compiling we get a docs folder /docs diff --git a/src/test/java/demo/Main.java b/src/test/java/demo/Main.java index a1654b210..c49111ed3 100644 --- a/src/test/java/demo/Main.java +++ b/src/test/java/demo/Main.java @@ -41,7 +41,6 @@ public class Main { commandManager.register(new PlayersCommand()); commandManager.register(new PotionCommand()); commandManager.register(new TitleCommand()); - commandManager.register(new CubeBatchCommand()); commandManager.register(new BookCommand()); commandManager.register(new ShootCommand()); commandManager.register(new HorseCommand()); diff --git a/src/test/java/demo/commands/CubeBatchCommand.java b/src/test/java/demo/commands/CubeBatchCommand.java deleted file mode 100644 index d1e9b272d..000000000 --- a/src/test/java/demo/commands/CubeBatchCommand.java +++ /dev/null @@ -1,191 +0,0 @@ -package demo.commands; - -import net.minestom.server.MinecraftServer; -import net.minestom.server.command.CommandSender; -import net.minestom.server.command.builder.Arguments; -import net.minestom.server.command.builder.Command; -import net.minestom.server.command.builder.arguments.Argument; -import net.minestom.server.command.builder.arguments.ArgumentType; -import net.minestom.server.entity.Player; -import net.minestom.server.instance.InstanceContainer; -import net.minestom.server.instance.batch.AbsoluteBlockBatch; -import net.minestom.server.instance.batch.BatchOption; -import net.minestom.server.instance.batch.ChunkBatch; -import net.minestom.server.instance.batch.RelativeBlockBatch; -import net.minestom.server.instance.block.Block; -import net.minestom.server.utils.time.TimeUnit; - -import java.util.concurrent.ThreadLocalRandom; - -public class CubeBatchCommand extends Command { - - public CubeBatchCommand() { - super("cube"); - - Argument subcommand = ArgumentType.Word("sub").from("create", "undo"); - - setDefaultExecutor(this::execute); - - addSyntax(this::handleSubcommand, subcommand); - } - - private void execute(CommandSender sender, Arguments args) { - if (!sender.isPlayer()) { - sender.sendMessage("This command may only be run by players."); - return; - } - Player player = sender.asPlayer(); - InstanceContainer instance = (InstanceContainer) player.getInstance(); - - applyChunkShape(instance); -// applyBlockShape(instance); - -// AbsoluteBlockBatch batch = new AbsoluteBlockBatch(); -// -// int offset = 50; -// for (int x = 0; x < 50; x += 2) { -// for (int y = 0; y < 50; y += 2) { -// for (int z = 0; z < 50; z += 2) { -// batch.setBlockStateId(x + offset, y + offset, z + offset, Block.STONE.getBlockId()); -// } -// } -// } - -// RelativeBlockBatch batch = new RelativeBlockBatch(); -// for (int x = 0; x < 50; x += 2) { -// for (int y = 0; y < 50; y += 2) { -// for (int z = 0; z < 50; z += 2) { -// batch.setBlockStateId(x, y, z, Block.STONE.getBlockId()); -// } -// } -// } -// batch.apply(instance, 0, 50, 0, () -> sender.sendMessage(ColoredText.of(ChatColor.BRIGHT_GREEN, "Created cube."))); - - - } - - private volatile ChunkBatch inverse = null; - private volatile AbsoluteBlockBatch absInverse = null; - - private void handleSubcommand(CommandSender sender, Arguments args) { - if (!sender.isPlayer()) { - sender.sendMessage("This command may only be run by players."); - return; - } - Player player = sender.asPlayer(); - InstanceContainer instance = (InstanceContainer) player.getInstance(); - - String sub = args.getWord("sub"); - if (sub.equalsIgnoreCase("create")) { - final ChunkBatch batch = new ChunkBatch(new BatchOption().setCalculateInverse(true)); - for (int x = 0; x < 16; x += 2) { - for (int y = 0; y < 50; y += 2) { - for (int z = 0; z < 16; z += 2) { - batch.setBlockStateId(x, y + 50, z, Block.STONE.getBlockId()); - } - } - } - inverse = batch.apply(instance, 1, 1, c -> sender.sendMessage("Applied batch")); - - final AbsoluteBlockBatch absBatch = new AbsoluteBlockBatch(new BatchOption().setCalculateInverse(true)); - for (int x = 0; x < 50; x += 2) { - for (int y = 0; y < 50; y += 2) { - for (int z = 0; z < 50; z += 2) { - absBatch.setBlockStateId(x - 100, y + 50, z + 50, Block.STONE.getBlockId()); - } - } - } - absInverse = absBatch.apply(instance, () -> sender.sendMessage("Applied batch 2")); - } else if (sub.equalsIgnoreCase("undo")) { - final ChunkBatch inv = inverse; - if (inv == null) { - sender.sendMessage("No inverse set."); - return; - } - - inv.apply(instance, 1, 1, c -> sender.sendMessage("Applied inverse")); - absInverse.apply(instance, () -> sender.sendMessage("Applied inverse 2")); - } else sender.sendMessage("Unknown subcommand '" + sub + "'"); - } - - private void applyBlockShape(InstanceContainer instance) { - for (int i = 0; i < 5; i++) { - AbsoluteBlockBatch batch = new AbsoluteBlockBatch(); - for (int x = -100; x < 101; x++) { - for (int z = -100; z < 101; z++) { - batch.setBlockStateId(x, 50, z, (short) (Block.BLUE_CONCRETE.getBlockId() + i)); - } - } - MinecraftServer.getSchedulerManager().buildTask(() -> { - batch.apply(instance, null); - }).delay(i * 3, TimeUnit.TICK).repeat(15, TimeUnit.TICK).schedule(); - } - - - // Bad -// for (int i = 0; i < 5; i++) { -// RelativeBlockBatch batch = makeBatch((short) (Block.BLUE_CONCRETE.getBlockId() + i)); -// MinecraftServer.getSchedulerManager().buildTask(() -> { -// batch.apply(instance, -// ThreadLocalRandom.current().nextInt(100) - 100, -// 50, -// ThreadLocalRandom.current().nextInt(100) - 100, -// null); -// }).delay(10, TimeUnit.TICK).repeat(1, TimeUnit.TICK).schedule(); -// } - - -// for (int i = 0; i < 5; i++) { -// RelativeBlockBatch batch = makeBatch((short) 0); -// MinecraftServer.getSchedulerManager().buildTask(() -> { -// batch.apply(instance, -// ThreadLocalRandom.current().nextInt(50) - 50, -// ThreadLocalRandom.current().nextInt(50) + 50, -// ThreadLocalRandom.current().nextInt(50) - 50, -// null); -// }).delay(10, TimeUnit.TICK).repeat(1, TimeUnit.TICK).schedule(); -// } -// for (int i = 0; i < 5; i++) { -// RelativeBlockBatch batch = makeBatch((short) (Block.STONE.getBlockId() + i)); -// MinecraftServer.getSchedulerManager().buildTask(() -> { -// batch.apply(instance, -// ThreadLocalRandom.current().nextInt(50) - 50, -// ThreadLocalRandom.current().nextInt(50) + 50, -// ThreadLocalRandom.current().nextInt(50) - 50, -// null); -// }).delay(10, TimeUnit.TICK).repeat(1, TimeUnit.TICK).schedule(); -// } - } - - private RelativeBlockBatch makeBatch(short block) { - final RelativeBlockBatch batch = new RelativeBlockBatch(); - for (int x = 0; x < 100; x += 2) { -// for (int y = 0; y < 50; y += 2) { - for (int z = 0; z < 100; z += 2) { - batch.setBlockStateId(x, 0, z, block); - } -// } - } - return batch; - } - - private void applyChunkShape(InstanceContainer instance) { - for (int i = 0; i < 20; i++) { - final ChunkBatch relBatch = new ChunkBatch(); - - for (int x = 0; x < 16; x += 2) { - for (int y = 0; y < 50; y += 2) { - for (int z = 0; z < 16; z += 2) { - relBatch.setBlockStateId(x, y + 50, z, (short) i); - } - } - } - MinecraftServer.getSchedulerManager().buildTask(() -> { - relBatch.apply(instance, - ThreadLocalRandom.current().nextInt(10) - 5, - ThreadLocalRandom.current().nextInt(10) - 5, - null); - }).delay(10, TimeUnit.TICK).repeat(1, TimeUnit.TICK).schedule(); - } - } -}