Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-17 05:20:05 +01:00
Revert "Added callback line of sight methods. Thanks xZise!"
This reverts commit 49cf586f969626bdb59632bb2fd5adfe79d38057.
Dieser Commit ist enthalten in:
Ursprung
11b388ff39
Commit
9177c205b4
@ -18,7 +18,6 @@ import org.bukkit.entity.LivingEntity;
|
|||||||
import org.bukkit.entity.Snowball;
|
import org.bukkit.entity.Snowball;
|
||||||
import org.bukkit.entity.Vehicle;
|
import org.bukkit.entity.Vehicle;
|
||||||
import org.bukkit.util.BlockIterator;
|
import org.bukkit.util.BlockIterator;
|
||||||
import org.bukkit.util.Callback;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@ -87,45 +86,6 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
|||||||
return getEyeHeight();
|
return getEyeHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Block> getLineOfSight(Callback<Boolean, Block> callback, int maxDistance, int maxLength) {
|
|
||||||
if (maxDistance > 120) {
|
|
||||||
maxDistance = 120;
|
|
||||||
}
|
|
||||||
ArrayList<Block> blocks = new ArrayList<Block>(maxLength == 0 ? 10 : maxLength);
|
|
||||||
Iterator<Block> itr = new BlockIterator(this, maxDistance);
|
|
||||||
while (itr.hasNext()) {
|
|
||||||
Block block = itr.next();
|
|
||||||
if (maxLength != 0 && blocks.size() + 1 > maxLength) {
|
|
||||||
blocks.remove(0);
|
|
||||||
}
|
|
||||||
blocks.add(block);
|
|
||||||
if (callback == null) {
|
|
||||||
if (block.getTypeId() != 0) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Boolean result = callback.call(block);
|
|
||||||
if (result != null && !result) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return blocks;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Block> getLineOfSight(Callback<Boolean, Block> callback, int maxDistance) {
|
|
||||||
return getLineOfSight(callback, maxDistance, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Block getTargetBlock(Callback<Boolean, Block> callback, int maxDistance) {
|
|
||||||
List<Block> blocks = getLineOfSight(callback, maxDistance, 1);
|
|
||||||
return blocks.get(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Block> getLastTwoTargetBlocks(Callback<Boolean, Block> callback, int maxDistance) {
|
|
||||||
return getLineOfSight(callback, maxDistance, 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<Block> getLineOfSight(HashSet<Byte> transparent, int maxDistance, int maxLength) {
|
private List<Block> getLineOfSight(HashSet<Byte> transparent, int maxDistance, int maxLength) {
|
||||||
if (maxDistance > 120) {
|
if (maxDistance > 120) {
|
||||||
maxDistance = 120;
|
maxDistance = 120;
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren