Removed CraftBukkit dependency and update to use new Bukkit API calls

This commit is contained in:
h31ix committed 2012-12-09 20:59:57 -05:00
1 parent e8c05e064f
commit 1f769d9256
2 files changed
+24 -19

No files matched your search

+2 -2
View File
@@ -42,8 +42,8 @@
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.bukkit</groupId> <groupId>org.bukkit</groupId>
<artifactId>craftbukkit</artifactId> <artifactId>bukkit</artifactId>
<version>1.4.5-R0.2</version> <version>1.4.5-R0.3-SNAPSHOT</version>
<type>jar</type> <type>jar</type>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
@@ -34,9 +34,9 @@ import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.craftbukkit.entity.CraftEntity;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerToggleSprintEvent; import org.bukkit.event.player.PlayerToggleSprintEvent;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
@@ -456,8 +456,8 @@ public class Backend
for (int i = 0; i < (Math.round(distance.getYDifference())) + 1; i++) for (int i = 0; i < (Math.round(distance.getYDifference())) + 1; i++)
{ {
Location l = new Location(player.getWorld(), player.getLocation().getX(), to + i, player.getLocation().getZ()); Block block = new Location(player.getWorld(), player.getLocation().getX(), to + i, player.getLocation().getZ()).getBlock();
if (l.getBlock().getTypeId() != 0 && net.minecraft.server.Block.byId[l.getBlock().getTypeId()].material.isSolid() && !l.getBlock().isLiquid()) if (block.getTypeId() != 0 && block.getType().isSolid())
{ {
bs = true; bs = true;
} }
@@ -565,30 +565,35 @@ public class Backend
public boolean checkSight(Player player, Entity entity) public boolean checkSight(Player player, Entity entity)
{ {
// Check to make sure the entity's head is not surrounded if(entity instanceof LivingEntity)
Block head = entity.getWorld().getBlockAt((int) entity.getLocation().getX(), (int) (entity.getLocation().getY() + ((CraftEntity) entity).getHandle().getHeadHeight()), (int) entity.getLocation().getZ());
boolean solid = false;
//TODO: This sucks. See if it's possible to not have as many false-positives while still retaining most of the check.
for (int x = -2; x <= 2; x++)
{ {
for (int z = -2; z <= 2; z++) LivingEntity le = (LivingEntity)entity;
// Check to make sure the entity's head is not surrounded
Block head = le.getWorld().getBlockAt((int) le.getLocation().getX(), (int) (le.getLocation().getY() +le.getEyeHeight()), (int) le.getLocation().getZ());
boolean solid = false;
//TODO: This sucks. See if it's possible to not have as many false-positives while still retaining most of the check.
for (int x = -2; x <= 2; x++)
{ {
for (int y = -1; y < 2; y++) for (int z = -2; z <= 2; z++)
{ {
if (head.getRelative(x, y, z).getTypeId() != 0) for (int y = -1; y < 2; y++)
{ {
if (net.minecraft.server.Block.byId[head.getRelative(x, y, z).getTypeId()].material.isSolid()) if (head.getRelative(x, y, z).getTypeId() != 0)
{ {
solid = true; if (head.getRelative(x, y, z).getType().isSolid())
break; {
} solid = true;
break;
}
}
} }
} }
}
}
return solid ? true : player.hasLineOfSight(le);
} }
return solid ? true : player.hasLineOfSight(entity); return true;
} }
public boolean checkFlight(Player player, Distance distance) public boolean checkFlight(Player player, Distance distance)