The bug
Values for the team option collisionRule
are not working correctly.
With the current behaviour for example two entities in different teams with pushOwnTeam
as collision rule push each other back.
How to reproduce
/team add Team1
/team modify Team1 collisionRule pushOtherTeams
/team add Team2
/team join Team1
/summon cow ~ ~ ~ {Team:"Team2",Health:0.1f
}
It just acts as it was set to pushOwnTeam
and you cannot push the cow
/team add Team1
/team modify Team1 collisionRule pushOwnTeam
/team add Team2
/team join Team1
/summon cow ~ ~ ~ {Team:"Team2",Health:0.1f
}
It just acts as it was set to pushOtherTeam
and you can push the cow
The reason
The following is based on decompiled version of Minecraft 1.9 using MCP 9.24 beta. All method and class names are the names used in the decompiled version.
The reason why this happens is because the predicate net.minecraft.util.EntitySelectors.func_188442_a().new Predicate() {...}.()
returns false
if two entities are in the same team and one of them can only push teammates.
public static <T extends Entity> Predicate<T> func_188442_a(final Entity p_188442_0_)
{
final Team team = p_188442_0_.getTeam();
final Team.CollisionRule team$collisionrule = team == null ? Team.CollisionRule.ALWAYS : team.getCollisionRule();
Predicate<?> ret = team$collisionrule == Team.CollisionRule.NEVER ? Predicates.alwaysFalse() : Predicates.and(NOT_SPECTATING, new Predicate<Entity>()
{
public boolean apply(Entity p_apply_1_)
{
if (!p_apply_1_.canBePushed())
{
return false;
}
else if (!p_188442_0_.worldObj.isRemote || p_apply_1_ instanceof EntityPlayer && ((EntityPlayer)p_apply_1_).isUser())
{
Team team1 = p_apply_1_.getTeam();
Team.CollisionRule team$collisionrule1 = team1 == null ? Team.CollisionRule.ALWAYS : team1.getCollisionRule();
if (team$collisionrule1 == Team.CollisionRule.NEVER)
{
return false;
}
// Replaced this
/* Parameter explanation:
* p_188442_0_ = Entity that gets pushed
* p_apply_1_ = Entity that pushes
*/
/*
* Team.CollisionRule values:
* ALWAYS("always", 0),
* NEVER("never", 1),
* HIDE_FOR_OTHER_TEAMS("pushOtherTeams", 2),
* HIDE_FOR_OWN_TEAM("pushOwnTeam", 3);
*/
//else
//{
// boolean flag = team != null && team.isSameTeam(team1);
//return (team$collisionrule == Team.CollisionRule.HIDE_FOR_OWN_TEAM || team$collisionrule1 == Team.CollisionRule.HIDE_FOR_OWN_TEAM) && flag ? false : team$collisionrule != Team.CollisionRule.HIDE_FOR_OTHER_TEAMS && team$collisionrule1 != Team.CollisionRule.HIDE_FOR_OTHER_TEAMS || flag;
//}
else if (team$collisionrule == Team.CollisionRule.ALWAYS && team$collisionrule1 == Team.CollisionRule.ALWAYS) {
return true;
}
else {
boolean sameTeam = team != null && team.isSameTeam(team1);
return ((sameTeam && team$collisionrule == Team.CollisionRule.HIDE_FOR_OWN_TEAM) || (!sameTeam && team$collisionrule != Team.CollisionRule.HIDE_FOR_OWN_TEAM && team$collisionrule1 != Team.CollisionRule.HIDE_FOR_OWN_TEAM));
}
}
else
{
return false;
}
}
});
return (Predicate<T>)ret;
}
This should fix this bug, but please recheck.
Note: The problem is that an entity does not only push another entity, it pushes back itself as well. This means that for both entities the collision rule has to allow pushing the other entity.
Linked issues
is duplicated by 6
relates to 1
Comments 16
Confirmed for 15w42a
There are some weird issues when trying to push around things, not assigned to a team...
Confirmed for 15w40b