Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
TheidenHD committed May 28, 2024
1 parent d39c42a commit 588dc44
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/main/java/vazkii/psi/common/item/ItemVectorRuler.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,12 @@ public InteractionResult useOn(UseOnContext ctx) {
BlockPos pos = ctx.getClickedPos();

ItemStack stack = ctx.getPlayer().getItemInHand(ctx.getHand());
int srcY = stack.getOrCreateTag().contains(TAG_SRC_Y) ? stack.getOrCreateTag().getInt(TAG_SRC_Y) : -1;

if(srcY == -1 || ctx.getPlayer().isShiftKeyDown()) {
if(!stack.getOrCreateTag().contains(TAG_SRC_Y) || ctx.getPlayer().isShiftKeyDown()) {
stack.getOrCreateTag().putInt(TAG_SRC_X, pos.getX());
stack.getOrCreateTag().putInt(TAG_SRC_Y, pos.getY());
stack.getOrCreateTag().putInt(TAG_SRC_Z, pos.getZ());
stack.getOrCreateTag().putInt(TAG_DST_Y, -1);
stack.removeTagKey(TAG_DST_Y);
} else {
stack.getOrCreateTag().putInt(TAG_DST_X, pos.getX());
stack.getOrCreateTag().putInt(TAG_DST_Y, pos.getY());
Expand All @@ -76,12 +75,12 @@ public Vector3 getVector(ItemStack stack) {
int srcY = stack.getOrCreateTag().getInt(TAG_SRC_Y);
int srcZ = stack.getOrCreateTag().getInt(TAG_SRC_Z);

int dstY = stack.getOrCreateTag().contains(TAG_DST_Y) ? stack.getOrCreateTag().getInt(TAG_DST_Y) : -1;
if(dstY == -1) {
if(!stack.getOrCreateTag().contains(TAG_DST_Y)) {
return new Vector3(srcX, srcY, srcZ);
}

int dstX = stack.getOrCreateTag().getInt(TAG_DST_X);
int dstY = stack.getOrCreateTag().getInt(TAG_DST_Y);
int dstZ = stack.getOrCreateTag().getInt(TAG_DST_Z);

return new Vector3(dstX - srcX, dstY - srcY, dstZ - srcZ);
Expand Down

0 comments on commit 588dc44

Please sign in to comment.