Another fix for falling sand/gravel tracking issues.

This commit is contained in:
GJ 2012-05-27 09:42:26 -04:00
parent d955feef61
commit 433913c77a

View File

@ -73,7 +73,7 @@ public class BlockListener implements Listener {
*/ */
@EventHandler(priority = EventPriority.MONITOR) @EventHandler(priority = EventPriority.MONITOR)
public void onBlockPhysics(BlockPhysicsEvent event) { public void onBlockPhysics(BlockPhysicsEvent event) {
//TODO: Figure out how to REMOVE metadata from the location the sand fell from. //TODO: Figure out how to REMOVE metadata from the location the sand/gravel fell from.
Material type = event.getChangedType(); Material type = event.getChangedType();
if (type == Material.GRAVEL || type == Material.SAND) { if (type == Material.GRAVEL || type == Material.SAND) {
@ -112,11 +112,14 @@ public class BlockListener implements Listener {
Block block = event.getBlock(); Block block = event.getBlock();
Player player = event.getPlayer(); Player player = event.getPlayer();
int id = block.getTypeId(); int id = block.getTypeId();
Material type = block.getType();
/* Check if the blocks placed should be monitored so they do not give out XP in the future */ /* Check if the blocks placed should be monitored so they do not give out XP in the future */
if (BlockChecks.shouldBeWatched(block)) { if (BlockChecks.shouldBeWatched(block)) {
if (!((type == Material.SAND || type == Material.GRAVEL) && block.getRelative(BlockFace.DOWN).getType() == Material.AIR)) { //Don't wanna track sand that's gonna fall.
mcMMO.placeStore.setTrue(block); mcMMO.placeStore.setTrue(block);
} }
}
if (id == configInstance.getRepairAnvilId() && configInstance.getRepairAnvilMessagesEnabled()) { if (id == configInstance.getRepairAnvilId() && configInstance.getRepairAnvilMessagesEnabled()) {
Repair.placedAnvilCheck(player, id); Repair.placedAnvilCheck(player, id);
@ -210,6 +213,23 @@ public class BlockListener implements Listener {
if (mcMMO.placeStore.isTrue(block) && BlockChecks.shouldBeWatched(block)) { if (mcMMO.placeStore.isTrue(block) && BlockChecks.shouldBeWatched(block)) {
mcMMO.placeStore.setFalse(block); mcMMO.placeStore.setFalse(block);
} }
//Remove metadata from fallen sand/gravel
Material aboveType = block.getRelative(BlockFace.UP).getType();
if (aboveType == Material.SAND || aboveType == Material.GRAVEL) {
for (int y = 1; block.getY() + y <= block.getWorld().getHighestBlockYAt(block.getX(), block.getZ()); y++) {
Block relative = block.getRelative(0, y, 0);
Material relativeType = relative.getType();
if ((relativeType == Material.SAND || relativeType == Material.GRAVEL) && mcMMO.placeStore.isTrue(relative)) {
mcMMO.placeStore.setFalse(relative);
}
else {
break;
}
}
}
} }
/** /**