AltControl implementation #7
3 changed files with 10 additions and 8 deletions
|
@ -101,7 +101,7 @@ public class RemoteEventManager {
|
|||
for (int i = 0; i < clients.size(); i++) {
|
||||
Socket client = clients.get(i);
|
||||
try {
|
||||
client.getOutputStream().write(i);
|
||||
client.getOutputStream().write(i + 1);
|
||||
new TypedOutputStream(client.getOutputStream()).writeString(stringEvent);
|
||||
client.getOutputStream().flush();
|
||||
} catch (IOException e) {
|
||||
|
|
|
@ -8,17 +8,19 @@ public class BlockUtils {
|
|||
// returned amount may be smaller!
|
||||
public static Selection[] splitSelection1D(Selection selection, int amount) {
|
||||
Vec3i size = selection.size();
|
||||
int sideLength = (int) ((selection.longestSideH() - 1) / amount + 1); // rounded up
|
||||
Selection[] selections = new Selection[(int) (selection.longestSideH() / sideLength)];
|
||||
int selSideLength = selection.longestSideH();
|
||||
int sectionSideLength = (selSideLength - 1) / amount + 1; // rounded up
|
||||
System.out.println(sectionSideLength);
|
||||
Selection[] selections = new Selection[(int) ((selSideLength - 1) / sectionSideLength + 1)]; // rounded up
|
||||
int xSideLength = 0;
|
||||
int zSideLength = 0;
|
||||
if(size.getX() >= size.getZ())
|
||||
xSideLength = sideLength;
|
||||
xSideLength = sectionSideLength;
|
||||
else
|
||||
zSideLength = sideLength;
|
||||
zSideLength = sectionSideLength;
|
||||
for (int i = 0; i < selections.length; i++) {
|
||||
BlockPos pos1 = selection.pos1.add(xSideLength * i, 0, zSideLength * i);
|
||||
BlockPos pos2 = selection.pos2.add(Math.min(xSideLength * (i + 1), size.getX() - 1), 0, Math.min(zSideLength * (i + 1), size.getZ() - 1));
|
||||
BlockPos pos2 = selection.pos1.add(Math.max(Math.min(xSideLength * (i + 1), selSideLength) - 1, 0), 0, Math.min(Math.max(zSideLength * (i + 1) - 1, 0), selSideLength - 1));
|
||||
selections[i] = new Selection(pos1, pos2);
|
||||
}
|
||||
return selections;
|
||||
|
|
|
@ -21,12 +21,12 @@ public class Selection {
|
|||
return (long) size.getX() * size.getY() * size.getZ();
|
||||
}
|
||||
|
||||
public long longestSide() {
|
||||
public int longestSide() {
|
||||
Vec3i size = size();
|
||||
return Math.max(Math.max(size.getX(), size.getY()), size.getZ());
|
||||
}
|
||||
|
||||
public long longestSideH() {
|
||||
public int longestSideH() {
|
||||
Vec3i size = size();
|
||||
return Math.max(size.getX(), size.getZ());
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue