Schematic tweaks and improvements

This commit is contained in:
Anuken
2020-03-04 19:21:40 -05:00
parent 3eea0ea065
commit c02c00cdfb
7 changed files with 35 additions and 21 deletions

View File

@@ -41,7 +41,9 @@ public class ItemBridge extends Block{
group = BlockGroup.transportation;
entityType = ItemBridgeEntity::new;
config(Point2.class, (tile, i) -> tile.<ItemBridgeEntity>ent().link = i.pack());
//point2 config is relative
config(Point2.class, (tile, i) -> tile.<ItemBridgeEntity>ent().link = Point2.pack(i.x + tile.x, i.y + tile.y));
//integer is not
config(Integer.class, (tile, i) -> tile.<ItemBridgeEntity>ent().link = i);
}
@@ -58,7 +60,7 @@ public class ItemBridge extends Block{
public void drawRequestConfigTop(BuildRequest req, Eachable<BuildRequest> list){
otherReq = null;
list.each(other -> {
if(other.block == this && req.config instanceof Point2 && ((Point2)req.config).equals(other.x, other.y)){
if(other.block == this && req != other && req.config instanceof Point2 && ((Point2)req.config).equals(other.x - req.x, other.y - req.y)){
otherReq = other;
}
});
@@ -367,7 +369,7 @@ public class ItemBridge extends Block{
@Override
public Point2 config(){
return Point2.unpack(link);
return Point2.unpack(link).sub(tile.x, tile.y);
}
@Override

View File

@@ -42,7 +42,8 @@ public class MassDriver extends Block{
outlineIcon = true;
entityType = MassDriverEntity::new;
config(Point2.class, (tile, point) -> tile.<MassDriverEntity>ent().link = point.pack());
//point2 is relative
config(Point2.class, (tile, point) -> tile.<MassDriverEntity>ent().link = Point2.pack(point.x + tile.x, point.y + tile.y));
config(Integer.class, (tile, point) -> tile.<MassDriverEntity>ent().link = point);
}
@@ -325,7 +326,7 @@ public class MassDriver extends Block{
@Override
public Point2 config(){
return Point2.unpack(link);
return Point2.unpack(link).sub(tile.x, tile.y);
}
@Override

View File

@@ -80,7 +80,9 @@ public class PowerNode extends PowerBlock{
config(Point2[].class, (tile, value) -> {
tile.entity.power().links.clear();
for(Point2 p : value){
tile.entity.power().links.add(p.pack());
if(tile.entity.power().links.size < maxNodes){
tile.entity.power().links.add(Point2.pack(p.x + tile.x, p.y + tile.y));
}
}
});
}
@@ -295,8 +297,7 @@ public class PowerNode extends PowerBlock{
for(Point2 point : (Point2[])req.config){
otherReq = null;
list.each(other -> {
if(other.x == point.x && other.y == point.y){
Log.info("found match " + other);
if((other.x == req.x + point.x && other.y == req.y + point.y) && other != req){
otherReq = other;
}
});
@@ -396,7 +397,7 @@ public class PowerNode extends PowerBlock{
public Point2[] config(){
Point2[] out = new Point2[power.links.size];
for(int i = 0; i < out.length; i++){
out[i] = Point2.unpack(power.links.get(i));
out[i] = Point2.unpack(power.links.get(i)).sub(tile.x, tile.y);
}
return out;
}