Working Restrictions

This commit is contained in:
2022-10-01 16:58:27 +02:00
parent b5468b1fe9
commit 4bdb3f94d5
20 changed files with 244 additions and 46 deletions

View File

@@ -0,0 +1,135 @@
package eu.mhsl.minenet.minigames.util;
import com.extollit.linalg.mutable.Vec2d;
import it.unimi.dsi.fastutil.Pair;
import net.minestom.server.coordinate.Vec;
import java.util.ArrayList;
import java.util.List;
public class InventoryItemAlignment {
private int size;
private int x;
private int y;
private int counter = -1;
public InventoryItemAlignment(int size, int x, int y) {
this.size = size;
this.x = x;
this.y = y;
if(x * y < size) throw new RuntimeException("Not enough space for Item alignment");
}
public InventoryItemAlignment(int size, int y) {
this.size = size;
this.x = 9;
this.y = y;
if(x * y < size) throw new RuntimeException("Not enough space for Item alignment");
}
public Vec2d next() {
counter++;
if(this.size < 9) return new Vec2d(this.row(this.size).get(counter), y/2);
//TODO more items?
return new Vec2d(0,0);
}
private List<Integer> row(int count) {
return new ArrayList<ArrayList<Integer>>() {
{
add(new ArrayList<>() {
{
}
});
add(new ArrayList<>() {
{
add(4);
}
});
add(new ArrayList<>() {
{
add(3);
add(5);
}
});
add(new ArrayList<>() {
{
add(2);
add(4);
add(6);
}
});
add(new ArrayList<>() {
{
add(1);
add(3);
add(5);
add(7);
}
});
add(new ArrayList<>() {
{
add(2);
add(3);
add(4);
add(5);
add(6);
}
});
add(new ArrayList<>() {
{
add(1);
add(2);
add(3);
add(5);
add(6);
add(7);
}
});
add(new ArrayList<>() {
{
add(1);
add(2);
add(3);
add(4);
add(5);
add(6);
add(7);
}
});
add(new ArrayList<>() {
{
add(0);
add(1);
add(2);
add(3);
add(5);
add(6);
add(7);
add(8);
}
});
add(new ArrayList<>() {
{
add(0);
add(1);
add(2);
add(3);
add(4);
add(5);
add(6);
add(7);
add(8);
}
});
}
}.get(count);
}
}