Worked on car

This commit is contained in:
Robert 2013-11-10 20:27:51 -05:00
parent 7cfafeb7fa
commit 6e25105da9
9 changed files with 22 additions and 24 deletions

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1 KiB

View file

@ -21,7 +21,6 @@ import dark.core.common.machines.TileEntityBatteryBox;
import dark.core.common.machines.TileEntityCoalGenerator;
import dark.core.common.machines.TileEntityElectricFurnace;
import dark.core.prefab.ModPrefab;
import dark.core.prefab.vehicles.EntityDrivable;
import dark.core.prefab.vehicles.EntityTestCar;
@SideOnly(Side.CLIENT)

View file

@ -1,7 +1,6 @@
package dark.core.client.renders;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelBoat;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.entity.Entity;
import net.minecraft.util.MathHelper;
@ -12,13 +11,13 @@ import org.lwjgl.opengl.GL11;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import dark.core.client.models.ModelTestCar;
import dark.core.common.DarkMain;
import dark.core.prefab.EntityAdvanced;
import dark.core.prefab.vehicles.EntityDrivable;
@SideOnly(Side.CLIENT)
public class RenderTestCar extends Render
{
private static final ResourceLocation TEXTURE = new ResourceLocation("textures/entity/boat.pn");
private static final ResourceLocation TEXTURE = new ResourceLocation(DarkMain.getInstance().DOMAIN, DarkMain.MODEL_DIRECTORY + "TestCar.png");
/** instance of ModelBoat for rendering */
protected ModelBase modelBoat;
@ -34,7 +33,7 @@ public class RenderTestCar extends Render
{
GL11.glPushMatrix();
GL11.glTranslatef((float) rx, (float) ry + .8f, (float) rz);
GL11.glTranslatef((float) rx, (float) ry + 1.2f, (float) rz);
GL11.glRotatef(180.0F - rYaw, 0.0F, 1.0F, 0.0F);
if (entity instanceof EntityAdvanced)
{

View file

@ -68,7 +68,8 @@ import dark.core.prefab.ModPrefab;
import dark.core.prefab.fluids.EnumGas;
import dark.core.prefab.machine.BlockMulti;
import dark.core.prefab.machine.TileEntityNBTContainer;
import dark.core.prefab.vehicles.EntityDrivable;
import dark.core.prefab.vehicles.EntityTestCar;
import dark.core.prefab.vehicles.EntityVehicle;
import dark.core.prefab.vehicles.ItemVehicleSpawn;
import dark.core.registration.ModObjectRegistry;
@ -137,8 +138,8 @@ public class DarkMain extends ModPrefab
public void init(FMLInitializationEvent event)
{
super.init(event);
EntityRegistry.registerGlobalEntityID(EntityDrivable.class, "TestCar", EntityRegistry.findGlobalUniqueEntityId());
EntityRegistry.registerModEntity(EntityDrivable.class, "TestCar", 60, this, 64, 1, true);
EntityRegistry.registerGlobalEntityID(EntityTestCar.class, "TestCar", EntityRegistry.findGlobalUniqueEntityId());
EntityRegistry.registerModEntity(EntityTestCar.class, "TestCar", 60, this, 64, 1, true);
for (EnumGas gas : EnumGas.values())
{

View file

@ -74,22 +74,22 @@ public class RayTraceHelper
AxisAlignedBB boxToScan = AxisAlignedBB.getBoundingBox(start.xCoord, start.zCoord, start.yCoord, end.xCoord, end.yCoord, end.zCoord);
MovingObjectPosition pickedEntity = null;
List<Entity> entitiesHit;
List<Entity> entities;
if (exclude == null)
{
entitiesHit = world.getEntitiesWithinAABB(Entity.class, boxToScan);
entities = world.getEntitiesWithinAABB(Entity.class, boxToScan);
}
else
{
entitiesHit = world.getEntitiesWithinAABBExcludingEntity(exclude, boxToScan);
entities = world.getEntitiesWithinAABBExcludingEntity(exclude, boxToScan);
}
double closestEntity = start.distanceTo(end);
if (entitiesHit == null || entitiesHit.isEmpty())
if (entities == null || entities.isEmpty())
{
return null;
}
for (Entity entityHit : entitiesHit)
for (Entity entityHit : entities)
{
if (entityHit != null && entityHit.canBeCollidedWith() && entityHit.boundingBox != null)
{

View file

@ -3,7 +3,7 @@ package dark.core.prefab.vehicles;
import dark.core.common.CoreRecipeLoader;
import net.minecraft.world.World;
public class EntityTestCar extends EntityDrivable
public class EntityTestCar extends EntityVehicle
{
public EntityTestCar(World world)

View file

@ -23,7 +23,7 @@ import dark.core.network.PacketManagerEntity;
import dark.core.network.PacketManagerKeyEvent;
import dark.core.prefab.EntityAdvanced;
public abstract class EntityDrivable extends EntityAdvanced implements IControlReceiver, ISimplePacketReceiver
public abstract class EntityVehicle extends EntityAdvanced implements IControlReceiver, ISimplePacketReceiver
{
//1m/tick is 80km/h or 50mi/h
//0.5/tick is 40km/h
@ -32,18 +32,18 @@ public abstract class EntityDrivable extends EntityAdvanced implements IControlR
public double boatX, boatY, boatZ, boatYaw, boatPitch;
public int boatPosRotationIncrements;
public EntityDrivable(World world)
public EntityVehicle(World world)
{
super(world);
this.setSize(0.98F, 0.7F);
this.preventEntitySpawning = true;
this.ignoreFrustumCheck = true;
this.isImmuneToFire = true;
this.yOffset = 1.0f;
this.yOffset = 0.45f;
PacketManagerKeyEvent.instance().register(this);
}
public EntityDrivable(World world, double xx, double yy, double zz)
public EntityVehicle(World world, double xx, double yy, double zz)
{
this(world);
this.setPosition(xx, yy + this.yOffset, zz);
@ -93,8 +93,8 @@ public abstract class EntityDrivable extends EntityAdvanced implements IControlR
if (this.riddenByEntity != null)
{
//Changes the player's position based on the boats rotation
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 deltaX = Math.cos(this.rotationYaw * Math.PI / 180.0D + 114.8) * -0.23D;
double deltaZ = Math.sin(this.rotationYaw * Math.PI / 180.0D + 114.8) * -0.23D;
this.riddenByEntity.setPosition(this.posX + deltaX, this.posY + this.riddenByEntity.getYOffset(), this.posZ + deltaZ);
if (this.riddenByEntity.rotationYaw > this.rotationYaw + 30)
@ -112,7 +112,7 @@ public abstract class EntityDrivable extends EntityAdvanced implements IControlR
public void onUpdate()
{
super.onUpdate();
this.applyFriction();
if (this.worldObj.isRemote)
{
this.worldObj.spawnParticle("mobSpell", this.posX, this.posY, this.posZ, 0, 0, 0);
@ -173,7 +173,6 @@ public abstract class EntityDrivable extends EntityAdvanced implements IControlR
this.moveEntity(this.motionX, this.motionY, this.motionZ);
}
this.applyFriction();
if (this.speed > this.maxSpeed)
{
this.speed = this.maxSpeed;
@ -419,7 +418,7 @@ public abstract class EntityDrivable extends EntityAdvanced implements IControlR
@Override
public double getMountedYOffset()
{
return -.3;
return -.2;
}
@Override

View file

@ -97,7 +97,7 @@ public class ItemVehicleSpawn extends Item
--y;
}
EntityDrivable spawnedEntity = new EntityTestCar(world, hitObj.blockX + 0.5F, y + 1.0F, hitObj.blockZ + 0.5F);
EntityTestCar spawnedEntity = new EntityTestCar(world, hitObj.blockX + 0.5F, y + 1.0F, hitObj.blockZ + 0.5F);
//Last collision check using the entities collision box
if (!world.getCollidingBoundingBoxes(spawnedEntity, spawnedEntity.boundingBox.expand(-0.1D, -0.1D, -0.1D)).isEmpty())