summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBillyGalbreath <BillyGalbreath@Hotmail.com>2014-12-17 18:44:34 -0600
committermd_5 <git@md-5.net>2015-02-15 12:16:12 +1100
commit9648edfa6136394153d524fa89c347d86f455641 (patch)
tree3c0515317e76bdb45c23722d27603aedb5725bce /src
parent17a3db767a78d3125ff3d71696e8b492a7ce8de6 (diff)
downloadcraftbukkit-9648edfa6136394153d524fa89c347d86f455641.tar
craftbukkit-9648edfa6136394153d524fa89c347d86f455641.tar.gz
craftbukkit-9648edfa6136394153d524fa89c347d86f455641.tar.lz
craftbukkit-9648edfa6136394153d524fa89c347d86f455641.tar.xz
craftbukkit-9648edfa6136394153d524fa89c347d86f455641.zip
Add alternatives for deprecated methods
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
index 1c1aab10..c4f799de 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
@@ -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);