mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-27 23:47:38 +01:00
Merge pull request #6356 from IThundxr/mc1.18/big-outlines-fix
Fix IHaveBigOutline not working in the y axis
This commit is contained in:
commit
7888c14082
1 changed files with 25 additions and 37 deletions
|
@ -20,7 +20,6 @@ import net.minecraftforge.common.ForgeMod;
|
||||||
* For mods wanting to use this take a look at {@link IHaveBigOutline}
|
* For mods wanting to use this take a look at {@link IHaveBigOutline}
|
||||||
*/
|
*/
|
||||||
public class BigOutlines {
|
public class BigOutlines {
|
||||||
|
|
||||||
static BlockHitResult result = null;
|
static BlockHitResult result = null;
|
||||||
|
|
||||||
public static void pick() {
|
public static void pick() {
|
||||||
|
@ -45,36 +44,38 @@ public class BigOutlines {
|
||||||
MutableBlockPos p = BlockPos.ZERO.mutable();
|
MutableBlockPos p = BlockPos.ZERO.mutable();
|
||||||
|
|
||||||
for (int x = -1; x <= 1; x++) {
|
for (int x = -1; x <= 1; x++) {
|
||||||
for (int z = -1; z <= 1; z++) {
|
for (int y = -1; y <= 1; y++) {
|
||||||
p.set(pos.getX() + x, pos.getY(), pos.getZ() + z);
|
for (int z = -1; z <= 1; z++) {
|
||||||
BlockState blockState = mc.level.getBlockState(p);
|
p.set(pos.getX() + x, pos.getY() + y, pos.getZ() + z);
|
||||||
|
BlockState blockState = mc.level.getBlockState(p);
|
||||||
|
|
||||||
if (!(blockState.getBlock() instanceof IHaveBigOutline))
|
if (!(blockState.getBlock() instanceof IHaveBigOutline))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
BlockHitResult hit = blockState.getInteractionShape(mc.level, p)
|
BlockHitResult hit = blockState.getInteractionShape(mc.level, p)
|
||||||
.clip(origin, target, p.immutable());
|
.clip(origin, target, p.immutable());
|
||||||
if (hit == null)
|
if (hit == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (result != null && Vec3.atCenterOf(p)
|
if (result != null && Vec3.atCenterOf(p)
|
||||||
.distanceToSqr(origin) >= Vec3.atCenterOf(result.getBlockPos())
|
.distanceToSqr(origin) >= Vec3.atCenterOf(result.getBlockPos())
|
||||||
.distanceToSqr(origin))
|
.distanceToSqr(origin))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Vec3 vec = hit.getLocation();
|
Vec3 vec = hit.getLocation();
|
||||||
double interactionDist = vec.distanceToSqr(origin);
|
double interactionDist = vec.distanceToSqr(origin);
|
||||||
if (interactionDist >= maxRange)
|
if (interactionDist >= maxRange)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
BlockPos hitPos = hit.getBlockPos();
|
BlockPos hitPos = hit.getBlockPos();
|
||||||
|
|
||||||
// pacifies ServerGamePacketListenerImpl.handleUseItemOn
|
// pacifies ServerGamePacketListenerImpl.handleUseItemOn
|
||||||
vec = vec.subtract(Vec3.atCenterOf(hitPos));
|
vec = vec.subtract(Vec3.atCenterOf(hitPos));
|
||||||
vec = VecHelper.clampComponentWise(vec, 1);
|
vec = VecHelper.clampComponentWise(vec, 1);
|
||||||
vec = vec.add(Vec3.atCenterOf(hitPos));
|
vec = vec.add(Vec3.atCenterOf(hitPos));
|
||||||
|
|
||||||
result = new BlockHitResult(vec, hit.getDirection(), hitPos, hit.isInside());
|
result = new BlockHitResult(vec, hit.getDirection(), hitPos, hit.isInside());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,17 +85,4 @@ public class BigOutlines {
|
||||||
if (result != null)
|
if (result != null)
|
||||||
mc.hitResult = result;
|
mc.hitResult = result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean isValidPos(Player player, BlockPos pos) {
|
|
||||||
// verify that the server will accept the fake result
|
|
||||||
double x = player.getX() - (pos.getX() + .5);
|
|
||||||
double y = player.getY() - (pos.getY() + .5) + 1.5;
|
|
||||||
double z = player.getZ() - (pos.getZ() + .5);
|
|
||||||
double distSqr = x * x + y * y + z * z;
|
|
||||||
double maxDist = player.getAttribute(ForgeMod.REACH_DISTANCE.get())
|
|
||||||
.getValue() + 1;
|
|
||||||
maxDist *= maxDist;
|
|
||||||
return distSqr <= maxDist;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue