- 46,942 views, 1 today
- 10,848 downloads, 0 today
85

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!
Progress | 70% complete |
Game Version | Minecraft 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
tools/tracking
2386861
7
the-vehicle-api
Create an account or sign in to comment.
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.
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
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 :)
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.