Fixed freezing when looking straight up/down or perfectly horizontal. Removed updateJSONURL in mods.toml. (8-6-2020)

This commit is contained in:
Christian Knaapen
2020-08-23 12:07:04 +02:00
parent 74d74390d2
commit 586e7df3f6
9 changed files with 34 additions and 7 deletions

View File

@@ -46,7 +46,7 @@ public class EffortlessBuilding
{
public static final String MODID = "effortlessbuilding";
public static final String NAME = "Effortless Building";
public static final String VERSION = "1.14.4-2.18";
public static final String VERSION = "1.14.4-2.19";
public static EffortlessBuilding instance;

View File

@@ -229,6 +229,31 @@ public class BuildModes {
return new Vec3d(x, y, z);
}
//Use this instead of player.getLookVec() in any buildmodes code
public static Vec3d getPlayerLookVec(PlayerEntity player){
Vec3d lookVec = player.getLookVec();
double x = lookVec.x;
double y = lookVec.y;
double z = lookVec.z;
//Further calculations (findXBound etc) don't like any component being 0 or 1 (e.g. dividing by 0)
//isCriteriaValid below will take up to 2 minutes to raytrace blocks towards infinity if that is the case
//So make sure they are close to but never exactly 0 or 1
if (Math.abs(x) < 0.0001) x = 0.0001;
if (Math.abs(x - 1.0) < 0.0001) x = 0.9999;
if (Math.abs(x + 1.0) < 0.0001) x = -0.9999;
if (Math.abs(y) < 0.0001) y = 0.0001;
if (Math.abs(y - 1.0) < 0.0001) y = 0.9999;
if (Math.abs(y + 1.0) < 0.0001) y = -0.9999;
if (Math.abs(z) < 0.0001) z = 0.0001;
if (Math.abs(z - 1.0) < 0.0001) z = 0.9999;
if (Math.abs(z + 1.0) < 0.0001) z = -0.9999;
return new Vec3d(x, y, z);
}
public static boolean isCriteriaValid(Vec3d start, Vec3d look, int reach, PlayerEntity player, boolean skipRaytrace, Vec3d lineBound, Vec3d planeBound, double distToPlayerSq) {
boolean intersects = false;
if (!skipRaytrace) {

View File

@@ -169,7 +169,7 @@ public abstract class ThreeClicksBuildMode extends BaseBuildMode {
//Finds height after floor has been chosen in buildmodes with 3 clicks
public static BlockPos findHeight(PlayerEntity player, BlockPos secondPos, boolean skipRaytrace) {
Vec3d look = player.getLookVec();
Vec3d look = BuildModes.getPlayerLookVec(player);
Vec3d start = new Vec3d(player.posX, player.posY + player.getEyeHeight(), player.posZ);
List<HeightCriteria> criteriaList = new ArrayList<>(3);

View File

@@ -4,6 +4,7 @@ import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import nl.requios.effortlessbuilding.EffortlessBuilding;
import nl.requios.effortlessbuilding.helper.ReachHelper;
import java.util.ArrayList;

View File

@@ -35,7 +35,7 @@ public class Floor extends TwoClicksBuildMode {
}
public static BlockPos findFloor(PlayerEntity player, BlockPos firstPos, boolean skipRaytrace) {
Vec3d look = player.getLookVec();
Vec3d look = BuildModes.getPlayerLookVec(player);
Vec3d start = new Vec3d(player.posX, player.posY + player.getEyeHeight(), player.posZ);
List<Criteria> criteriaList = new ArrayList<>(3);

View File

@@ -3,6 +3,7 @@ package nl.requios.effortlessbuilding.buildmode.buildmodes;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import nl.requios.effortlessbuilding.EffortlessBuilding;
import nl.requios.effortlessbuilding.buildmode.BuildModes;
import nl.requios.effortlessbuilding.buildmode.TwoClicksBuildMode;
import nl.requios.effortlessbuilding.helper.ReachHelper;
@@ -60,7 +61,7 @@ public class Line extends TwoClicksBuildMode {
}
public static BlockPos findLine(PlayerEntity player, BlockPos firstPos, boolean skipRaytrace) {
Vec3d look = player.getLookVec();
Vec3d look = BuildModes.getPlayerLookVec(player);
Vec3d start = new Vec3d(player.posX, player.posY + player.getEyeHeight(), player.posZ);
List<Criteria> criteriaList = new ArrayList<>(3);

View File

@@ -38,7 +38,7 @@ public class Wall extends TwoClicksBuildMode {
}
public static BlockPos findWall(PlayerEntity player, BlockPos firstPos, boolean skipRaytrace) {
Vec3d look = player.getLookVec();
Vec3d look = BuildModes.getPlayerLookVec(player);
Vec3d start = new Vec3d(player.posX, player.posY + player.getEyeHeight(), player.posZ);
List<Criteria> criteriaList = new ArrayList<>(3);

View File

@@ -18,7 +18,7 @@ version="${file.jarVersion}" #mandatory
# A display name for the mod
displayName="Effortless Building" #mandatory
# A URL to query for updates for this mod. See the JSON update specification <here>
updateJSONURL="http://myurl.me/" #optional
#updateJSONURL="example.com" #optional
# A URL for the "homepage" for this mod, displayed in the mod UI
displayURL="https://minecraft.curseforge.com/projects/effortless-building" #optional
# A file name (in the root of the mod JAR) containing a logo for display