Skip to content

Commit

Permalink
Revert "Magnet: convert scanForInventoryBlocks to native code (use ti…
Browse files Browse the repository at this point in the history
…le entities) #441"

This reverts commit 805e687.
  • Loading branch information
Hidendra committed Feb 1, 2013
1 parent 86ed63d commit 25cb2a3
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions src/main/java/com/griefcraft/modules/flag/MagnetModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
import org.bukkit.Server;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Item;
import org.bukkit.inventory.InventoryHolder;
Expand Down Expand Up @@ -253,23 +252,21 @@ private List<Block> scanForInventoryBlocks(Location location, int radius) {
int baseX = location.getBlockX();
int baseY = location.getBlockY();
int baseZ = location.getBlockZ();
World world = location.getWorld();

// native handle
net.minecraft.server.WorldServer worldHandle = ((CraftWorld) world).getHandle();
for (int x = baseX - radius; x < baseX + radius; x++) {
for (int y = baseY - radius; y < baseY + radius; y++) {
for (int z = baseZ - radius; z < baseZ + radius; z++) {
Block block = location.getWorld().getBlockAt(x, y, z);

List<net.minecraft.server.TileEntity> entities = (List<net.minecraft.server.TileEntity>) worldHandle.getTileEntities(baseX - radius, baseY - radius, baseZ - radius, baseX + radius, baseY + radius, baseZ + radius);

for (net.minecraft.server.TileEntity entity : entities) {
Block block = world.getBlockAt(entity.x, entity.y, entity.z);

try {
if (block.getState() instanceof InventoryHolder) {
found.add(block);
try {
if (block.getState() instanceof InventoryHolder) {
found.add(block);
}
} catch (NullPointerException e) {
LWC lwc = LWC.getInstance();
lwc.log("Possibly invalid block found at [" + x + ", " + y + ", " + z + "]!");
}
}
} catch (NullPointerException e) {
LWC lwc = LWC.getInstance();
lwc.log("Possibly invalid block found at [" + entity.x + ", " + entity.y + ", " + entity.z + "]!");
}
}

Expand Down

0 comments on commit 25cb2a3

Please sign in to comment.