Skip to content

Commit

Permalink
added logging to debug when player or itemframe spawns an egg
Browse files Browse the repository at this point in the history
  • Loading branch information
msudol committed Dec 31, 2019
1 parent a3fee6a commit cbed67f
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/com/pwn9/PwnChickenLay/PwnChickenLayItemSpawnListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,20 @@ public void onSpawn(ItemSpawnEvent event)
// if item is anything other than an egg, return
if(is.getType() != Material.EGG) return;

List<Entity> nearby = test.getNearbyEntities(0.1, 0.3, 0.1);
List<Entity> nearby = test.getNearbyEntities(0.01, 0.3, 0.01);

// check if a player entity is at the same location as the ItemSpawnEvent - if so, probably not a chicken lay and return
// do the same with item frame.
for(int i = 0; i < nearby.size(); i++)
{
if (nearby.get(i) instanceof Player) return;
if (nearby.get(i) instanceof ItemFrame) return;
if (nearby.get(i) instanceof Player) {
PwnChickenLay.logToFile("Egg spawn event was from a Player");
return;
}
if (nearby.get(i) instanceof ItemFrame) {
PwnChickenLay.logToFile("Egg spawn event was from an ItemFrame");
return;
}
}

String world = eworld.getName();
Expand Down Expand Up @@ -162,7 +168,7 @@ else if (PwnChickenLay.random(PwnChickenLay.layChance))
// log if debug_log is enabled
if (PwnChickenLay.logEnabled)
{
PwnChickenLay.logToFile("Chicken laid: Default egg, in world: " + world);
PwnChickenLay.logToFile("Chicken laid: Default egg, in world: " + world + " Location: " + eLoc.getBlockX() + ", " + eLoc.getBlockY() + ", " + eLoc.getBlockZ());
}
}

Expand Down Expand Up @@ -203,8 +209,8 @@ public void doReplacement(World eworld, Location eLoc, String randomReplacement

for (String key : getSpecialEnchants.keySet())
{
// deprecated - specialEnchants.put(Enchantment.getByName(key), (Integer) getSpecialEnchants.get(key));
specialEnchants.put(Enchantment.getByKey(NamespacedKey.minecraft(key)), (Integer) getSpecialEnchants.get(key));
specialEnchants.put(Enchantment.getByName(key), (Integer) getSpecialEnchants.get(key));
//the above is deprecated, this is supposed to work but doesnt - specialEnchants.put(Enchantment.getByKey(NamespacedKey.minecraft(key)), (Integer) getSpecialEnchants.get(key));
}
}

Expand Down Expand Up @@ -263,7 +269,7 @@ else if ((Material.getMaterial(randomReplacement) != Material.AIR) && (Material.
// log if debug_log is enabled
if (PwnChickenLay.logEnabled)
{
PwnChickenLay.logToFile("Chicken laid: " + randomReplacement + " in world: " + world);
PwnChickenLay.logToFile("Chicken laid: " + randomReplacement + " in world: " + world + " Location: " + eLoc.getBlockX() + ", " + eLoc.getBlockY() + ", " + eLoc.getBlockZ());
}

}
Expand Down

0 comments on commit cbed67f

Please sign in to comment.