add vis_claim command
All checks were successful
/ Auto-Build-App (push) Successful in 1m47s

This commit is contained in:
pietru 2025-04-28 22:11:00 +02:00
parent a6fd82b57e
commit 807ffa76a1
2 changed files with 69 additions and 0 deletions

View file

@ -39,6 +39,7 @@ public class TextCommands {
commands.put("my_id",new my_id_command());
commands.put("my_name",new my_name_command());
commands.put("my_area",new my_area_command());
commands.put("vis_claim",new vis_area_claim_command());
commands.put("my_claims",new my_claims_command());
commands.put("setup",new setup_command());
commands.put("region",new region_command());

View file

@ -0,0 +1,68 @@
package net.pietru.cookie_utils.commands.my_cmds;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.math.Vector3;
import com.badlogic.gdx.math.collision.BoundingBox;
import finalforeach.cosmicreach.entities.player.Player;
import finalforeach.cosmicreach.networking.NetworkIdentity;
import finalforeach.cosmicreach.networking.packets.MessagePacket;
import finalforeach.cosmicreach.networking.server.ServerSingletons;
import finalforeach.cosmicreach.particles.GameParticleSystem;
import io.netty.channel.ChannelHandlerContext;
import net.pietru.cookie_utils.api.Area;
import net.pietru.cookie_utils.commands.BaseCommand;
import net.pietru.cookie_utils.utils.ParticleUtil;
import static net.pietru.cookie_utils.api.Region.get_area_at_pos;
import static net.pietru.cookie_utils.utils.block_util.isInt;
public class vis_area_claim_command extends BaseCommand {
@Override
public String get_command_key() {
return "vis_claim";
}
@Override
public void accept(String[] args, NetworkIdentity networkIdentity, ChannelHandlerContext ctx) {
Player plr = ServerSingletons.getPlayer(networkIdentity);
Area area = get_area_at_pos(plr.getPosition(), plr.getZone());
int xp = (int)plr.getPosition().x;
int yp = (int)plr.getPosition().y;
int zp = (int)plr.getPosition().z;
String size_txt = "15";
if (args.length >= 2) {
size_txt=args[1];
}
int size = isInt(size_txt) ? Math.max(Math.min(Integer.parseInt(size_txt), 15), 2) : 15;
Vector3 ca = new Vector3(xp - size, yp - size, zp - size);
Vector3 cb = new Vector3(xp + size, yp + size, zp + size);
BoundingBox bb = new BoundingBox(ca,cb);
GameParticleSystem system = GameParticleSystem.laserParticleSystem.copy();
system.startColor.set(Color.YELLOW);
system.duration = 20.0F;
Vector3 m = new Vector3(.5f,.5f,.5f);
for (int x = (int) bb.min.x; x<=bb.max.x; x++){
ParticleUtil.send_particle(x, (int) bb.min.y, (int) bb.min.z,system,ctx,m);
ParticleUtil.send_particle(x, (int) bb.max.y, (int) bb.min.z,system,ctx,m);
ParticleUtil.send_particle(x, (int) bb.min.y, (int) bb.max.z,system,ctx,m);
ParticleUtil.send_particle(x, (int) bb.max.y, (int) bb.max.z,system,ctx,m);
}
for (int y = (int) bb.min.y; y<=bb.max.y; y++){
ParticleUtil.send_particle((int) bb.min.x,y, (int) bb.min.z,system,ctx,m);
ParticleUtil.send_particle((int) bb.max.x,y, (int) bb.min.z,system,ctx,m);
ParticleUtil.send_particle((int) bb.min.x,y, (int) bb.max.z,system,ctx,m);
ParticleUtil.send_particle((int) bb.max.x,y, (int) bb.max.z,system,ctx,m);
}
for (int z = (int) bb.min.z; z<=bb.max.z; z++){
ParticleUtil.send_particle((int) bb.min.x, (int) bb.min.y,z,system,ctx,m);
ParticleUtil.send_particle((int) bb.max.x, (int) bb.min.y,z,system,ctx,m);
ParticleUtil.send_particle((int) bb.min.x, (int) bb.max.y,z,system,ctx,m);
ParticleUtil.send_particle((int) bb.max.x, (int) bb.max.y,z,system,ctx,m);
}
}
}