mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-01 20:50:41 +01:00
Add alternatives for deprecated methods
This commit is contained in:
parent
17a3db767a
commit
9648edfa61
1 changed files with 40 additions and 0 deletions
|
@ -5,6 +5,7 @@ import java.util.Collection;
|
|||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.server.DamageSource;
|
||||
import net.minecraft.server.EntityArmorStand;
|
||||
|
@ -151,19 +152,58 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
|||
return blocks;
|
||||
}
|
||||
|
||||
private List<Block> getLineOfSight(Set<Material> transparent, int maxDistance, int maxLength) {
|
||||
if (maxDistance > 120) {
|
||||
maxDistance = 120;
|
||||
}
|
||||
ArrayList<Block> blocks = new ArrayList<Block>();
|
||||
Iterator<Block> itr = new BlockIterator(this, maxDistance);
|
||||
while (itr.hasNext()) {
|
||||
Block block = itr.next();
|
||||
blocks.add(block);
|
||||
if (maxLength != 0 && blocks.size() > maxLength) {
|
||||
blocks.remove(0);
|
||||
}
|
||||
Material material = block.getType();
|
||||
if (transparent == null) {
|
||||
if (!material.equals(Material.AIR)) {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (!transparent.contains(material)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return blocks;
|
||||
}
|
||||
|
||||
public List<Block> getLineOfSight(HashSet<Byte> transparent, int maxDistance) {
|
||||
return getLineOfSight(transparent, maxDistance, 0);
|
||||
}
|
||||
|
||||
public List<Block> getLineOfSight(Set<Material> transparent, int maxDistance) {
|
||||
return getLineOfSight(transparent, maxDistance, 0);
|
||||
}
|
||||
|
||||
public Block getTargetBlock(HashSet<Byte> transparent, int maxDistance) {
|
||||
List<Block> blocks = getLineOfSight(transparent, maxDistance, 1);
|
||||
return blocks.get(0);
|
||||
}
|
||||
|
||||
public Block getTargetBlock(Set<Material> transparent, int maxDistance) {
|
||||
List<Block> blocks = getLineOfSight(transparent, maxDistance, 1);
|
||||
return blocks.get(0);
|
||||
}
|
||||
|
||||
public List<Block> getLastTwoTargetBlocks(HashSet<Byte> transparent, int maxDistance) {
|
||||
return getLineOfSight(transparent, maxDistance, 2);
|
||||
}
|
||||
|
||||
public List<Block> getLastTwoTargetBlocks(Set<Material> transparent, int maxDistance) {
|
||||
return getLineOfSight(transparent, maxDistance, 2);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public Arrow shootArrow() {
|
||||
return launchProjectile(Arrow.class);
|
||||
|
|
Loading…
Reference in a new issue