Village siege's spawn location is calculated incorrectly (fix included)
(Slightly related to MC-7432; both bugs are in the same class.)
The code that tries to find a location to bring the zombies "in" to the village creates a random location that is calculated slightly incorrectly. Currently, the zombies can be spawned anywhere in a square area around the village center (including in the center of the village), instead of the intended somewhere along circular perimeter area. (That is, if they could be spawned at all; MC-7432 prevents that currently).
Bugged code
With MCP and my own variable name interpretations:
while (true) { if (tries < 10) { this.siegeSourceHorX = villageCenterChunk.posX + (int) ((double) (MathHelper.cos(this.worldObj.rand.nextFloat() * (float) Math.PI * 2.0F) * villageRadius) * 0.9D); this.siegeSourceVerZ = villageCenterChunk.posY; this.siegeSourceHorY = villageCenterChunk.posZ + (int) ((double) (MathHelper.sin(this.worldObj.rand.nextFloat() * (float) Math.PI * 2.0F) * villageRadius) * 0.9D);
The code is obviously trying to roll a random angle, and calculate the location at that "compass angle" from the village center to the village perimeter. But for that result, the angle for both the trigonometric functions should be the same. In the above code, it rolls a new independent random number for each, and thus they can independently vary between -1 and 1, leaving the target area to be a slightly unevenly distributed square.
Fix
Tested to work, but not 100% tested to work correctly.
while (true) { if (tries < 10) { float angle = this.worldObj.rand.nextFloat() * (float) Math.PI * 2.0F; this.siegeSourceHorX = villageCenterChunk.posX + (int) ((double) (MathHelper.cos(angle) * villageRadius) * 0.9D); this.siegeSourceVerZ = villageCenterChunk.posY; this.siegeSourceHorY = villageCenterChunk.posZ + (int) ((double) (MathHelper.sin(angle) * villageRadius) * 0.9D);
Linked Issues
Created Issue:
Village siege's spawn location is calculated incorrectly
(Slightly related to
MC-7432; both bugs are in the same class.)The code that tries to find a location to bring the zombies "in" to the village creates a random location that is calculated slightly incorrectly. Currently, the zombies can be spawned anywhere in a square area around the village center (including in the center of the village), instead of the intended somewhere along circular perimeter area. (That is, if they could be spawned at all;
MC-7432prevents that currently).Bugged code
With MCP and my own variable name interpretations:VillageSiege.func_75529_b()while (true) { if (tries < 10) { this.siegeSourceHorX = villageCenterChunk.posX + (int) ((double) (MathHelper.cos(this.worldObj.rand.nextFloat() * (float) Math.PI * 2.0F) * villageRadius) * 0.9D); this.siegeSourceVerZ = villageCenterChunk.posY; this.siegeSourceHorY = villageCenterChunk.posZ + (int) ((double) (MathHelper.sin(this.worldObj.rand.nextFloat() * (float) Math.PI * 2.0F) * villageRadius) * 0.9D);The code is obviously trying to roll a random angle, and calculate the location at that "compass angle" from the village center to the village perimeter. But for that result, the angle for both the trigonometric functions should be the same. In the above code, it rolls a new independent random number for each, and thus they can independently vary between -1 and 1, leaving the target area to be a slightly unevenly distributed square.
Fix
Tested to work, but not 100% tested to work correctly.VillageSiege.func_75529_b()while (true) { if (tries < 10) { float angle = this.worldObj.rand.nextFloat() * (float) Math.PI * 2.0F; this.siegeSourceHorX = villageCenterChunk.posX + (int) ((double) (MathHelper.cos(angle) * villageRadius) * 0.9D); this.siegeSourceVerZ = villageCenterChunk.posY; this.siegeSourceHorY = villageCenterChunk.posZ + (int) ((double) (MathHelper.sin(angle) * villageRadius) * 0.9D);
relates to
Village siege's spawn location is calculated incorrectly (fix included)
And I think I just found and fixed another bug in the same class/feature. See MC-7488.
@Cailan And why not. It is a bug, this is the fix. That is what bug forums are for.
Actually if they do fix it, they better fix the bug involving the start point of a zombie siege.
They should start at the edge of the villager radius, not in the middle of the village.
See related bug MC-7488
This is the problem with bucket/spigot servers. They fixed zombie sieges, bit not the siege spawn point.
Yes definitely..
Please fix the related (but not quite the same) bug MC-7488.
Without that bug being fixed as well, zombie sieges can be very annoying, as they can and will spawn in the middle of houses and trading booths.
Thanks Mog for fixing this.
This bug is starting to become very annoying. Currently everyone just accepts this as being 'normal play'. But really it just makes any form of trading village unsafe and impossible to mob proof.
It is time that this bug be properly fixed, especially as the fix is simple enough that it would only take mojang a minute or so to apply it for the next snapshot release.
Actually it also gives village Iron Golems more of a chance to take care of a siege that is (with the bug fix) heading into the village toward the juicy villagers.
I have watched iron golems in a village with large dark areas. They handle quite large hordes (non seige) zombies that are approaching the villagers, quite well.
But Iron golem will not handle a bugged zombie seige that appears in the middle of the village in side the house that the villages are hiding in. I have seen large trading villages decimated by a single siege on bucket servers (siege start bug fixed, but not start location), when a horde appeared inside the building the villagers were piled into.
Beauty Bonsa.... Thanks Mojang... and specifically Mog... for fixing this.
Especially with the zombie seige start fix as well.