Fixed #8795
This commit is contained in:
@@ -364,13 +364,19 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
|||||||
|
|
||||||
@Remote(targets = Loc.both, called = Loc.server)
|
@Remote(targets = Loc.both, called = Loc.server)
|
||||||
public static void requestBuildPayload(Player player, Building build){
|
public static void requestBuildPayload(Player player, Building build){
|
||||||
if(player == null || !(player.unit() instanceof Payloadc pay)) return;
|
if(player == null || !(player.unit() instanceof Payloadc pay) || build == null) return;
|
||||||
|
|
||||||
Unit unit = player.unit();
|
Unit unit = player.unit();
|
||||||
|
|
||||||
if(build != null && state.teams.canInteract(unit.team, build.team)
|
if(!unit.within(build, tilesize * build.block.size * 1.2f + tilesize * 5f)) return;
|
||||||
&& unit.within(build, tilesize * build.block.size * 1.2f + tilesize * 5f)){
|
|
||||||
|
|
||||||
|
if(net.server() && !netServer.admins.allowAction(player, ActionType.pickupBlock, build.tile, action -> {
|
||||||
|
action.unit = unit;
|
||||||
|
})){
|
||||||
|
throw new ValidateException(player, "Player cannot pick up a block.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(state.teams.canInteract(unit.team, build.team)){
|
||||||
//pick up block's payload
|
//pick up block's payload
|
||||||
Payload current = build.getPayload();
|
Payload current = build.getPayload();
|
||||||
if(current != null && pay.canPickupPayload(current)){
|
if(current != null && pay.canPickupPayload(current)){
|
||||||
@@ -424,6 +430,14 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
|||||||
|
|
||||||
Payloadc pay = (Payloadc)player.unit();
|
Payloadc pay = (Payloadc)player.unit();
|
||||||
|
|
||||||
|
if(pay.payloads().isEmpty()) return;
|
||||||
|
|
||||||
|
if(net.server() && !netServer.admins.allowAction(player, ActionType.dropPayload, player.unit().tileOn(), action -> {
|
||||||
|
action.payload = pay.payloads().peek();
|
||||||
|
})){
|
||||||
|
throw new ValidateException(player, "Player cannot drop a payload.");
|
||||||
|
}
|
||||||
|
|
||||||
//apply margin of error
|
//apply margin of error
|
||||||
Tmp.v1.set(x, y).sub(pay).limit(tilesize * 4f).add(pay);
|
Tmp.v1.set(x, y).sub(pay).limit(tilesize * 4f).add(pay);
|
||||||
float cx = Tmp.v1.x, cy = Tmp.v1.y;
|
float cx = Tmp.v1.x, cy = Tmp.v1.y;
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import mindustry.*;
|
|||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
import mindustry.world.*;
|
import mindustry.world.*;
|
||||||
|
import mindustry.world.blocks.payloads.*;
|
||||||
|
|
||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
import static mindustry.game.EventType.*;
|
import static mindustry.game.EventType.*;
|
||||||
@@ -659,6 +660,9 @@ public class Administration{
|
|||||||
/** valid for unit-type events only, and even in that case may be null. */
|
/** valid for unit-type events only, and even in that case may be null. */
|
||||||
public @Nullable Unit unit;
|
public @Nullable Unit unit;
|
||||||
|
|
||||||
|
/** valid only for payload events */
|
||||||
|
public @Nullable Payload payload;
|
||||||
|
|
||||||
/** valid only for removePlanned events only; contains packed positions. */
|
/** valid only for removePlanned events only; contains packed positions. */
|
||||||
public @Nullable int[] plans;
|
public @Nullable int[] plans;
|
||||||
|
|
||||||
@@ -697,7 +701,7 @@ public class Administration{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public enum ActionType{
|
public enum ActionType{
|
||||||
breakBlock, placeBlock, rotate, configure, withdrawItem, depositItem, control, buildSelect, command, removePlanned, commandUnits, commandBuilding, respawn
|
breakBlock, placeBlock, rotate, configure, withdrawItem, depositItem, control, buildSelect, command, removePlanned, commandUnits, commandBuilding, respawn, pickupBlock, dropPayload
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user