This commit is contained in:
Anuken
2021-03-19 14:36:25 -04:00
parent afd6570ced
commit 7ffd46aee9
4 changed files with 11 additions and 10 deletions

View File

@@ -97,9 +97,9 @@ public class PlacementFragment extends Fragment{
scrollPositions.put(currentCategory, blockPane.getScrollY());
if(Core.input.keyTap(Binding.pick) && player.isBuilder()){ //mouse eyedropper select
Building tile = world.buildWorld(Core.input.mouseWorld().x, Core.input.mouseWorld().y);
Block tryRecipe = tile == null ? null : tile instanceof ConstructBuild c ? c.cblock : tile.block;
Object tryConfig = tile == null ? null : tile.config();
var build = world.buildWorld(Core.input.mouseWorld().x, Core.input.mouseWorld().y);
Block tryRecipe = build == null ? null : build instanceof ConstructBuild c ? c.cblock : build.block;
Object tryConfig = build == null || !build.block.copyConfig ? null : build.config();
for(BuildPlan req : player.unit().plans()){
if(!req.breaking && req.block.bounds(req.x, req.y, Tmp.r1).contains(Core.input.mouseWorld())){

View File

@@ -63,6 +63,8 @@ public class Block extends UnlockableContent{
public @Nullable Object lastConfig;
/** whether to save the last config and apply it to newly placed blocks */
public boolean saveConfig = false;
/** whether to allow copying the config through middle click */
public boolean copyConfig = true;
/** whether this block has a tile entity that updates */
public boolean update;
/** whether this block has health and can be destroyed */

View File

@@ -45,6 +45,7 @@ public class ItemBridge extends Block{
unloadable = false;
group = BlockGroup.transportation;
noUpdateDisabled = true;
copyConfig = false;
//point2 config is relative
config(Point2.class, (ItemBridgeBuild tile, Point2 i) -> tile.link = Point2.pack(i.x + tile.tileX(), i.y + tile.tileY()));
@@ -142,7 +143,7 @@ public class ItemBridge extends Block{
public Tile findLink(int x, int y){
Tile tile = world.tile(x, y);
if(tile != null && lastBuild != null && linkValid(tile, lastBuild.tile) && lastBuild.tile != tile){
if(tile != null && lastBuild != null && linkValid(tile, lastBuild.tile) && lastBuild.tile != tile && lastBuild.link == -1){
return lastBuild.tile;
}
return null;
@@ -176,11 +177,9 @@ public class ItemBridge extends Block{
public void playerPlaced(Object config){
super.playerPlaced(config);
if(config == null){
Tile link = findLink(tile.x, tile.y);
if(linkValid(tile, link) && !proximity.contains(link.build)){
link.build.configure(tile.pos());
}
Tile link = findLink(tile.x, tile.y);
if(linkValid(tile, link) && !proximity.contains(link.build)){
link.build.configure(tile.pos());
}
lastBuild = this;