geforkt von Mirrors/Paper
Add alternatives for deprecated methods
Dieser Commit ist enthalten in:
Ursprung
17a3db767a
Commit
9648edfa61
@ -5,6 +5,7 @@ import java.util.Collection;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import net.minecraft.server.DamageSource;
|
import net.minecraft.server.DamageSource;
|
||||||
import net.minecraft.server.EntityArmorStand;
|
import net.minecraft.server.EntityArmorStand;
|
||||||
@ -151,19 +152,58 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
|||||||
return blocks;
|
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) {
|
public List<Block> getLineOfSight(HashSet<Byte> transparent, int maxDistance) {
|
||||||
return getLineOfSight(transparent, maxDistance, 0);
|
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) {
|
public Block getTargetBlock(HashSet<Byte> transparent, int maxDistance) {
|
||||||
List<Block> blocks = getLineOfSight(transparent, maxDistance, 1);
|
List<Block> blocks = getLineOfSight(transparent, maxDistance, 1);
|
||||||
return blocks.get(0);
|
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) {
|
public List<Block> getLastTwoTargetBlocks(HashSet<Byte> transparent, int maxDistance) {
|
||||||
return getLineOfSight(transparent, maxDistance, 2);
|
return getLineOfSight(transparent, maxDistance, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Block> getLastTwoTargetBlocks(Set<Material> transparent, int maxDistance) {
|
||||||
|
return getLineOfSight(transparent, maxDistance, 2);
|
||||||
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public Arrow shootArrow() {
|
public Arrow shootArrow() {
|
||||||
return launchProjectile(Arrow.class);
|
return launchProjectile(Arrow.class);
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren