Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,8 @@ public static void onProcessPacket(final Packet packetIn, final PacketListener n
// Basically, we need to sanity check the nearby blocks because if they have
// any positional logic, we need to run captures
final AABB boundingBox = packetPlayer.getBoundingBox();
final BlockPos min = new BlockPos((int) (boundingBox.minX + 0.001D), (int) (boundingBox.minY + 0.001D), (int) (boundingBox.minZ + 0.001D));
final BlockPos max = new BlockPos((int) (boundingBox.maxX - 0.001D), (int) (boundingBox.maxY - 0.001D), (int) (boundingBox.maxZ - 0.001D));
final BlockPos min = BlockPos.containing(boundingBox.minX + 0.001D, boundingBox.minY + 0.001D, boundingBox.minZ + 0.001D);
final BlockPos max = BlockPos.containing(boundingBox.maxX - 0.001D, boundingBox.maxY - 0.001D, boundingBox.maxZ - 0.001D);
final BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos();
if (packetPlayer.level().hasChunksAt(min, max)) {
for(int x = min.getX(); x <= max.getX(); ++x) {
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/org/spongepowered/common/util/VecHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,11 @@ public static boolean inBounds(final BlockPos pos, final org.spongepowered.math.
return VecHelper.inBounds(pos.getX(), pos.getY(), pos.getZ(), min, max);
}

public static boolean inBounds(final org.spongepowered.math.vector.Vector3i pos, final org.spongepowered.math.vector.Vector3i min,
final org.spongepowered.math.vector.Vector3i max) {
return VecHelper.inBounds(pos.x(), pos.y(), pos.z(), min, max);
}

public static boolean inBounds(final org.spongepowered.math.vector.Vector3d pos, final org.spongepowered.math.vector.Vector3i min,
final org.spongepowered.math.vector.Vector3i max) {
return VecHelper.inBounds(pos.x(), pos.y(), pos.z(), min, max);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ public <E extends Entity> E createEntityNaturally(final EntityType<E> type, fina
@Override
public Optional<Entity> createEntity(final DataContainer container) {
return Optional.ofNullable(((LevelBridge) this.level).bridge$createEntity(container, null,
position -> VecHelper.inBounds(position, this.min(), this.max())));
position -> VecHelper.inBounds(position.toInt(), this.min(), this.max())));
}

@Override
Expand Down Expand Up @@ -231,7 +231,7 @@ public <T extends Entity> void filterEntities(final Class<? extends T> entityCla
}

private void checkPositionInChunk(final Vector3d position) {
if (!VecHelper.inBounds(position, this.min(), this.max())) {
if (!VecHelper.inBounds(position.toInt(), this.min(), this.max())) {
throw new IllegalArgumentException("Supplied bounds are not within this chunk.");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -469,8 +469,7 @@ public <E extends Entity> E createEntityNaturally(final EntityType<E> type, fina

@Override
public Optional<Entity> createEntity(final DataContainer container) {
return Optional.ofNullable(((LevelBridge) this.level).bridge$createEntity(container, null,
position -> VecHelper.inBounds(position, this.min(), this.max())));
return Optional.ofNullable(((LevelBridge) this.level).bridge$createEntity(container, null, this::api$isInBounds));
}

@Override
Expand Down Expand Up @@ -510,7 +509,7 @@ public boolean setBlock(final int x, final int y, final int z, final BlockState
}

private boolean api$isInBounds(final Vector3d position) {
return VecHelper.inBounds(position, this.min(), this.max());
return VecHelper.inBounds(position.toInt(), this.min(), this.max());
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public abstract class EmptyMapItemMixin {
frame.addContext(EventContextKeys.USED_ITEM, ItemStackUtil.snapshotOf(usedItem));

final Set<Value<?>> mapValues = Sets.newHashSet(
Value.immutableOf(Keys.MAP_LOCATION, Vector2i.from((int) player.getX(), (int) player.getZ())),
Value.immutableOf(Keys.MAP_LOCATION, Vector2i.from(player.getBlockX(), player.getBlockZ())),
Value.immutableOf(Keys.MAP_WORLD, ((ServerWorld) level).key())
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public abstract class TeleportCommandMixin {

if (entityIn instanceof ServerPlayer) {

ChunkPos chunkpos = new ChunkPos(new BlockPos((int) actualX, (int) actualY, (int) actualZ));
ChunkPos chunkpos = new ChunkPos(BlockPos.containing(actualX, actualY, actualZ));
worldIn.getChunkSource().addRegionTicket(TicketType.POST_TELEPORT, chunkpos, 1, entityIn.getId());

entityIn.stopRiding();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ public abstract class LevelMixin implements LevelBridge, LevelAccessor {

if (naturally && entity instanceof Mob) {
// Adding the default equipment
final DifficultyInstance difficulty = this.shadow$getCurrentDifficultyAt(new BlockPos((int) x, (int) y, (int) z));
final DifficultyInstance difficulty = this.shadow$getCurrentDifficultyAt(BlockPos.containing(x, y, z));
((MobAccessor) entity).invoker$populateDefaultEquipmentSlots(this.random, difficulty);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public abstract class FallingBlockEntityMixin_Tracker extends EntityMixin_Tracke
// cancellable = true
// )
private void tracker$handleBlockCapture(final CallbackInfo ci) {
final BlockPos pos = new BlockPos((int) this.shadow$getX(), (int) this.shadow$getY(), (int) this.shadow$getZ());
final BlockPos pos = BlockPos.containing(this.shadow$getX(), this.shadow$getY(), this.shadow$getZ());
// So, there's two cases here: either the world is not cared for, or the
// ChangeBlockEvent is not being listened to. If it's not being listened to,
// we need to specifically just proceed as normal.
Expand Down
Loading