Revert this change for now

This commit is contained in:
nossr50 2020-10-08 19:07:42 -07:00
parent f5294387b0
commit 80c89fe1e5
2 changed files with 69 additions and 25 deletions

View File

@ -19,7 +19,6 @@ Version 2.1.148
COTW spawned mobs are tracked persistently and are no longer forgotten about after a restart COTW spawned mobs are tracked persistently and are no longer forgotten about after a restart
Player bred mobs are tracked persistently and are no longer forgotten about after a restart Player bred mobs are tracked persistently and are no longer forgotten about after a restart
NOTES: NOTES:
Egg mobs & Nether portal pigs being assigned to the mobspawner xp multiplier didn't make sense to me, so it has been changed. They have their own XP multipliers now. Egg mobs & Nether portal pigs being assigned to the mobspawner xp multiplier didn't make sense to me, so it has been changed. They have their own XP multipliers now.
While working on making data persistent I stumbled upon some alarming memory leak candidates, one of them was 7 years old. Sigh. While working on making data persistent I stumbled upon some alarming memory leak candidates, one of them was 7 years old. Sigh.

View File

@ -197,37 +197,82 @@ public class EntityListener implements Listener {
Entity entity = event.getEntity(); Entity entity = event.getEntity();
if (entity instanceof FallingBlock || entity instanceof Enderman) { if (entity instanceof FallingBlock || entity instanceof Enderman) {
trackMovingBlocks(block, entity); //ignore the IDE warning boolean isTracked = entity.hasMetadata(mcMMO.travelingBlock);
//Apparently redstone ore will throw these events
} else if ((block.getType() != Material.REDSTONE_ORE)) { if (mcMMO.getPlaceStore().isTrue(block) && !isTracked) {
mcMMO.getPlaceStore().setFalse(block);
entity.setMetadata(mcMMO.travelingBlock, mcMMO.metadataValue);
}
else if (isTracked) {
mcMMO.getPlaceStore().setTrue(block);
}
} else if ((block.getType() == Material.REDSTONE_ORE)) {
}
else {
if (mcMMO.getPlaceStore().isTrue(block)) { if (mcMMO.getPlaceStore().isTrue(block)) {
mcMMO.getPlaceStore().setFalse(block); mcMMO.getPlaceStore().setFalse(block);
} }
} }
} }
/** // /**
* This is a complex hack to track blocks for this event // * Monitor EntityChangeBlock events.
* This event is called when a block starts its movement, or ends its movement // *
* It can start the movement through physics (falling blocks) or through being picked up (endermen) // * @param event
* Since this event can be cancelled, its even weirder to track this stuff // * The event to watch
* @param block this will either be the block that was originally picked up, or the block in its final destination // */
* @param movementSourceEntity this will either be an Endermen or a Falling Block // @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
*/ // public void onEntityChangeBlock(EntityChangeBlockEvent event) {
private void trackMovingBlocks(@NotNull Block block, @NotNull Entity movementSourceEntity) { // /* WORLD BLACKLIST CHECK */
// if(WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
// return;
//
// Block block = event.getBlock();
//
// // When the event is fired for the falling block that changes back to a
// // normal block
// // event.getBlock().getType() returns AIR
// if (!BlockUtils.shouldBeWatched(block.getState())
// && block.getState().getType() != Material.WATER
// && block.getType() != Material.AIR) {
// return;
// }
//
// Entity entity = event.getEntity();
//
// if (entity instanceof FallingBlock || entity instanceof Enderman) {
// trackMovingBlocks(block, entity); //ignore the IDE warning
// //Apparently redstone ore will throw these events
// } else if ((block.getType() != Material.REDSTONE_ORE)) {
// if (mcMMO.getPlaceStore().isTrue(block)) {
// mcMMO.getPlaceStore().setFalse(block);
// }
// }
// }
//A block that has reached its destination, either being placed by endermen or having finished its fall // /**
if(movementSourceEntity.hasMetadata(mcMMO.travelingBlock)) { // * This is a complex hack to track blocks for this event
mcMMO.getPlaceStore().setTrue(block); // * This event is called when a block starts its movement, or ends its movement
movementSourceEntity.removeMetadata(mcMMO.travelingBlock, pluginRef); // * It can start the movement through physics (falling blocks) or through being picked up (endermen)
} else { // * Since this event can be cancelled, its even weirder to track this stuff
//A block that is starting movement (from either Endermen or Falling/Physics) // * @param block this will either be the block that was originally picked up, or the block in its final destination
if(mcMMO.getPlaceStore().isTrue(block)) { // * @param movementSourceEntity this will either be an Endermen or a Falling Block
mcMMO.getPlaceStore().setFalse(block); // */
movementSourceEntity.setMetadata(mcMMO.blockMetadataKey, mcMMO.metadataValue); // private void trackMovingBlocks(@NotNull Block block, @NotNull Entity movementSourceEntity) {
} //
} // //A block that has reached its destination, either being placed by endermen or having finished its fall
} // if(movementSourceEntity.hasMetadata(mcMMO.travelingBlock)) {
// mcMMO.getPlaceStore().setTrue(block);
// movementSourceEntity.removeMetadata(mcMMO.travelingBlock, pluginRef);
// } else {
// //A block that is starting movement (from either Endermen or Falling/Physics)
// if(mcMMO.getPlaceStore().isTrue(block)) {
// mcMMO.getPlaceStore().setFalse(block);
// movementSourceEntity.setMetadata(mcMMO.blockMetadataKey, mcMMO.metadataValue);
// }
// }
// }
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onEntityCombustByEntityEvent(EntityCombustByEntityEvent event) { public void onEntityCombustByEntityEvent(EntityCombustByEntityEvent event) {