-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
55 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 4 additions & 2 deletions
6
src/main/java/tools/redstone/redstonetools/utils/CommandSourceUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
package tools.redstone.redstonetools.utils; | ||
|
||
import com.mojang.brigadier.exceptions.CommandSyntaxException; | ||
|
||
import net.minecraft.server.command.ServerCommandSource; | ||
|
||
public class CommandSourceUtils { | ||
private CommandSourceUtils() { | ||
} | ||
|
||
public static void executeCommand(ServerCommandSource source, String command) { | ||
source.getServer().getCommandManager().execute(source, command); | ||
public static void executeCommand(ServerCommandSource source, String command) throws CommandSyntaxException { | ||
source.getServer().getCommandManager().getDispatcher().execute(command, source); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 6 additions & 7 deletions
13
src/main/java/tools/redstone/redstonetools/utils/RaycastUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,29 @@ | ||
package tools.redstone.redstonetools.utils; | ||
|
||
import org.joml.Vector3f; | ||
|
||
import net.minecraft.entity.player.PlayerEntity; | ||
import net.minecraft.util.hit.BlockHitResult; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.util.math.Vec3f; | ||
import net.minecraft.world.RaycastContext; | ||
|
||
public class RaycastUtils { | ||
private RaycastUtils() { | ||
} | ||
|
||
public static BlockHitResult getBlockHitNeighbor(BlockHitResult hit) { | ||
var sideOffset = hit.getSide().getUnitVector(); | ||
Vector3f sideOffset = hit.getSide().getUnitVector(); | ||
|
||
var newBlockPos = hit.getBlockPos().add(sideOffset.getX(), sideOffset.getY(), sideOffset.getZ()); | ||
var newBlockPos = hit.getBlockPos().add((int) sideOffset.x(), (int) sideOffset.y(), (int) sideOffset.z()); | ||
|
||
return hit.withBlockPos(newBlockPos); | ||
} | ||
|
||
public static BlockHitResult rayCastFromEye(PlayerEntity player, float reach) { | ||
return player.method_48926().raycast(new RaycastContext( | ||
return player.getWorld().raycast(new RaycastContext( | ||
player.getEyePos(), | ||
player.getEyePos().add(player.getRotationVector().multiply(reach)), | ||
RaycastContext.ShapeType.COLLIDER, | ||
RaycastContext.FluidHandling.NONE, | ||
player | ||
)); | ||
player)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters