Prevent returning out of bounds ColumnArrayView's

This commit is contained in:
James Seibel
2024-10-08 07:07:48 -05:00
parent e97e16e7d1
commit f91d3d1ec2
@@ -135,9 +135,21 @@ public class ColumnRenderSource implements IDataSource<IDhClientLevel>
public ColumnArrayView getVerticalDataPointView(int posX, int posZ)
{
int offset = posX * SECTION_SIZE * this.verticalDataCount + posZ * this.verticalDataCount;
// don't allow returning views that are outside this render source's bounds
if (offset >= this.renderDataContainer.size())
{
return null;
}
else if (posX < 0 || posX >= 64
|| posZ < 0 || posZ >= 64)
{
return null;
}
return new ColumnArrayView(this.renderDataContainer, this.verticalDataCount,
posX * SECTION_SIZE * this.verticalDataCount + posZ * this.verticalDataCount,
this.verticalDataCount);
offset, this.verticalDataCount);
}
public ColumnQuadView getFullQuadView() { return this.getQuadViewOverRange(0, 0, SECTION_SIZE, SECTION_SIZE); }