Started by
StellaeLux
on
Topic category: Help with MCreator software
So I was trying to isolate the climbing behaviour that spiders have from other aspects of the spider's behaviour:
Inside of the custom mob element code:
Importing:
import net.minecraft.pathfinding.PathNavigate;
import net.minecraft.pathfinding.PathNavigateClimber;
import net.minecraft.network.datasync.DataParameter;
import net.minecraft.network.datasync.DataSerializers;
import net.minecraft.network.datasync.EntityDataManager;
import net.minecraft.entity.monster.EntitySpider;
Inside:
public static class EntityCustom extends EntityMob { }
Paste:
private static final DataParameter<Byte> CLIMBING = EntityDataManager.<Byte>createKey(EntitySpider.class, DataSerializers.BYTE);
protected PathNavigate createNavigator(World worldIn)
{
return new PathNavigateClimber(this, worldIn);
}
protected void entityInit()
{
super.entityInit();
this.dataManager.register(CLIMBING, Byte.valueOf((byte)0));
}
public void onUpdate()
{
super.onUpdate();
if (!this.world.isRemote)
{
this.setBesideClimbableBlock(this.collidedHorizontally);
}
}
public boolean isBesideClimbableBlock()
{
return (((Byte)this.dataManager.get(CLIMBING)).byteValue() & 1) != 0;
}
public void setBesideClimbableBlock(boolean climbing)
{
byte b0 = ((Byte)this.dataManager.get(CLIMBING)).byteValue();
if (climbing)
{
b0 = (byte)(b0 | 1);
}
else
{
b0 = (byte)(b0 & -2);
}
this.dataManager.set(CLIMBING, Byte.valueOf(b0));
}
public boolean isOnLadder()
{
return this.isBesideClimbableBlock();
}
Which will allow your custom entity to be able to climb (without inheriting other aspects of the EntitySpider class), which would be an ideal "can climb" true/false checkbox for people creating a custom mob.. However, there is a tiny issue with pathfinding; Occasionally whenever the mob stand exactly between 4 blocks on the ground it will start to rotate at its current position, until a walking AI task triggers.
Does anyone know what could cause this issue?
Edited by StellaeLux on Wed, 10/30/2019 - 15:32
I am not sure if this bug was in 1.12.2 already, but even vanilla mobs can sometimes start turning randomly.
You are right. I placed spiders and cave spiders down and the cave spiders also started spinning in circles. Strangely enough, normal spiders wouldn't do so, where as cave-spiders spin just as often as my mob.
Removing:
disables the spinning but also disables climbing.
I hope they improved pathfinding for 1.14. Thanks for the help!
I saw that this bug was fixed from the side of Minecraft Forge recently for 1.14.4 branch.
Here: