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,38 +197,83 @@ 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) {
if (mcMMO.getPlaceStore().isTrue(block)) {
mcMMO.getPlaceStore().setFalse(block); mcMMO.getPlaceStore().setFalse(block);
}
}
}
/** entity.setMetadata(mcMMO.travelingBlock, mcMMO.metadataValue);
* This is a complex hack to track blocks for this event }
* This event is called when a block starts its movement, or ends its movement else if (isTracked) {
* It can start the movement through physics (falling blocks) or through being picked up (endermen)
* Since this event can be cancelled, its even weirder to track this stuff
* @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
*/
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); mcMMO.getPlaceStore().setTrue(block);
movementSourceEntity.removeMetadata(mcMMO.travelingBlock, pluginRef); }
} else { } else if ((block.getType() == Material.REDSTONE_ORE)) {
//A block that is starting movement (from either Endermen or Falling/Physics) }
else {
if (mcMMO.getPlaceStore().isTrue(block)) { if (mcMMO.getPlaceStore().isTrue(block)) {
mcMMO.getPlaceStore().setFalse(block); mcMMO.getPlaceStore().setFalse(block);
movementSourceEntity.setMetadata(mcMMO.blockMetadataKey, mcMMO.metadataValue);
} }
} }
} }
// /**
// * Monitor EntityChangeBlock events.
// *
// * @param event
// * The event to watch
// */
// @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
// public void onEntityChangeBlock(EntityChangeBlockEvent event) {
// /* 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);
// }
// }
// }
// /**
// * This is a complex hack to track blocks for this event
// * 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)
// * Since this event can be cancelled, its even weirder to track this stuff
// * @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
// */
// 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) {
//Prevent players from setting fire to each other if they are in the same party //Prevent players from setting fire to each other if they are in the same party