Minecraft Mods

[1.6.4][Standalone]The Vehicle A.P.I ! Revamped and Updated

  • 47,546 views, 2 today
  • 10,872 downloads, 0 today
  • 28
  • 16
  • 78
bmanrules's Avatar bmanrules
Level 57 : Grandmaster Programmer
85
dedefddaaccfc

Welcome!

Bmanrules' Vehicle A.P.I allows modders to create amazing new vehicles in Minecraft, complete with loads of hooks used to make awesome vanilla styled vehicles!


Example: Minecraft Boat remade in API:

After API:

package net.minecraft.src;

import java.util.List;

public class EntityBoat extends EntityVehicle{

public EntityBoat(World par1World)
{
super(par1World);
}
public EntityBoat(World par1World, double par2, double par4, double par6)
{
super(par1World, par2, par4, par6);
this.setFloatOnWater(true);
}

public void onCriticalCrash(){
this.dropItemWithOffset(Item.stick.itemID, 1, 0.0F);
this.setDead();
}

public void onDeath(DamageSource par1DamageSource){
this.dropItemWithOffset(Item.boat.itemID, 1, 0.0F);
}

}


Before:

package net.minecraft.src;

import java.util.List;
import org.lwjgl.input.Keyboard;

public class EntityBoat extends Entity
{
private boolean field_70279_a;
private double speedMultiplier;
private int vehiclePosRotationIncrements;
private double vehicleX;
private double vehicleY;
private double vehicleZ;
private double vehicleYaw;
private double vehiclePitch;
private double velocityX;
private double velocityY;
private double velocityZ;
private boolean shouldFloat = true;
private String speedParticle = "magicCrit";
public int textInt = 1;
float length = 0.0F;

public EntityBoat(World par1World)
{
super(par1World);
this.field_70279_a = true;
this.speedMultiplier = 3.0D;
this.preventEntitySpawning = true;
this.setSize(7.4F, 0.6F);
this.yOffset = this.height / 2.1F;
}

/**
* returns if this entity triggers Block.onEntityWalking on the blocks they walk on. used for spiders and wolves to
* prevent them from trampling crops
*/
protected boolean canTriggerWalking()
{
return false;
}

protected void entityInit()
{
this.dataWatcher.addObject(17, new Integer(0));
this.dataWatcher.addObject(18, new Integer(1));
this.dataWatcher.addObject(19, new Float(0.0F));
}

/**
* Returns a boundingBox used to collide the entity with other entities and blocks. This enables the entity to be
* pushable on contact, like vehicles or minecarts.
*/
public AxisAlignedBB getCollisionBox(Entity par1Entity)
{
return par1Entity.boundingBox;
}

/**
* returns the bounding box for this entity
*/
public AxisAlignedBB getBoundingBox()
{
return this.boundingBox;
}

/**
* Returns true if this entity should push and be pushed by other entities when colliding.
*/
public boolean canBePushed()
{
return true;
}

public EntityBoat(World par1World, double par2, double par4, double par6)
{
this(par1World);
this.setPosition(par2, par4 + (double)this.yOffset, par6);
this.motionX = 0.0D;
this.motionY = 0.0D;
this.motionZ = 0.0D;
this.prevPosX = par2;
this.prevPosY = par4;
this.prevPosZ = par6;
}

/**
* Returns the Y offset from the entity's position for any entity riding this one.
*/
public double getMountedYOffset()
{
return (double)this.height * 0.0D - 0.30000001192092896D;
}

/**
* Called when the entity is attacked.
*/
public boolean attackEntityFrom(DamageSource par1DamageSource, float par2)
{
if (this.isEntityInvulnerable())
{
return false;
}
else if (!this.worldObj.isRemote && !this.isDead)
{
this.setForwardDirection(-this.getForwardDirection());
this.setTimeSinceHit(10);
this.setDamageTaken(this.getDamageTaken() + par2 * 10.0F);
this.setBeenAttacked();
boolean var3 = par1DamageSource.getEntity() instanceof EntityPlayer && ((EntityPlayer)par1DamageSource.getEntity()).capabilities.isCreativeMode;

if (var3 || this.getDamageTaken() > 40.0F)
{
if (this.riddenByEntity != null)
{
this.riddenByEntity.mountEntity(this);
}

if (!var3)
{
this.dropItemWithOffset(Item.boat.itemID, 1, 0.0F);
}

this.setDead();
}

return true;
}
else
{
return true;
}
}

/**
* Setups the entity to do the hurt animation. Only used by packets in multiplayer.
*/
public void performHurtAnimation()
{
this.setForwardDirection(-this.getForwardDirection());
this.setTimeSinceHit(10);
this.setDamageTaken(this.getDamageTaken() * 11.0F);
}

/**
* Returns true if other Entities should be prevented from moving through this Entity.
*/
public boolean canBeCollidedWith()
{
return !this.isDead;
}

/**
* Sets the position and rotation. Only difference from the other one is no bounding on the rotation. Args: posX,
* posY, posZ, yaw, pitch
*/
public void setPositionAndRotation2(double par1, double par3, double par5, float par7, float par8, int par9)
{
if (this.field_70279_a)
{
this.vehiclePosRotationIncrements = par9 + 5;
}
else
{
double var10 = par1 - this.posX;
double var12 = par3 - this.posY;
double var14 = par5 - this.posZ;
double var16 = var10 * var10 + var12 * var12 + var14 * var14;

if (var16 <= 1.0D)
{
return;
}

this.vehiclePosRotationIncrements = 3;
}

this.vehicleX = par1;
this.vehicleY = par3;
this.vehicleZ = par5;
this.vehicleYaw = (double)par7;
this.vehiclePitch = (double)par8;
this.motionX = this.velocityX;
this.motionY = this.velocityY;
this.motionZ = this.velocityZ;
}

/**
* Sets the velocity to the args. Args: x, y, z
*/
public void setVelocity(double par1, double par3, double par5)
{
this.velocityX = this.motionX = par1;
this.velocityY = this.motionY = par3;
this.velocityZ = this.motionZ = par5;
}

public void onCrash()
{

}

/**
* Called to update the entity's position/logic.
*/
public void onUpdate()
{
if (textInt == 1)
{
textInt = 2;
}
else
{
textInt = 1;
}
if (this.isCollidedHorizontally)
{
motionY += 0.1D;
}

if (Keyboard.isKeyDown(31) && this.riddenByEntity != null){

motionX += motionX * -1;
motionY += motionY * -1;
motionZ += motionZ * -1;

}

if (this.riddenByEntity == null)
{
motionX += motionX * -1;
motionY += motionY * -1;
motionZ += motionZ * -1;
}

if (Keyboard.isKeyDown(30)){
vehicleYaw += 1.0D;
}

if (Keyboard.isKeyDown(32)){
vehicleYaw -= 1.0D;
vehiclePitch -= 1.0D;
}
if (this.getTimeSinceHit() > 0)
{
this.setTimeSinceHit(this.getTimeSinceHit() - 1);
}

if (this.getDamageTaken() > 0.0F)
{
this.setDamageTaken(this.getDamageTaken() - 1.0F);
}

this.prevPosX = this.posX;
this.prevPosY = this.posY;
this.prevPosZ = this.posZ;
byte var1 = 5;
double var2 = 0.0D;

for (int var4 = 0; var4 < var1; ++var4)
{
double var5 = this.boundingBox.minY + (this.boundingBox.maxY - this.boundingBox.minY) * (double)(var4 + 0) / (double)var1 - 0.125D;
double var7 = this.boundingBox.minY + (this.boundingBox.maxY - this.boundingBox.minY) * (double)(var4 + 1) / (double)var1 - 0.125D;
AxisAlignedBB var9 = AxisAlignedBB.getAABBPool().getAABB(this.boundingBox.minX, var5, this.boundingBox.minZ, this.boundingBox.maxX, var7, this.boundingBox.maxZ);

if (this.worldObj.isAABBInMaterial(var9, Material.water) && this.shouldFloat)
{
var2 += 1.0D / (double)var1;
}
}

double var23 = Math.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ);
double var6;
double var8;

if (var23 > 0.26249999999999996D)
{
var6 = Math.cos((double)this.rotationYaw * Math.PI / 180.0D);
var8 = Math.sin((double)this.rotationYaw * Math.PI / 180.0D);

for (int var10 = 0; (double)var10 < 1.0D + var23 * 60.0D; ++var10)
{
double var11 = (double)(this.rand.nextFloat() * 2.0F - 1.0F);
double var13 = (double)(this.rand.nextInt(2) * 2 - 1) * 0.7D;
double var15;
double var17;

if (this.rand.nextBoolean())
{
var15 = this.posX - var6 * var11 * 0.8D + var8 * var13;
var17 = this.posZ - var8 * var11 * 0.8D - var6 * var13;
this.worldObj.spawnParticle(speedParticle, var15, this.posY - 0.125D, var17, this.motionX, this.motionY, this.motionZ);
//this.playSound("mob.silverfish.say", 1.0F, 1.0F);
}
else
{
var15 = this.posX + var6 + var8 * var11 * 0.7D;
var17 = this.posZ + var8 - var6 * var11 * 0.7D;
this.worldObj.spawnParticle(speedParticle, var15, this.posY - 0.125D, var17, this.motionX, this.motionY, this.motionZ);
}
}
}

double var12;
double var25;

if (this.worldObj.isRemote && this.field_70279_a)
{
if (this.vehiclePosRotationIncrements > 0)
{
var6 = this.posX + (this.vehicleX - this.posX) / (double)this.vehiclePosRotationIncrements;
var8 = this.posY + (this.vehicleY - this.posY) / (double)this.vehiclePosRotationIncrements;
var25 = this.posZ + (this.vehicleZ - this.posZ) / (double)this.vehiclePosRotationIncrements;
var12 = MathHelper.wrapAngleTo180_double(this.vehicleYaw - (double)this.rotationYaw);
this.rotationYaw = (float)((double)this.rotationYaw + var12 / (double)this.vehiclePosRotationIncrements);
this.rotationPitch = (float)((double)this.rotationPitch + (this.vehiclePitch - (double)this.rotationPitch) / (double)this.vehiclePosRotationIncrements);
--this.vehiclePosRotationIncrements;
this.setPosition(var6, var8, var25);
this.setRotation(this.rotationYaw, this.rotationPitch);
}
else
{
var6 = this.posX + this.motionX;
var8 = this.posY + this.motionY;
var25 = this.posZ + this.motionZ;
this.setPosition(var6, var8, var25);



So, How do I use it?

If you're not a modder and need this mod, download the above zip and add the two .class files to Minecraft.jar

If you are a modder, great! This A.P.I is basically an Entity that you can extend on to to make awesome vehicles in Minecraft. From planes, to tanks, helicopters, submarines and giant ships, you can make them all (Once you're a fairly good modder ;) ). Download the file, and add the two .java files to the src folder! Then, make a new mob, extend EntityVehicle and utilise any hooks you may need!

If you need any help with setting it up, send me a PM!

This mod does not include Airships. And also, Cake is a lie

Happy coding!
Progress70% complete
Game VersionMinecraft 1.6.4
Tags

8 Update Logs

Update #8 : by bmanrules 11/20/2013 11:39:29 amNov 20th, 2013

PMC reset zip a third time! Should be fixed.
LOAD MORE LOGS

Create an account or sign in to comment.

1
05/04/2015 2:31 pm
Level 1 : New Explorer
racerboy70
racerboy70's Avatar
How do you 'make' Vehicles with VehicleAPI? kinda bad with this type of thing..
1
08/01/2014 10:01 am
Level 1 : New Miner
AHWM
AHWM's Avatar
Hello.
Are you going to update it to a current version soon? I want to make a big mod, but I would have to do it for 1.6.4.
1
08/01/2014 10:39 am
Level 57 : Grandmaster Programmer
bmanrules
bmanrules's Avatar
Sure, I'll get to work on it :)
1
08/01/2014 11:21 am
Level 1 : New Miner
AHWM
AHWM's Avatar
Thank you.
1
06/23/2014 8:17 pm
Level 26 : Expert Dragon
KerianH
KerianH's Avatar
So here's a question, and hopefully a nice change of pace compared to the other questions you probably get on a regular basis...

Since this is an API, would there happen to be a list of mods that use this API by chance, or would you happen to have some tutorials to help teach people who are new at this to make their own custom vehicles using your API?

I'm curious because the way you built the display airship looks a lot like the build for the Steampunk Airship Mod that unfortunately died long ago, and I'm looking to implement a similar vehicle in custom maps/modpacks, but have virtually no coding experience and...well, I'm stuck.  Any help in this regard would be great.

-Kerian
1
06/24/2014 5:55 pm
Level 57 : Grandmaster Programmer
bmanrules
bmanrules's Avatar
Unfortunatly no one's actually used the A.P.I except for me here. I'll get working on a tutorial and link it in a reply (Should be done by tomorrow, the A.P.I is pretty easy to use so won't take long). I'll post a link as a reply so you get a message when it's done!

If you want, you could use the Airship I linked earlier in your modpack (though it's not yet for 1.6.4, I'll probably be going straight to 1.7/8, I'm not too sure at the moment). However if you want to program your own version (Which I understand) you may want to start off learning the basics of Java (variables and functions/methods) as some knowledge in these topics will be required :)
1
06/26/2014 10:19 pm
Level 26 : Expert Dragon
KerianH
KerianH's Avatar
It would be a bit more convenient for me if it was 1.6.4 before 1.7.2, but that works as well.  I could probably use it for a different modpack I have planned.

Thanks for the intel.  Maybe I should look into learning basic Java...though I'm not looking forward to it.  Being a literary-oriented person makes it hard for me to be able to do coding very well, I lack the patience for it.
1
12/11/2013 5:50 pm
Level 44 : Master Network
dunem666
dunem666's Avatar
this decent enough to handle some cars? I'm already in stages of making a car mod but this would save me great amounts of time.
1
12/11/2013 6:05 pm
Level 57 : Grandmaster Programmer
bmanrules
bmanrules's Avatar
Yep! I've already made a few cars throughout my testing (nothing worth releasing yet) but it should definitely be able to make a car mod (and save you a lot of time!) If you need a hand with anything, or want any new functions/methods added, send me a PM!
1
12/08/2013 1:09 pm
Level 9 : Apprentice Creeper
Da Creepa11
Da Creepa11's Avatar
Sorry if this sounds nooby, what is API?
Planet Minecraft

Website

© 2010 - 2024
www.planetminecraft.com

Welcome