Fixed an issue causing mobs in breed cooldown to stack.

This commit is contained in:
Brianna O'Keefe 2019-03-24 18:32:00 -04:00
parent e5210ef11c
commit 1d16886f8b
3 changed files with 43 additions and 9 deletions

36
.gitignore vendored
View File

@ -198,3 +198,39 @@ target/classes/com/songoda/ultimatestacker/hologram/Hologram\.class
target/classes/com/songoda/ultimatestacker/hologram/HologramArconix\.class
target/classes/com/songoda/ultimatestacker/hologram/HologramHolographicDisplays\.class
\.idea/encodings\.xml
\.idea/libraries/Maven__com_gmail_filoghost_holographicdisplays_holographicdisplays_api_2_3_2\.xml
\.idea/libraries/Maven__com_songoda_arconix_2_0_0\.xml
\.idea/libraries/Maven__net_milkbowl_vault_1_7_1\.xml
target/classes/com/songoda/ultimatestacker/events/InteractListeners\$1\.class
target/classes/com/songoda/ultimatestacker/events/InventoryListeners\.class
target/classes/com/songoda/ultimatestacker/utils/ConfigWrapper\.class
target/classes/com/songoda/ultimatestacker/utils/Metrics\.class
target/classes/com/songoda/ultimatestacker/utils/Metrics\$1\.class
target/classes/com/songoda/ultimatestacker/utils/Metrics\$2\.class
target/classes/com/songoda/ultimatestacker/utils/Metrics\$AdvancedBarChart\.class
target/classes/com/songoda/ultimatestacker/utils/Metrics\$AdvancedPie\.class
target/classes/com/songoda/ultimatestacker/utils/Metrics\$CustomChart\.class
target/classes/com/songoda/ultimatestacker/utils/Metrics\$DrilldownPie\.class
target/classes/com/songoda/ultimatestacker/utils/Metrics\$MultiLineChart\.class
target/classes/com/songoda/ultimatestacker/utils/Metrics\$SimpleBarChart\.class
target/classes/com/songoda/ultimatestacker/utils/Metrics\$SimplePie\.class
target/classes/com/songoda/ultimatestacker/utils/Metrics\$SingleLineChart\.class

View File

@ -32,9 +32,9 @@ public class InteractListeners implements Listener {
@EventHandler
public void onSheepDye(SheepDyeWoolEvent event) {
Entity entity = event.getEntity();
Sheep entity = event.getEntity();
if (!instance.getEntityStackManager().isStacked(entity) || event.getColor() == ((Sheep) entity).getColor()) return;
if (!instance.getEntityStackManager().isStacked(entity) || event.getColor() == entity.getColor()) return;
EntityStack stack = instance.getEntityStackManager().getStack(entity);
if (stack.getAmount() <= 1) return;
@ -42,8 +42,8 @@ public class InteractListeners implements Listener {
entity.setVelocity(getRandomVector());
Sheep sheep = ((Sheep) newEntity);
sheep.setSheared(((Sheep)entity).isSheared());
sheep.setColor(((Sheep)entity).getColor());
sheep.setSheared(entity.isSheared());
sheep.setColor(entity.getColor());
instance.getEntityStackManager().addStack(new EntityStack(newEntity, stack.getAmount() - 1));
stack.setAmount(1);
@ -83,9 +83,7 @@ public class InteractListeners implements Listener {
Sheep sheep = ((Sheep) newEntity);
sheep.setSheared(((Sheep)entity).isSheared());
sheep.setColor(((Sheep)entity).getColor());
}
if (entity instanceof Villager) {
} else if (entity instanceof Villager) {
Villager villager = ((Villager) newEntity);
villager.setProfession(((Villager)entity).getProfession());
}

View File

@ -45,8 +45,7 @@ public class StackingTask extends BukkitRunnable {
}
// Start stacking task.
new StackingTask(instance).runTaskTimer(instance, 0,
instance.getConfig().getInt("Main.Stack Search Tick Speed"));
runTaskTimer(instance, 0, instance.getConfig().getInt("Main.Stack Search Tick Speed"));
}
@Override
@ -119,6 +118,7 @@ public class StackingTask extends BukkitRunnable {
maxEntityStackSize = configurationSection.getInt("Mobs." + initalEntity.getType().name() + ".Max Stack Size");
List<Entity> entityList = Methods.getSimilarEntitesAroundEntity(initalEntity);
entityList.removeIf(entity -> entity.hasMetadata("inLove") || entity.hasMetadata("breedCooldown"));
for (Entity entity : new ArrayList<>(entityList)) {
if (removed.contains(entity.getUniqueId())) continue;