Skip to content

Commit

Permalink
Fixed reconstructor commanding in multiplayer
Browse files Browse the repository at this point in the history
  • Loading branch information
Anuken committed Jun 17, 2023
1 parent 6ed336a commit 7051675
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
4 changes: 4 additions & 0 deletions core/src/mindustry/io/TypeIO.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ public static void writeObject(Writes write, Object object){
for(Object obj : objs){
writeObject(write, obj);
}
}else if(object instanceof UnitCommand command){
write.b(23);
write.s(command.id);
}else{
throw new IllegalArgumentException("Unknown object type: " + object.getClass());
}
Expand Down Expand Up @@ -200,6 +203,7 @@ public static Object readObjectBoxed(Reads read, boolean box){
for(int i = 0; i < objlen; i++) objs[i] = readObjectBoxed(read, box);
yield objs;
}
case 23 -> UnitCommand.all.get(read.us());
default -> throw new IllegalArgumentException("Unknown object type: " + type);
};
}
Expand Down
5 changes: 5 additions & 0 deletions core/src/mindustry/world/Block.java
Original file line number Diff line number Diff line change
Expand Up @@ -890,6 +890,11 @@ public void placeBegan(Tile tile, Block previous){

}

/** Called when building of this block begins. */
public void placeBegan(Tile tile, Block previous, @Nullable Unit builder){
placeBegan(tile, previous);
}

/** Called right before building of this block begins. */
public void beforePlaceBegan(Tile tile, Block previous){

Expand Down
4 changes: 2 additions & 2 deletions core/src/mindustry/world/Build.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ public static void beginPlace(@Nullable Unit unit, Block result, Team team, int
build.prevBuild = prevBuild;
if(unit != null && unit.getControllerName() != null) build.lastAccessed = unit.getControllerName();

result.placeBegan(tile, previous);

Events.fire(new BlockBuildBeginEvent(tile, team, unit, false));

result.placeBegan(tile, previous, unit);
}

/** Returns whether a tile can be placed at this location by this team. */
Expand Down
4 changes: 3 additions & 1 deletion core/src/mindustry/world/blocks/storage/CoreBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public boolean canPlaceOn(Tile tile, Team team, int rotation){
}

@Override
public void placeBegan(Tile tile, Block previous){
public void placeBegan(Tile tile, Block previous, Unit builder){
//finish placement immediately when a block is replaced.
if(previous instanceof CoreBlock){
tile.setBlock(this, tile.team());
Expand All @@ -181,6 +181,8 @@ public void placeBegan(Tile tile, Block previous){

nextItems = null;
}

Events.fire(new BlockBuildEndEvent(tile, builder, tile.team(), false, null));
}
}

Expand Down

0 comments on commit 7051675

Please sign in to comment.