SteamWar/FightSystem
Archiviert
13
1

Not working Waterlogged detection
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Lixfel 2023-09-09 18:43:52 +02:00
Ursprung 3b6cde085d
Commit a309541e7e
2 geänderte Dateien mit 30 neuen und 8 gelöschten Zeilen

Datei anzeigen

@ -37,7 +37,10 @@ import org.bukkit.Note;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.Lectern;
import org.bukkit.block.data.*;
import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.FaceAttachable;
import org.bukkit.block.data.Openable;
import org.bukkit.block.data.Powerable;
import org.bukkit.block.data.type.Comparator;
import org.bukkit.block.data.type.NoteBlock;
import org.bukkit.block.data.type.Repeater;
@ -210,6 +213,11 @@ public abstract class AI {
@Override
public void run() {
Location location = entity.getLocation();
if(!entity.isOnGround() && location.getBlock().getType() != Material.LADDER) {
FightSystem.getPlugin().getLogger().log(Level.INFO, "Entity falling");
return;
}
Location target = translate(pos, false);
if(Math.abs(location.getX() - target.getX()) > 1.0 || Math.abs(location.getY() - target.getY()) > 1.5 || Math.abs(location.getZ() - target.getZ()) > 1.0) {
FightSystem.getPlugin().getLogger().log(Level.INFO, () -> entity.getName() + ": Overdistance movement " + location.toVector() + " " + target.toVector());

Datei anzeigen

@ -20,6 +20,8 @@
package de.steamwar.fightsystem.ai;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.registry.state.BooleanProperty;
import com.sk89q.worldedit.world.block.BaseBlock;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.FightTeam;
@ -30,6 +32,8 @@ import de.steamwar.sql.SteamwarUser;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.Particle;
import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.Waterlogged;
import org.bukkit.scheduler.BukkitTask;
import org.bukkit.util.Vector;
@ -114,9 +118,12 @@ public class LixfelAI extends AI {
}
private void assignWater(Clipboard clipboard) {
BooleanProperty waterlogged = new BooleanProperty("waterlogged", Arrays.asList(false, true));
List<Vector> waterSources = new ArrayList<>();
clipboard.getRegion().forEach(block -> {
if(clipboard.getBlock(block).getBlockType().getMaterial().isLiquid())
BaseBlock state = clipboard.getFullBlock(block);
if(state.getBlockType().getMaterial().isLiquid() || Boolean.TRUE.equals(state.getState(waterlogged)))
waterSources.add(pathplanner.clipboardToSchem(block));
});
@ -179,13 +186,16 @@ public class LixfelAI extends AI {
return true;
List<Vector> path = new ArrayList<>(pathplanner.planToRange(position, new Vector(0, -getEntity().getEyeHeight(), 0).add(target), 5.0));
if(path.isEmpty())
path.add(new Vector(0, 1, 0).add(position));
for(Vector v : path)
Config.world.spawnParticle(Particle.VILLAGER_HAPPY, translate(v, false), 1);
Config.world.spawnParticle(Particle.DRIP_LAVA, translate(v, false), 1);
if(path.isEmpty()) {
move(new Vector(0, 1.2, 0).add(position));
setTNT(position);
} else {
move(path.get(0));
}
move(path.get(0));
return false;
}
@ -222,12 +232,16 @@ public class LixfelAI extends AI {
}
public boolean shoot() {
for(Vector w : water)
Config.world.spawnParticle(Particle.VILLAGER_HAPPY, translate(w, true).add(0.5, 0.5, 0.5), 1);
if(currentTime < freeAt || water.isEmpty())
return true;
if(lastCannonCheck < freeAt) {
Vector w = water.get(random.nextInt(water.size()));
if(getBlock(w) == Material.WATER)
BlockData data = getBlockData(w);
if(data.getMaterial() == Material.WATER || (data instanceof Waterlogged && ((Waterlogged)data).isWaterlogged()))
lastCannonCheck = freeAt;
else
water.remove(w);