Add CArea, RInteractionCallback

Add DynamicRegionEditor, DynamicRegionVisualizer
This commit is contained in:
2026-08-13 17:42:20 +02:00
parent 87c8e3f875
commit c47d950f2e
23 changed files with 597 additions and 344 deletions
@@ -0,0 +1,83 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2026 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.entity;
import org.bukkit.Location;
import org.bukkit.block.data.BlockData;
import org.bukkit.util.Vector;
import java.util.List;
public class CArea extends CEntity {
public static final float DEFAULT_WIDTH = 1 / 16f;
private Location pos1;
private Location pos2;
private float width = DEFAULT_WIDTH;
public CArea(REntityServer server) {
super(server);
for (int i = 0; i < 4; i++) {
entities.add(new CLine(server));
}
}
public CArea setPos1And2(Location pos1, Location pos2) {
if (pos1.getY() != pos2.getY()) return this;
this.pos1 = pos1;
this.pos2 = pos2;
updateAndSpawnLines();
return this;
}
public CArea setWidth(float width) {
this.width = width;
updateAndSpawnLines();
getEntitiesByType(CLine.class).forEach(haaLine -> {
haaLine.setWidth(width);
});
return this;
}
public CArea setBlock(BlockData blockData) {
getEntitiesByType(CLine.class).forEach(haaLine -> {
haaLine.setBlock(blockData);
});
return this;
}
private void updateAndSpawnLines() {
List<CLine> lines = getEntitiesByType(CLine.class);
if (pos1 == null || pos2 == null) {
lines.forEach(line -> line.setFromAndTo(null, null));
return;
}
Vector min = Vector.getMinimum(pos1.toVector(), pos2.toVector());
Vector max = Vector.getMaximum(pos1.toVector(), pos2.toVector())
.add(new Vector(1 - width, 0, 1 - width));
lines.get(0).setFromAndTo(new Location(null, min.getX(), min.getY(), min.getZ()), new Location(null, max.getX() + width, min.getY(), min.getZ()));
lines.get(1).setFromAndTo(new Location(null, min.getX(), min.getY(), max.getZ()), new Location(null, max.getX() + width, min.getY(), max.getZ()));
lines.get(2).setFromAndTo(new Location(null, min.getX(), min.getY(), min.getZ()), new Location(null, min.getX(), min.getY(), max.getZ() + width));
lines.get(3).setFromAndTo(new Location(null, max.getX(), min.getY(), min.getZ()), new Location(null, max.getX(), min.getY(), max.getZ() + width));
}
}
@@ -0,0 +1,26 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2026 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.entity;
import org.bukkit.entity.Player;
public interface RInteractionCallback {
void call(Player player, RInteraction interaction, REntityServer.EntityAction entityAction);
}