Skip to content

Commit

Permalink
refactor: Pos;
Browse files Browse the repository at this point in the history
  • Loading branch information
MJaroslav committed Feb 13, 2024
1 parent 0157be7 commit aa1171f
Show file tree
Hide file tree
Showing 7 changed files with 1,271 additions and 560 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import io.github.mjaroslav.mjutils.util.BlockAABBSet;
import io.github.mjaroslav.mjutils.util.Pos;
import io.github.mjaroslav.mjutils.util.game.UtilsPosBlock;
import io.github.mjaroslav.mjutils.util.game.UtilsPosWorld;
import io.github.mjaroslav.mjutils.util.object.game.Pos;
import io.github.mjaroslav.sharedjava.format.ColorFormat;
import io.github.mjaroslav.sharedjava.format.Colors;
import lombok.experimental.UtilityClass;
Expand Down Expand Up @@ -34,9 +34,9 @@ public void renderBlocksCollisions(@NotNull Pos pos, int blockRadius) {
glBegin(GL_LINES);
val min = pos.sub(blockRadius);
val max = pos.add(blockRadius + 1);
val mask = min.toAABB(max);
val mask = min.createAABB(max);
val list = new ArrayList<AxisAlignedBB>();
Pos.forEachInBox(min, max, i -> {
min.forEachBox(max, i -> {
list.clear();
colorCounter = 0;
UtilsPosBlock.addCollisionBoxesToList(UtilsPosWorld.getBlock(world, i), world, i, mask, list, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
import io.github.mjaroslav.mjutils.item.Stacks;
import io.github.mjaroslav.mjutils.lib.General.Creative.BlockBreaking;
import io.github.mjaroslav.mjutils.lib.General.Debug.BlockCollisionHighlighting;
import io.github.mjaroslav.mjutils.util.object.game.Pos;
import io.github.mjaroslav.mjutils.util.Pos;
import io.github.mjaroslav.mjutils.util.Pos.Mutable;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import lombok.val;
Expand All @@ -23,6 +24,8 @@ public class ClientWorldEventListener {
public final ItemStackSet extraDisabledForCreativeDestroying = new ItemStackSet(Stacks.META_WILDCARD
| Stacks.ITEM_NULLABLE);

private final Mutable temp = Pos.mutable();

@SubscribeEvent
public void onRenderWorldLastEvent(@NotNull RenderWorldLastEvent event) {
if (!BlockCollisionHighlighting.enable.isEnabled()) return;
Expand All @@ -31,9 +34,9 @@ public void onRenderWorldLastEvent(@NotNull RenderWorldLastEvent event) {
val player = Minecraft.getMinecraft().thePlayer;
if (mov == null || world == null || player == null || (BlockCollisionHighlighting.enable.isShift()
&& !player.isSneaking())) return;
val pos = BlockCollisionHighlighting.enable.isCursor() ? new Pos(mov.blockX, mov.blockY, mov.blockZ) :
new Pos(player.posX, player.posY, player.posZ);
DebugRenderer.renderBlocksCollisions(pos, BlockCollisionHighlighting.range - 1);
val flag = BlockCollisionHighlighting.enable.isCursor();
DebugRenderer.renderBlocksCollisions(temp.set(flag ? mov.blockX : player.posX, flag ? mov.blockX : player.posX,
flag ? mov.blockX : player.posX), BlockCollisionHighlighting.range - 1);
}

@SubscribeEvent
Expand Down
Loading

0 comments on commit aa1171f

Please sign in to comment.