Skip to content

Commit

Permalink
Merge pull request #33 from Zpiboo/master
Browse files Browse the repository at this point in the history
Add boundingBoxSize infoVar
  • Loading branch information
kurrycat2004 authored Jun 6, 2024
2 parents 2fc1b84 + 4066200 commit b6a51a9
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public class Player {
public boolean landTick = false;
public String lastTiming = "None";
public boolean sprinting = false;
public BoundingBox3D boundingBox = null;


@InfoString.Getter
Expand Down Expand Up @@ -323,11 +324,18 @@ public Player getPrevious() {
return tickHistory.get(i - 1);
}

public BoundingBox3D getBB() {
return new BoundingBox3D(
getPos().add(-0.6F / 2D, 0D, -0.6F / 2D), //TODO: use dynamic player size
getPos().add(0.6F / 2D, 1.8F, 0.6F / 2D)
);
public BoundingBox3D getBoundingBox() {
return boundingBox;
}

@InfoString.Getter
public Vector3D getBoundingBoxSize() {
return boundingBox.getSize();
}

public Player setBoundingBox(BoundingBox3D boundingBox) {
this.boundingBox = boundingBox;
return this;
}

@InfoString.Getter
Expand All @@ -340,11 +348,12 @@ public Player setPos(Vector3D pos) {
return this;
}

public BoundingBox3D getLastBB() {
return new BoundingBox3D(
getLastPos().add(-0.6F / 2D, 0D, -0.6F / 2D), //TODO: use dynamic player size
getLastPos().add(0.6F / 2D, 1.8F, 0.6F / 2D)
);
public BoundingBox3D getLastBoundingBox() {
return getPrevious().getBoundingBox();
}

public Vector3D getLastBoundingBoxSize() {
return getLastBoundingBox().getSize();
}

@InfoString.Getter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ else if (calculateOffsetDist(offset) > calculateOffsetDist(pb)) {
public boolean isTryingToLandOn() {
if (Player.getLatest() == null) return false;

BoundingBox3D playerBB = Player.getLatest().getBB();
BoundingBox3D lastPlayerBB = Player.getLatest().getLastBB();
BoundingBox3D playerBB = Player.getLatest().getBoundingBox();
BoundingBox3D lastPlayerBB = Player.getLatest().getLastBoundingBox();

if (landingMode != LandingMode.ENTER)
return playerBB.minY() <= boundingBox.maxY() && lastPlayerBB.minY() > boundingBox.maxY();
Expand Down Expand Up @@ -123,13 +123,13 @@ public BoundingBox3D getPlayerBB() {
switch (this) {
case Z_NEO:
if (Player.getBeforeLatest() == null) return null;
return Player.getBeforeLatest().getLastBB();
return Player.getBeforeLatest().getLastBoundingBox();
case HIT:
case ENTER:
return Player.getLatest().getBB();
return Player.getLatest().getBoundingBox();
case LAND:
default:
return Player.getLatest().getLastBB();
return Player.getLatest().getLastBoundingBox();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
import io.github.kurrycat.mpkmod.compatibility.API;
import io.github.kurrycat.mpkmod.compatibility.MCClasses.Player;
import io.github.kurrycat.mpkmod.compatibility.fabric_1_19_4.mixin.KeyBindingAccessor;
import io.github.kurrycat.mpkmod.compatibility.fabric_1_19_4.MPKGuiScreen;
import io.github.kurrycat.mpkmod.ticks.ButtonMS;
import io.github.kurrycat.mpkmod.ticks.ButtonMSList;
import io.github.kurrycat.mpkmod.util.BoundingBox3D;
import io.github.kurrycat.mpkmod.util.Vector3D;
import net.fabricmc.fabric.api.networking.v1.PacketSender;
import net.minecraft.client.MinecraftClient;
Expand All @@ -16,6 +18,7 @@
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.Util;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.Box;

public class EventHandler {
private static final ButtonMSList timeQueue = new ButtonMSList();
Expand Down Expand Up @@ -93,13 +96,18 @@ public void onClientTickEnd(MinecraftClient mc) {
ClientPlayerEntity mcPlayer = mc.player;

if (mcPlayer != null) {
Box playerBB = mcPlayer.getBoundingBox();
new Player()
.setPos(new Vector3D(mcPlayer.getX(), mcPlayer.getY(), mcPlayer.getZ()))
.setLastPos(new Vector3D(mcPlayer.prevX, mcPlayer.prevY, mcPlayer.prevZ))
.setMotion(new Vector3D(mcPlayer.getVelocity().x, mcPlayer.getVelocity().y, mcPlayer.getVelocity().z))
.setRotation(mcPlayer.getRotationClient().y, mcPlayer.getRotationClient().x)
.setOnGround(mcPlayer.isOnGround())
.setSprinting(mcPlayer.isSprinting())
.setBoundingBox(new BoundingBox3D(
new Vector3D(playerBB.minX, playerBB.minY, playerBB.minZ),
new Vector3D(playerBB.maxX, playerBB.maxY, playerBB.maxZ)
))
.constructKeyInput()
.setKeyMSList(timeQueue)
.buildAndSave();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
import io.github.kurrycat.mpkmod.compatibility.API;
import io.github.kurrycat.mpkmod.compatibility.MCClasses.Player;
import io.github.kurrycat.mpkmod.compatibility.fabric_1_20_4.mixin.KeyBindingAccessor;
import io.github.kurrycat.mpkmod.compatibility.fabric_1_20_4.MPKGuiScreen;
import io.github.kurrycat.mpkmod.ticks.ButtonMS;
import io.github.kurrycat.mpkmod.ticks.ButtonMSList;
import io.github.kurrycat.mpkmod.util.BoundingBox3D;
import io.github.kurrycat.mpkmod.util.Vector3D;
import net.fabricmc.fabric.api.networking.v1.PacketSender;
import net.minecraft.client.MinecraftClient;
Expand All @@ -17,6 +19,7 @@
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.Util;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.Box;

public class EventHandler {
private static final ButtonMSList timeQueue = new ButtonMSList();
Expand Down Expand Up @@ -94,13 +97,18 @@ public void onClientTickEnd(MinecraftClient mc) {
ClientPlayerEntity mcPlayer = mc.player;

if (mcPlayer != null) {
Box playerBB = mcPlayer.getBoundingBox();
new Player()
.setPos(new Vector3D(mcPlayer.getX(), mcPlayer.getY(), mcPlayer.getZ()))
.setLastPos(new Vector3D(mcPlayer.prevX, mcPlayer.prevY, mcPlayer.prevZ))
.setMotion(new Vector3D(mcPlayer.getVelocity().x, mcPlayer.getVelocity().y, mcPlayer.getVelocity().z))
.setRotation(mcPlayer.getRotationClient().y, mcPlayer.getRotationClient().x)
.setOnGround(mcPlayer.isOnGround())
.setSprinting(mcPlayer.isSprinting())
.setBoundingBox(new BoundingBox3D(
new Vector3D(playerBB.minX, playerBB.minY, playerBB.minZ),
new Vector3D(playerBB.maxX, playerBB.maxY, playerBB.maxZ)
))
.constructKeyInput()
.setKeyMSList(timeQueue)
.buildAndSave();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
import io.github.kurrycat.mpkmod.compatibility.API;
import io.github.kurrycat.mpkmod.compatibility.MCClasses.Player;
import io.github.kurrycat.mpkmod.compatibility.fabric_1_20_6.mixin.KeyBindingAccessor;
import io.github.kurrycat.mpkmod.compatibility.fabric_1_20_6.MPKGuiScreen;
import io.github.kurrycat.mpkmod.ticks.ButtonMS;
import io.github.kurrycat.mpkmod.ticks.ButtonMSList;
import io.github.kurrycat.mpkmod.util.BoundingBox3D;
import io.github.kurrycat.mpkmod.util.Vector3D;
import net.fabricmc.fabric.api.networking.v1.PacketSender;
import net.minecraft.client.MinecraftClient;
Expand All @@ -17,6 +19,7 @@
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.Util;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.Box;

public class EventHandler {
private static final ButtonMSList timeQueue = new ButtonMSList();
Expand Down Expand Up @@ -94,13 +97,18 @@ public void onClientTickEnd(MinecraftClient mc) {
ClientPlayerEntity mcPlayer = mc.player;

if (mcPlayer != null) {
Box playerBB = mcPlayer.getBoundingBox();
new Player()
.setPos(new Vector3D(mcPlayer.getX(), mcPlayer.getY(), mcPlayer.getZ()))
.setLastPos(new Vector3D(mcPlayer.prevX, mcPlayer.prevY, mcPlayer.prevZ))
.setMotion(new Vector3D(mcPlayer.getVelocity().x, mcPlayer.getVelocity().y, mcPlayer.getVelocity().z))
.setRotation(mcPlayer.getRotationClient().y, mcPlayer.getRotationClient().x)
.setOnGround(mcPlayer.isOnGround())
.setSprinting(mcPlayer.isSprinting())
.setBoundingBox(new BoundingBox3D(
new Vector3D(playerBB.minX, playerBB.minY, playerBB.minZ),
new Vector3D(playerBB.maxX, playerBB.maxY, playerBB.maxZ)
))
.constructKeyInput()
.setKeyMSList(timeQueue)
.buildAndSave();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
import io.github.kurrycat.mpkmod.compatibility.MCClasses.Player;
import io.github.kurrycat.mpkmod.ticks.ButtonMS;
import io.github.kurrycat.mpkmod.ticks.ButtonMSList;
import io.github.kurrycat.mpkmod.util.BoundingBox3D;
import io.github.kurrycat.mpkmod.util.Mouse;
import io.github.kurrycat.mpkmod.util.Vector3D;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.client.gui.GuiOverlayDebug;
import net.minecraft.client.settings.GameSettings;
import net.minecraft.util.AxisAlignedBB;
import net.minecraftforge.client.event.MouseEvent;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.client.event.RenderWorldLastEvent;
Expand Down Expand Up @@ -90,13 +92,18 @@ public void onTick(TickEvent.ClientTickEvent e) {
if (e.side != Side.CLIENT) return;

if (mcPlayer != null && e.phase == TickEvent.Phase.START) {
AxisAlignedBB playerBB = mcPlayer.getEntityBoundingBox();
new Player()
.setPos(new Vector3D(mcPlayer.posX, mcPlayer.posY, mcPlayer.posZ))
.setLastPos(new Vector3D(mcPlayer.lastTickPosX, mcPlayer.lastTickPosY, mcPlayer.lastTickPosZ))
.setMotion(new Vector3D(mcPlayer.motionX, mcPlayer.motionY, mcPlayer.motionZ))
.setRotation(mcPlayer.rotationYaw, mcPlayer.rotationPitch)
.setOnGround(mcPlayer.onGround)
.setSprinting(mcPlayer.isSprinting())
.setBoundingBox(new BoundingBox3D(
new Vector3D(playerBB.minX, playerBB.minY, playerBB.minZ),
new Vector3D(playerBB.maxX, playerBB.maxY, playerBB.maxZ)
))
.constructKeyInput()
.setKeyMSList(timeQueue.copy())
.buildAndSave();
Expand Down

0 comments on commit b6a51a9

Please sign in to comment.