Change rotation of vehicle to a method
Also corrected the directions being reverse. As well changed it to a method so vehicles extending this have more control.
This commit is contained in:
parent
36eee0272a
commit
893ccb49d1
1 changed files with 17 additions and 3 deletions
|
@ -40,7 +40,7 @@ public class EntityDrivable extends EntityAdvanced implements IControlReceiver
|
||||||
@Override
|
@Override
|
||||||
public boolean keyTyped(EntityPlayer player, int keycode)
|
public boolean keyTyped(EntityPlayer player, int keycode)
|
||||||
{
|
{
|
||||||
System.out.println("Key: "+keycode+" P: " + (player != null ? player.username : "null"));
|
System.out.println("Key: " + keycode + " P: " + (player != null ? player.username : "null"));
|
||||||
if (player != null && this.riddenByEntity instanceof EntityPlayer && ((EntityPlayer) this.riddenByEntity).username.equalsIgnoreCase(player.username))
|
if (player != null && this.riddenByEntity instanceof EntityPlayer && ((EntityPlayer) this.riddenByEntity).username.equalsIgnoreCase(player.username))
|
||||||
{
|
{
|
||||||
//TODO add auto forward and backwards keys like those in WoT
|
//TODO add auto forward and backwards keys like those in WoT
|
||||||
|
@ -55,11 +55,11 @@ public class EntityDrivable extends EntityAdvanced implements IControlReceiver
|
||||||
}
|
}
|
||||||
if (keycode == Minecraft.getMinecraft().gameSettings.keyBindLeft.keyCode)
|
if (keycode == Minecraft.getMinecraft().gameSettings.keyBindLeft.keyCode)
|
||||||
{
|
{
|
||||||
this.rotationYaw += 6;
|
this.turn(true);
|
||||||
}
|
}
|
||||||
if (keycode == Minecraft.getMinecraft().gameSettings.keyBindRight.keyCode)
|
if (keycode == Minecraft.getMinecraft().gameSettings.keyBindRight.keyCode)
|
||||||
{
|
{
|
||||||
this.rotationYaw -= 6;
|
this.turn(false);
|
||||||
}
|
}
|
||||||
//Power brakes
|
//Power brakes
|
||||||
if (keycode == Minecraft.getMinecraft().gameSettings.keyBindJump.keyCode)
|
if (keycode == Minecraft.getMinecraft().gameSettings.keyBindJump.keyCode)
|
||||||
|
@ -83,6 +83,8 @@ public class EntityDrivable extends EntityAdvanced implements IControlReceiver
|
||||||
double deltaX = Math.cos(this.rotationYaw * Math.PI / 180.0D + 114.8) * -0.5D;
|
double deltaX = Math.cos(this.rotationYaw * Math.PI / 180.0D + 114.8) * -0.5D;
|
||||||
double deltaZ = Math.sin(this.rotationYaw * Math.PI / 180.0D + 114.8) * -0.5D;
|
double deltaZ = Math.sin(this.rotationYaw * Math.PI / 180.0D + 114.8) * -0.5D;
|
||||||
this.riddenByEntity.setPosition(this.posX + deltaX, this.posY + this.riddenByEntity.getYOffset(), this.posZ + deltaZ);
|
this.riddenByEntity.setPosition(this.posX + deltaX, this.posY + this.riddenByEntity.getYOffset(), this.posZ + deltaZ);
|
||||||
|
|
||||||
|
this.riddenByEntity.rotationYaw = this.rotationYaw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -174,6 +176,18 @@ public class EntityDrivable extends EntityAdvanced implements IControlReceiver
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void turn(boolean left)
|
||||||
|
{
|
||||||
|
if (left)
|
||||||
|
{
|
||||||
|
this.rotationYaw -= 6;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.rotationYaw += 6;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** By default this slows the vehicle down with a constant. However this can be used to apply
|
/** By default this slows the vehicle down with a constant. However this can be used to apply
|
||||||
* advanced friction based on materials */
|
* advanced friction based on materials */
|
||||||
public void applyFriction()
|
public void applyFriction()
|
||||||
|
|
Loading…
Reference in a new issue