]> git.lizzy.rs Git - BoundingBoxOutlineReloaded.git/commitdiff
Support adding spheres at other locations
authorIrtimaled <irtimaled@gmail.com>
Mon, 18 Nov 2019 18:12:58 +0000 (10:12 -0800)
committerIrtimaled <irtimaled@gmail.com>
Tue, 19 Nov 2019 04:26:53 +0000 (20:26 -0800)
src/main/java/com/irtimaled/bbor/client/commands/SpawningSphereCommand.java
src/main/java/com/irtimaled/bbor/client/providers/SpawningSphereProvider.java

index d47bb0c2403cd4b2e27c60c12328384b8725de55..a4399d285e1f1e9300fff52626f99418833fa770 100644 (file)
@@ -1,23 +1,35 @@
 package com.irtimaled.bbor.client.commands;
 
+import com.irtimaled.bbor.client.PlayerCoords;
 import com.irtimaled.bbor.client.providers.SpawningSphereProvider;
 import com.mojang.brigadier.CommandDispatcher;
 import com.mojang.brigadier.builder.LiteralArgumentBuilder;
 import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
 import net.minecraft.command.Commands;
 import net.minecraft.command.ISuggestionProvider;
+import net.minecraft.command.arguments.Vec3Argument;
+import net.minecraft.util.math.Vec3d;
 
 public class SpawningSphereCommand {
     private static final String COMMAND = "bbor:spawningSphere";
     private static final String SET = "set";
+    private static final String POS = "pos";
     private static final String CLEAR = "clear";
     private static final String CALCULATE_SPAWNABLE = "calculateSpawnable";
 
     public static void register(CommandDispatcher<ISuggestionProvider> commandDispatcher) {
         LiteralArgumentBuilder command = Commands.literal(COMMAND)
                 .then(Commands.literal(SET)
+                        .then(Commands.argument(POS, Vec3Argument.vec3())
+                                .executes(context -> {
+                                    Vec3d pos = Vec3Argument.getVec3(context, POS);
+                                    SpawningSphereProvider.setSphere(pos.x, pos.y, pos.z);
+
+                                    CommandHelper.feedback(context, "Spawning sphere set");
+                                    return 0;
+                                }))
                         .executes(context -> {
-                            SpawningSphereProvider.setSphere();
+                            SpawningSphereProvider.setSphere(PlayerCoords.getX(), PlayerCoords.getY(), PlayerCoords.getZ());
 
                             CommandHelper.feedback(context, "Spawning sphere set");
                             return 0;
index eb024a77e3e6d8dd25bb9d55a08d53d3da4d29a1..2da43ed7797eff4e9f6b62694a1ac5164b8449e9 100644 (file)
@@ -11,11 +11,11 @@ public class SpawningSphereProvider implements IBoundingBoxProvider<BoundingBoxS
     private static BoundingBoxSpawningSphere spawningSphere;
     private static Integer dimensionId;
 
-    public static void setSphere() {
-        Coords coords = PlayerCoords.get();
-        double xOffset = snapToNearestHalf(PlayerCoords.getX() -coords.getX());
-        double yOffset = PlayerCoords.getY()- coords.getY();
-        double zOffset = snapToNearestHalf(PlayerCoords.getZ()-coords.getZ());
+    public static void setSphere(double x, double y, double z) {
+        Coords coords = new Coords(x, y, z);
+        double xOffset = snapToNearestHalf(x -coords.getX());
+        double yOffset = y- coords.getY();
+        double zOffset = snapToNearestHalf(z-coords.getZ());
 
         if(spawningSphere != null && spawningSphere.isCenter(coords, xOffset, yOffset, zOffset)) {
             return;