mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-11-14 06:24:29 +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
@ -20,7 +20,6 @@ import net.minecraftforge.common.ForgeMod;
|
||||
* For mods wanting to use this take a look at {@link IHaveBigOutline}
|
||||
*/
|
||||
public class BigOutlines {
|
||||
|
||||
static BlockHitResult result = null;
|
||||
|
||||
public static void pick() {
|
||||
@ -45,36 +44,38 @@ public class BigOutlines {
|
||||
MutableBlockPos p = BlockPos.ZERO.mutable();
|
||||
|
||||
for (int x = -1; x <= 1; x++) {
|
||||
for (int z = -1; z <= 1; z++) {
|
||||
p.set(pos.getX() + x, pos.getY(), pos.getZ() + z);
|
||||
BlockState blockState = mc.level.getBlockState(p);
|
||||
for (int y = -1; y <= 1; y++) {
|
||||
for (int z = -1; z <= 1; z++) {
|
||||
p.set(pos.getX() + x, pos.getY() + y, pos.getZ() + z);
|
||||
BlockState blockState = mc.level.getBlockState(p);
|
||||
|
||||
if (!(blockState.getBlock() instanceof IHaveBigOutline))
|
||||
continue;
|
||||
if (!(blockState.getBlock() instanceof IHaveBigOutline))
|
||||
continue;
|
||||
|
||||
BlockHitResult hit = blockState.getInteractionShape(mc.level, p)
|
||||
.clip(origin, target, p.immutable());
|
||||
if (hit == null)
|
||||
continue;
|
||||
BlockHitResult hit = blockState.getInteractionShape(mc.level, p)
|
||||
.clip(origin, target, p.immutable());
|
||||
if (hit == null)
|
||||
continue;
|
||||
|
||||
if (result != null && Vec3.atCenterOf(p)
|
||||
.distanceToSqr(origin) >= Vec3.atCenterOf(result.getBlockPos())
|
||||
.distanceToSqr(origin))
|
||||
continue;
|
||||
if (result != null && Vec3.atCenterOf(p)
|
||||
.distanceToSqr(origin) >= Vec3.atCenterOf(result.getBlockPos())
|
||||
.distanceToSqr(origin))
|
||||
continue;
|
||||
|
||||
Vec3 vec = hit.getLocation();
|
||||
double interactionDist = vec.distanceToSqr(origin);
|
||||
if (interactionDist >= maxRange)
|
||||
continue;
|
||||
Vec3 vec = hit.getLocation();
|
||||
double interactionDist = vec.distanceToSqr(origin);
|
||||
if (interactionDist >= maxRange)
|
||||
continue;
|
||||
|
||||
BlockPos hitPos = hit.getBlockPos();
|
||||
BlockPos hitPos = hit.getBlockPos();
|
||||
|
||||
// pacifies ServerGamePacketListenerImpl.handleUseItemOn
|
||||
vec = vec.subtract(Vec3.atCenterOf(hitPos));
|
||||
vec = VecHelper.clampComponentWise(vec, 1);
|
||||
vec = vec.add(Vec3.atCenterOf(hitPos));
|
||||
// pacifies ServerGamePacketListenerImpl.handleUseItemOn
|
||||
vec = vec.subtract(Vec3.atCenterOf(hitPos));
|
||||
vec = VecHelper.clampComponentWise(vec, 1);
|
||||
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)
|
||||
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 New Issue
Block a user