Started by
Dreek
on
Topic category: Help with Minecraft modding (Java Edition)
Hi! So I am trying to add cars to my mod, but I don't know how to make the entity not move.
There is no AI base for the armor stand, so I'm really stuck here... Also, can you make the
mob so you can ride like a horse but it doesn't move when you're not controlling it, like
cars? Please help!
Set its movement speed to 0, enable AI and remove all AI tasks from the list.
Ok, the car doesn't move anymore (how I did it was I removed AI ; You can do higher movement speed because it won't move at all), But the thing is you can't ride it wherever you want, and I wanna be able to do that because who wants cars that you can't control? Help!
Did you make it ridable?
yes, but you cant control it.
This is not possible yet, but planned for the future updates. Check this page for more info: https://mcreator.net/tracker/issue/51428
I looked it up a bit and I think there must be a piece of code looking similar like this. I ripped this from the AbstractHorse's code and edited it a bit but I don't know if it'll work:
public void travel(float strafe, float vertical, float forward)
{
if (this.isBeingRidden() && this.canBeSteered())
{
EntityLivingBase entitylivingbase = (EntityLivingBase)this.getControllingPassenger();
this.rotationYaw = entitylivingbase.rotationYaw;
this.prevRotationYaw = this.rotationYaw;
this.rotationPitch = entitylivingbase.rotationPitch * 0.5F;
this.setRotation(this.rotationYaw, this.rotationPitch);
this.renderYawOffset = this.rotationYaw;
this.rotationYawHead = this.renderYawOffset;
strafe = entitylivingbase.moveStrafing * 0.5F;
forward = entitylivingbase.moveForward;
if (forward <= 0.0F)
{
forward *= 0.25F;
}
if (this.onGround && !this.allowStandSliding)
{
strafe = 0.0F;
forward = 0.0F;
}
if (this.canPassengerSteer())
{
this.setAIMoveSpeed((float)this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).getAttributeValue());
super.travel(strafe, vertical, forward);
}
else if (entitylivingbase instanceof EntityPlayer)
{
this.motionX = 0.0D;
this.motionY = 0.0D;
this.motionZ = 0.0D;
}
}
public boolean canBeSteered()
{
return this.getControllingPassenger() instanceof EntityLivingBase;
}
@Nullable
public Entity getControllingPassenger()
{
return this.getPassengers().isEmpty() ? null : (Entity)this.getPassengers().get(0);
}
Where do you put all that code into