From e31d46c2af87e2c505d764603564125f56ff8f4b Mon Sep 17 00:00:00 2001 From: Adubbz Date: Sun, 5 Jul 2020 22:40:12 +1000 Subject: [PATCH] Removed /bop tpbiome as Vanilla added its own command --- .../common/command/BOPCommand.java | 24 ----- .../common/command/BiomeArgument.java | 57 ---------- .../common/command/CommandTpBiome.java | 101 ------------------ .../biomesoplenty/core/BiomesOPlenty.java | 10 -- 4 files changed, 192 deletions(-) delete mode 100644 src/main/java/biomesoplenty/common/command/BOPCommand.java delete mode 100644 src/main/java/biomesoplenty/common/command/BiomeArgument.java delete mode 100644 src/main/java/biomesoplenty/common/command/CommandTpBiome.java diff --git a/src/main/java/biomesoplenty/common/command/BOPCommand.java b/src/main/java/biomesoplenty/common/command/BOPCommand.java deleted file mode 100644 index d3a7fac5c..000000000 --- a/src/main/java/biomesoplenty/common/command/BOPCommand.java +++ /dev/null @@ -1,24 +0,0 @@ -/******************************************************************************* - * Copyright 2014-2019, the Biomes O' Plenty Team - * - * This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International Public License. - * - * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/. - ******************************************************************************/ -package biomesoplenty.common.command; - -import com.mojang.brigadier.CommandDispatcher; -import com.mojang.brigadier.builder.LiteralArgumentBuilder; -import net.minecraft.command.CommandSource; - -public class BOPCommand -{ - public BOPCommand(CommandDispatcher dispatcher) - { - dispatcher.register( - LiteralArgumentBuilder.literal("bop") - .requires(cs->cs.hasPermission(2)) - .then(CommandTpBiome.register()) - ); - } -} \ No newline at end of file diff --git a/src/main/java/biomesoplenty/common/command/BiomeArgument.java b/src/main/java/biomesoplenty/common/command/BiomeArgument.java deleted file mode 100644 index 3be3cf0ff..000000000 --- a/src/main/java/biomesoplenty/common/command/BiomeArgument.java +++ /dev/null @@ -1,57 +0,0 @@ -/******************************************************************************* - * Copyright 2014-2019, the Biomes O' Plenty Team - * - * This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International Public License. - * - * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/. - ******************************************************************************/ -package biomesoplenty.common.command; - -import com.mojang.brigadier.StringReader; -import com.mojang.brigadier.arguments.ArgumentType; -import com.mojang.brigadier.context.CommandContext; -import com.mojang.brigadier.exceptions.CommandSyntaxException; -import com.mojang.brigadier.exceptions.DynamicCommandExceptionType; -import com.mojang.brigadier.suggestion.Suggestions; -import com.mojang.brigadier.suggestion.SuggestionsBuilder; -import net.minecraft.command.CommandSource; -import net.minecraft.command.ISuggestionProvider; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.registry.Registry; -import net.minecraft.util.text.TranslationTextComponent; -import net.minecraft.world.biome.Biome; - -import java.util.concurrent.CompletableFuture; - -public class BiomeArgument implements ArgumentType -{ - public static final DynamicCommandExceptionType INVALID_BIOME_EXCEPTION = new DynamicCommandExceptionType((biome) -> { - return new TranslationTextComponent("argument.biomesoplenty.biome.invalid", new Object[]{biome}); - }); - - public static BiomeArgument createArgument() - { - return new BiomeArgument(); - } - - public static Biome getValue(CommandContext context, String name) throws CommandSyntaxException - { - return context.getArgument(name, Biome.class); - } - - @Override - public Biome parse(StringReader reader) throws CommandSyntaxException - { - ResourceLocation location = ResourceLocation.read(reader); - return Registry.BIOME.getOptional(location).orElseThrow(() -> - { - return INVALID_BIOME_EXCEPTION.create(location); - }); - } - - @Override - public CompletableFuture listSuggestions(CommandContext context, SuggestionsBuilder suggestionsBuilder) - { - return ISuggestionProvider.suggestResource(Registry.BIOME.keySet(), suggestionsBuilder); - } -} diff --git a/src/main/java/biomesoplenty/common/command/CommandTpBiome.java b/src/main/java/biomesoplenty/common/command/CommandTpBiome.java deleted file mode 100644 index 141efa532..000000000 --- a/src/main/java/biomesoplenty/common/command/CommandTpBiome.java +++ /dev/null @@ -1,101 +0,0 @@ -/******************************************************************************* - * Copyright 2014-2019, the Biomes O' Plenty Team - * - * This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International Public License. - * - * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/. - ******************************************************************************/ -package biomesoplenty.common.command; - -import biomesoplenty.common.util.biome.BiomeUtil; -import biomesoplenty.common.util.block.BlockUtil; -import com.mojang.brigadier.builder.ArgumentBuilder; -import com.mojang.brigadier.exceptions.CommandSyntaxException; -import net.minecraft.block.BlockState; -import net.minecraft.block.material.Material; -import net.minecraft.command.CommandSource; -import net.minecraft.command.Commands; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.text.TranslationTextComponent; -import net.minecraft.world.World; -import net.minecraft.world.biome.Biome; -import net.minecraft.world.chunk.IChunk; - -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; - -public class CommandTpBiome -{ - private static final ExecutorService TP_BIOME_THREAD = Executors.newFixedThreadPool(1); - - static ArgumentBuilder register() - { - return Commands.literal("tpbiome") - .then(Commands.argument("biome", BiomeArgument.createArgument()) - .executes(ctx -> { - ServerPlayerEntity player = ctx.getSource().getPlayerOrException(); - TP_BIOME_THREAD.execute(() -> { - try - { - findTeleportBiome(ctx.getSource(), player, BiomeArgument.getValue(ctx, "biome")); - } - catch (CommandSyntaxException e) - { - e.printStackTrace(); - } - }); - return 1; - })); - - } - - private static int findTeleportBiome(CommandSource cs, ServerPlayerEntity player, Biome biome) - { - World world = player.level; - BlockPos closestBiomePos = biome == null ? null : BiomeUtil.spiralOutwardsLookingForBiome(world, biome, player.getX(), player.getZ()); - String biomeName = biome != null && world.isClientSide ? biome.getName().toString() : biome.getRegistryName().toString(); - - if (closestBiomePos != null) - { - double x = (double)closestBiomePos.getX(); - double y = (double) BlockUtil.getTopSolidOrLiquidBlock(world, closestBiomePos.getX(), closestBiomePos.getZ()).getY(); - double z = (double)closestBiomePos.getZ(); - - if (!world.dimensionType().natural()) - { - y = (double)getTopBlockNonOverworld(world, closestBiomePos).getY(); - } - - player.connection.teleport(x, y, z, player.yRot, player.xRot); - cs.sendSuccess(new TranslationTextComponent("commands.biomesoplenty.tpbiome.success", player.getName(), biomeName, x, y, z), true); - } - else - { - cs.sendSuccess(new TranslationTextComponent("commands.biomesoplenty.tpbiome.error", biomeName), true); - } - - return 1; - } - - public static BlockPos getTopBlockNonOverworld(World world, BlockPos pos) - { - IChunk chunk = world.getChunk(pos); - BlockPos blockpos; - BlockPos blockpos1; - BlockPos blockpos2 = new BlockPos(pos.getX(), chunk.getHighestSectionPosition() + 16, pos.getZ()); - - for (blockpos = blockpos2; blockpos.getY() >= 0; blockpos = blockpos1) - { - blockpos1 = blockpos.below(); - BlockState state = chunk.getBlockState(blockpos1); - - if (!state.getMaterial().blocksMotion() && !world.isEmptyBlock(blockpos1.below()) && state.getMaterial() != Material.LEAVES) - { - return blockpos1; - } - } - - return blockpos2; - } -} diff --git a/src/main/java/biomesoplenty/core/BiomesOPlenty.java b/src/main/java/biomesoplenty/core/BiomesOPlenty.java index a763bb7ca..db18e8611 100644 --- a/src/main/java/biomesoplenty/core/BiomesOPlenty.java +++ b/src/main/java/biomesoplenty/core/BiomesOPlenty.java @@ -8,15 +8,12 @@ package biomesoplenty.core; -import biomesoplenty.common.command.BOPCommand; import biomesoplenty.init.*; -import net.minecraft.server.dedicated.ServerProperties; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; -import net.minecraftforge.fml.event.lifecycle.FMLDedicatedServerSetupEvent; import net.minecraftforge.fml.event.lifecycle.FMLLoadCompleteEvent; import net.minecraftforge.fml.event.server.FMLServerStartingEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; @@ -40,7 +37,6 @@ public class BiomesOPlenty FMLJavaModLoadingContext.get().getModEventBus().addListener(this::commonSetup); FMLJavaModLoadingContext.get().getModEventBus().addListener(this::clientSetup); FMLJavaModLoadingContext.get().getModEventBus().addListener(this::loadComplete); - MinecraftForge.EVENT_BUS.addListener(this::serverStarting); ModBiomes.setup(); ModConfig.setup(); @@ -62,10 +58,4 @@ public class BiomesOPlenty //GenLayerVisualizer.run(); ModCompatibility.setup(); } - - public void serverStarting(FMLServerStartingEvent evt) - { - logger.info("Registering BoP commands..."); - new BOPCommand(evt.getCommandDispatcher()); - } }