Posted August 10, 201510 yr Im working on my VehicleEntity but i somehow are confused from the entityStructure. I call the creation of some entitySeats, but they are not created. I have set what should happen when i righclick, but it doesn't happen. Can anybody help me? See my file here: package itsamysterious.mods.reallifemod.core.vehicles; import org.lwjgl.util.vector.Vector3f; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.DamageSource; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class EntityVehicle extends Entity { private VehicleFile file; public double backWheelRotation; public double wheelRotL; private boolean isEmpty; private boolean canDoStuff; private EntitySeat[] seats; private double vehicleX; private double vehicleY; private double vehicleZ; private float vehicleYaw; private float vehiclePitch; private double velocityY; private double velocityX; private double velocityZ; public EntityVehicle(World world) { super(world); canDoStuff = false; setSize(1, 2); isEmpty = true; preventEntitySpawning = true; ignoreFrustumCheck = true; } public EntityVehicle(World world, VehicleFile file, double x, double y, double z) { this(world); setFile(file); seats = new EntitySeat[file.numDrivers]; setPosition(x, y, z); createSeats(); } private void createSeats() { for (int i = 0; i < seats.length; i++) { seats = new EntitySeat(worldObj); worldObj.spawnEntityInWorld(seats); } canDoStuff = true; } @Override protected boolean canTriggerWalking() { return false; } @Override public AxisAlignedBB getCollisionBox(Entity entityIn) { return entityIn.getEntityBoundingBox(); } @Override public AxisAlignedBB getBoundingBox() { return getEntityBoundingBox(); } @Override @SideOnly(Side.CLIENT) public void setVelocity(double p_70016_1_, double p_70016_3_, double p_70016_5_) { velocityX = (float) (motionX = p_70016_1_); velocityY = (float) (motionY = p_70016_3_); velocityZ = (float) (motionZ = p_70016_5_); } @Override public boolean attackEntityFrom(DamageSource p_70097_1_, float p_70097_2_) { if (isEntityInvulnerable(p_70097_1_)) { return false; } else if (!worldObj.isRemote && !isDead) { setForwardDirection(-getForwardDirection()); setTimeSinceHit(10); setDamageTaken(getDamageTaken() + p_70097_2_ * 10.0F); setBeenAttacked(); boolean flag = p_70097_1_.getEntity() instanceof EntityPlayer && ((EntityPlayer) p_70097_1_.getEntity()).capabilities.isCreativeMode; if (flag || getDamageTaken() > 40.0F) { if (riddenByEntity != null) { riddenByEntity.mountEntity(this); } if (!flag) { } setDead(); } return true; } else { return true; } } @Override public void entityInit() { dataWatcher.addObject(17, new Integer(0)); dataWatcher.addObject(18, new Integer(1)); dataWatcher.addObject(19, new Float(0.0F)); } @Override public void onUpdate() { super.onUpdate(); if (getTimeSinceHit() > 0) { setTimeSinceHit(getTimeSinceHit() - 1); } if (getDamageTaken() > 0.0F) { setDamageTaken(getDamageTaken() - 1.0F); } prevPosX = posX; prevPosY = posY; prevPosZ = posZ; if (canDoStuff) { for (int i = 0; i < seats.length; i++) { Vector3f f = file.ridersPositions; seats.setPosition(posX + f.x, posY + f.y + 0.5, posZ + f.z); } } } public void move() { } @Override public void readEntityFromNBT(NBTTagCompound tagCompund) { NBTTagCompound vehicleTag = tagCompund.getCompoundTag("VehicleTag"); String s = vehicleTag.getString("VehicleName"); for (int i = 0; i < Vehicles.vehicles.size(); i++) { VehicleFile f = Vehicles.vehicles.get(i); if (f.vehicleName.equals(s)) { setFile(f); } } } @Override public void writeEntityToNBT(NBTTagCompound tagCompound) { NBTTagCompound vehicleTag = new NBTTagCompound(); if (getFile() == null) { System.out.println("No file"); } vehicleTag.setString("VehicleName", getFile().vehicleName); tagCompound.setTag("VehicleTag", vehicleTag); } @Override public boolean interactFirst(EntityPlayer player) { player.mountEntity(this); return true; } @Override public void updateRiderPosition() { if (riddenByEntity != null && riddenByEntity instanceof EntityLivingBase) { double rad = Math.toRadians(rotationYaw); double newX = posX; double newY = posY; double newZ = posZ; riddenByEntity.setPosition(newX, newY, newZ); } }; public VehicleFile getFile() { return file; } public void setFile(VehicleFile file) { this.file = file; } public void setDamageTaken(float p_70266_1_) { dataWatcher.updateObject(19, Float.valueOf(p_70266_1_)); } /** * Gets the damage taken from the last hit. */ public float getDamageTaken() { return dataWatcher.getWatchableObjectFloat(19); } /** * Sets the time to count down from since the last time entity was hit. */ public void setTimeSinceHit(int p_70265_1_) { dataWatcher.updateObject(17, Integer.valueOf(p_70265_1_)); } /** * Gets the time since the last hit. */ public int getTimeSinceHit() { return dataWatcher.getWatchableObjectInt(17); } /** * Sets the forward direction of the entity. */ public void setForwardDirection(int p_70269_1_) { dataWatcher.updateObject(18, Integer.valueOf(p_70269_1_)); } /** * Gets the forward direction of the entity. */ public int getForwardDirection() { return dataWatcher.getWatchableObjectInt(18); } }
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.