<!-- 
RSS generated by JIRA (9.12.2#9120002-sha1:301bf498dd45d800842af0b84230f1bb58606c13) at Sun Jan 12 12:22:43 UTC 2025

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary append 'field=key&field=summary' to the URL of your request.
-->
<rss version="0.92" >
<channel>
    <title>Mojang Studios Jira</title>
    <link>https://bugs.mojang.com</link>
    <description>This file is an XML representation of an issue</description>
    <language>en</language>    <build-info>
        <version>9.12.2</version>
        <build-number>9120002</build-number>
        <build-date>10-01-2024</build-date>
    </build-info>


<item>
            <title>[MC-9935] EntityAIAvoidEntity Interference</title>
                <link>https://bugs.mojang.com/browse/MC-9935</link>
                <project id="10400" key="MC">Minecraft: Java Edition</project>
                    <description>&lt;p&gt;Creeper doesn&apos;t react at the Cat if there is another Cat (not visible for Creeper) within 3 blocks below it.&lt;/p&gt;

&lt;p&gt;Most likely Creeper checks Cat presence starting from below coordinates and getting locked at first found Cat.&lt;/p&gt;

&lt;p&gt;At the first screenshot, 2nd and 3rd floor Creepers doesn&apos;t react at their Cat unless you kill Cat below.&lt;/p&gt;

&lt;p&gt;At the second screenshot all Creepers act properly.&lt;/p&gt;</description>
                <environment></environment>
        <key id="23705">MC-9935</key>
            <summary>EntityAIAvoidEntity Interference</summary>
                <type id="1" iconUrl="https://bugs.mojang.com/secure/viewavatar?size=xsmall&amp;avatarId=18903&amp;avatarType=issuetype">Bug</type>
                                    <status id="5" iconUrl="https://bugs.mojang.com/images/icons/statuses/resolved.png" description="A resolution has been taken, and it is awaiting verification by reporter. From here issues are either reopened, or are closed.">Resolved</status>
                    <statusCategory id="3" key="done" colorName="success"/>
                                    <resolution id="1">Fixed</resolution>
                                        <assignee username="dinnerbone">[Mojang] Nathan Adams</assignee>
                                    <reporter username="mt.andi">MTandi</reporter>
                        <labels>
                    </labels>
                <created>Sun, 17 Feb 2013 15:50:47 +0100</created>
                <updated>Tue, 19 Feb 2013 09:26:41 +0100</updated>
                            <resolved>Tue, 19 Feb 2013 09:26:41 +0100</resolved>
                                    <version>Snapshot 13w07a</version>
                                    <fixVersion>Snapshot 13w09a</fixVersion>
                                                        <votes>1</votes>
                                    <watches>2</watches>
                                                                            <comments>
                            <comment id="46535" author="mt.andi" created="Tue, 19 Feb 2013 08:04:17 +0100"  >&lt;p&gt;From your explanation all Entities that use this class have the same bug, so I updated the title and added example with Villagers and Zombies.&lt;/p&gt;</comment>
                            <comment id="46264" author="bugi74" created="Sun, 17 Feb 2013 17:46:10 +0100"  >&lt;p&gt;&lt;b&gt;An inelegant but working fix&lt;/b&gt;&lt;/p&gt;
&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeHeader panelHeader&quot; style=&quot;border-bottom-width: 1px;&quot;&gt;&lt;b&gt;EntityAIAvoidEntity.shouldExecute()&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;    ...
    List entities = &lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;.theEntity.worldObj.getEntitiesWithinAABB(&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;.targetEntityClass, &lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;.theEntity.boundingBox.expand((&lt;span class=&quot;code-object&quot;&gt;double&lt;/span&gt;) &lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;.distanceFromEntity, 3.0D, (&lt;span class=&quot;code-object&quot;&gt;double&lt;/span&gt;) &lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;.distanceFromEntity));

    &lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt; (entities.isEmpty()) {
        &lt;span class=&quot;code-keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;code-keyword&quot;&gt;false&lt;/span&gt;;
    }

    &lt;span class=&quot;code-comment&quot;&gt;//&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;.closestLivingEntity = (Entity) entities.get(0); // OLD CODE
&lt;/span&gt;    &lt;span class=&quot;code-comment&quot;&gt;// FIX:
&lt;/span&gt;    Entity nearest = &lt;span class=&quot;code-keyword&quot;&gt;null&lt;/span&gt;;
    &lt;span class=&quot;code-object&quot;&gt;double&lt;/span&gt; nearestDistanceSquared = 10000000000d;
    &lt;span class=&quot;code-keyword&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;code-object&quot;&gt;Object&lt;/span&gt; entity : entities) {
        Entity ent = (Entity) entity;
        &lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt; (!&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;.theEntity.getEntitySenses().canSee(ent))
            &lt;span class=&quot;code-keyword&quot;&gt;continue&lt;/span&gt;;
        &lt;span class=&quot;code-object&quot;&gt;double&lt;/span&gt; d = ent.getDistanceSqToEntity(&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;.theEntity);
        &lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt; (d &amp;lt; nearestDistanceSquared) {
            nearestDistanceSquared = d;
            nearest = ent;
        }
    }
    &lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt; (nearest == &lt;span class=&quot;code-keyword&quot;&gt;null&lt;/span&gt;)
        &lt;span class=&quot;code-keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;code-keyword&quot;&gt;false&lt;/span&gt;;
    &lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;.closestLivingEntity = nearest;
    ...
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Tested on 1.4.7, with similar setup as in the screenshots. Now each creeper was fleeing the cat at the same height as it was. And all creepers did flee, sooner or later.&lt;/p&gt;

&lt;p&gt;Edit: Additional improvement for efficiency would be good; the way it seeks for the location to flee to is so simplistic that it causes lots of unnecessary extra rounds through the shouldExecute() method. It should try harder to find a way to flee, in order to avoid doing the calculations to find the nearest cat (or whatever other solution is found for that) over and over again in rapid succession.&lt;/p&gt;</comment>
                            <comment id="46239" author="bugi74" created="Sun, 17 Feb 2013 16:11:11 +0100"  >&lt;p&gt;The EntityAIAvoidEntity only looks for +/-3 blocks up and down from the entity (creeper). That is why it works if the cat below is more than 3 blocks below.&lt;/p&gt;

&lt;p&gt;The reason why it ignores the upper cat when there is one below and within those 3 blocks is because the routine that seeks for entities works from bottom up, and adds the results into a list in the order found. The AI routine itself is more than a bit naive, and picks the first result as the one entity it is going to avoid, if needed (i.e. if it can see it).&lt;/p&gt;

&lt;p&gt;One fix might be to loop through the result list, and skip an entity if it can not be seen (or is otherwise ignorable). This will cause a tiny bit of extra processing, and will still leave e.g. such weird behaviour that if there is one cat further away but one block lower, and another cat right near the creeper at the same height and in the opposite direction as the first cat, the creeper would run right into the nearby cat.&lt;/p&gt;

&lt;p&gt;Better solution would be to loop through the list, skip ignorable cases (i.e. can not see) and for valid cases add a vector from horror to creeper with length 1/distance to a sum. The  sum vector would tell which way might be best to flee in panic. However, this adds more processing, though should still be nothing to worry about.&lt;/p&gt;</comment>
                    </comments>
                    <attachments>
                            <attachment id="21945" name="2013-02-17_19.30.00.png" size="791056" author="mt.andi" created="Sun, 17 Feb 2013 15:50:47 +0100"/>
                            <attachment id="21946" name="2013-02-17_19.30.11.png" size="389535" author="mt.andi" created="Sun, 17 Feb 2013 15:50:47 +0100"/>
                            <attachment id="22052" name="2013-02-19_12.01.01.png" size="416183" author="mt.andi" created="Tue, 19 Feb 2013 08:02:05 +0100"/>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                                                                                                                                                                                        <customfield id="customfield_10500" key="com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons">
                        <customfieldname>Confirmation Status</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10300"><![CDATA[Unconfirmed]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                        <customfield id="customfield_11700" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                            <customfield id="customfield_11600" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>0|i06oq7:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                    </customfields>
    </item>
</channel>
</rss>