001 package net.minecraft.src; 002 003 import cpw.mods.fml.common.Side; 004 import cpw.mods.fml.common.asm.SideOnly; 005 006 import java.util.ArrayList; 007 import java.util.List; 008 import net.minecraftforge.common.IMinecartCollisionHandler; 009 import net.minecraftforge.common.MinecartRegistry; 010 import net.minecraftforge.common.MinecraftForge; 011 import net.minecraftforge.event.entity.minecart.MinecartCollisionEvent; 012 import net.minecraftforge.event.entity.minecart.MinecartInteractEvent; 013 import net.minecraftforge.event.entity.minecart.MinecartUpdateEvent; 014 015 public class EntityMinecart extends Entity implements IInventory 016 { 017 /** Array of item stacks stored in minecart (for storage minecarts). */ 018 protected ItemStack[] cargoItems; 019 protected int fuel; 020 protected boolean field_70499_f; 021 022 /** The type of minecart, 2 for powered, 1 for storage. */ 023 public int minecartType; 024 public double pushX; 025 public double pushZ; 026 protected final IUpdatePlayerListBox field_82344_g; 027 protected boolean field_82345_h; 028 protected static final int[][][] field_70500_g = new int[][][] {{{0, 0, -1}, {0, 0, 1}}, {{ -1, 0, 0}, {1, 0, 0}}, {{ -1, -1, 0}, {1, 0, 0}}, {{ -1, 0, 0}, {1, -1, 0}}, {{0, 0, -1}, {0, -1, 1}}, {{0, -1, -1}, {0, 0, 1}}, {{0, 0, 1}, {1, 0, 0}}, {{0, 0, 1}, { -1, 0, 0}}, {{0, 0, -1}, { -1, 0, 0}}, {{0, 0, -1}, {1, 0, 0}}}; 029 030 /** appears to be the progress of the turn */ 031 protected int turnProgress; 032 protected double minecartX; 033 protected double minecartY; 034 protected double minecartZ; 035 protected double minecartYaw; 036 protected double minecartPitch; 037 @SideOnly(Side.CLIENT) 038 protected double velocityX; 039 @SideOnly(Side.CLIENT) 040 protected double velocityY; 041 @SideOnly(Side.CLIENT) 042 protected double velocityZ; 043 044 /* Forge: Minecart Compatibility Layer Integration. */ 045 public static float defaultMaxSpeedRail = 0.4f; 046 public static float defaultMaxSpeedGround = 0.4f; 047 public static float defaultMaxSpeedAirLateral = 0.4f; 048 public static float defaultMaxSpeedAirVertical = -1f; 049 public static double defaultDragRidden = 0.996999979019165D; 050 public static double defaultDragEmpty = 0.9599999785423279D; 051 public static double defaultDragAir = 0.94999998807907104D; 052 protected boolean canUseRail = true; 053 protected boolean canBePushed = true; 054 private static IMinecartCollisionHandler collisionHandler = null; 055 056 /* Instance versions of the above physics properties */ 057 protected float maxSpeedRail; 058 protected float maxSpeedGround; 059 protected float maxSpeedAirLateral; 060 protected float maxSpeedAirVertical; 061 protected double dragAir; 062 063 public EntityMinecart(World par1World) 064 { 065 super(par1World); 066 this.cargoItems = new ItemStack[36]; 067 this.fuel = 0; 068 this.field_70499_f = false; 069 this.field_82345_h = true; 070 this.preventEntitySpawning = true; 071 this.setSize(0.98F, 0.7F); 072 this.yOffset = this.height / 2.0F; 073 this.field_82344_g = par1World != null ? par1World.func_82735_a(this) : null; 074 075 maxSpeedRail = defaultMaxSpeedRail; 076 maxSpeedGround = defaultMaxSpeedGround; 077 maxSpeedAirLateral = defaultMaxSpeedAirLateral; 078 maxSpeedAirVertical = defaultMaxSpeedAirVertical; 079 dragAir = defaultDragAir; 080 } 081 082 public EntityMinecart(World world, int type) 083 { 084 this(world); 085 minecartType = type; 086 } 087 088 /** 089 * returns if this entity triggers Block.onEntityWalking on the blocks they walk on. used for spiders and wolves to 090 * prevent them from trampling crops 091 */ 092 protected boolean canTriggerWalking() 093 { 094 return false; 095 } 096 097 protected void entityInit() 098 { 099 this.dataWatcher.addObject(16, new Byte((byte)0)); 100 this.dataWatcher.addObject(17, new Integer(0)); 101 this.dataWatcher.addObject(18, new Integer(1)); 102 this.dataWatcher.addObject(19, new Integer(0)); 103 } 104 105 /** 106 * Returns a boundingBox used to collide the entity with other entities and blocks. This enables the entity to be 107 * pushable on contact, like boats or minecarts. 108 */ 109 public AxisAlignedBB getCollisionBox(Entity par1Entity) 110 { 111 if (getCollisionHandler() != null) 112 { 113 return getCollisionHandler().getCollisionBox(this, par1Entity); 114 } 115 return par1Entity.boundingBox; 116 } 117 118 /** 119 * returns the bounding box for this entity 120 */ 121 public AxisAlignedBB getBoundingBox() 122 { 123 if (getCollisionHandler() != null) 124 { 125 return getCollisionHandler().getBoundingBox(this); 126 } 127 return null; 128 } 129 130 /** 131 * Returns true if this entity should push and be pushed by other entities when colliding. 132 */ 133 public boolean canBePushed() 134 { 135 return canBePushed; 136 } 137 138 public EntityMinecart(World par1World, double par2, double par4, double par6, int par8) 139 { 140 this(par1World); 141 this.setPosition(par2, par4 + (double)this.yOffset, par6); 142 this.motionX = 0.0D; 143 this.motionY = 0.0D; 144 this.motionZ = 0.0D; 145 this.prevPosX = par2; 146 this.prevPosY = par4; 147 this.prevPosZ = par6; 148 this.minecartType = par8; 149 } 150 151 /** 152 * Returns the Y offset from the entity's position for any entity riding this one. 153 */ 154 public double getMountedYOffset() 155 { 156 return (double)this.height * 0.0D - 0.30000001192092896D; 157 } 158 159 /** 160 * Called when the entity is attacked. 161 */ 162 public boolean attackEntityFrom(DamageSource par1DamageSource, int par2) 163 { 164 if (!this.worldObj.isRemote && !this.isDead) 165 { 166 this.func_70494_i(-this.func_70493_k()); 167 this.func_70497_h(10); 168 this.setBeenAttacked(); 169 this.setDamage(this.getDamage() + par2 * 10); 170 171 if (par1DamageSource.getEntity() instanceof EntityPlayer && ((EntityPlayer)par1DamageSource.getEntity()).capabilities.isCreativeMode) 172 { 173 this.setDamage(100); 174 } 175 176 if (this.getDamage() > 40) 177 { 178 if (this.riddenByEntity != null) 179 { 180 this.riddenByEntity.mountEntity(this); 181 } 182 183 this.setDead(); 184 dropCartAsItem(); 185 } 186 187 return true; 188 } 189 else 190 { 191 return true; 192 } 193 } 194 195 @SideOnly(Side.CLIENT) 196 197 /** 198 * Setups the entity to do the hurt animation. Only used by packets in multiplayer. 199 */ 200 public void performHurtAnimation() 201 { 202 this.func_70494_i(-this.func_70493_k()); 203 this.func_70497_h(10); 204 this.setDamage(this.getDamage() + this.getDamage() * 10); 205 } 206 207 /** 208 * Returns true if other Entities should be prevented from moving through this Entity. 209 */ 210 public boolean canBeCollidedWith() 211 { 212 return !this.isDead; 213 } 214 215 /** 216 * Will get destroyed next tick. 217 */ 218 public void setDead() 219 { 220 if (this.field_82345_h) 221 { 222 for (int var1 = 0; var1 < this.getSizeInventory(); ++var1) 223 { 224 ItemStack var2 = this.getStackInSlot(var1); 225 226 if (var2 != null) 227 { 228 float var3 = this.rand.nextFloat() * 0.8F + 0.1F; 229 float var4 = this.rand.nextFloat() * 0.8F + 0.1F; 230 float var5 = this.rand.nextFloat() * 0.8F + 0.1F; 231 232 while (var2.stackSize > 0) 233 { 234 int var6 = this.rand.nextInt(21) + 10; 235 236 if (var6 > var2.stackSize) 237 { 238 var6 = var2.stackSize; 239 } 240 241 var2.stackSize -= var6; 242 EntityItem var7 = new EntityItem(this.worldObj, this.posX + (double)var3, this.posY + (double)var4, this.posZ + (double)var5, new ItemStack(var2.itemID, var6, var2.getItemDamage())); 243 244 if (var2.hasTagCompound()) 245 { 246 var7.item.setTagCompound((NBTTagCompound)var2.getTagCompound().copy()); 247 } 248 249 float var8 = 0.05F; 250 var7.motionX = (double)((float)this.rand.nextGaussian() * var8); 251 var7.motionY = (double)((float)this.rand.nextGaussian() * var8 + 0.2F); 252 var7.motionZ = (double)((float)this.rand.nextGaussian() * var8); 253 this.worldObj.spawnEntityInWorld(var7); 254 } 255 } 256 } 257 } 258 259 super.setDead(); 260 261 if (this.field_82344_g != null) 262 { 263 this.field_82344_g.update(); 264 } 265 } 266 267 /** 268 * Teleports the entity to another dimension. Params: Dimension number to teleport to 269 */ 270 public void travelToDimension(int par1) 271 { 272 this.field_82345_h = false; 273 super.travelToDimension(par1); 274 } 275 276 /** 277 * Called to update the entity's position/logic. 278 */ 279 public void onUpdate() 280 { 281 if (this.field_82344_g != null) 282 { 283 this.field_82344_g.update(); 284 } 285 286 if (this.func_70496_j() > 0) 287 { 288 this.func_70497_h(this.func_70496_j() - 1); 289 } 290 291 if (this.getDamage() > 0) 292 { 293 this.setDamage(this.getDamage() - 1); 294 } 295 296 if (this.posY < -64.0D) 297 { 298 this.kill(); 299 } 300 301 if (this.isMinecartPowered() && this.rand.nextInt(4) == 0 && minecartType == 2 && getClass() == EntityMinecart.class) 302 { 303 this.worldObj.spawnParticle("largesmoke", this.posX, this.posY + 0.8D, this.posZ, 0.0D, 0.0D, 0.0D); 304 } 305 306 if (this.worldObj.isRemote) 307 { 308 if (this.turnProgress > 0) 309 { 310 double var45 = this.posX + (this.minecartX - this.posX) / (double)this.turnProgress; 311 double var46 = this.posY + (this.minecartY - this.posY) / (double)this.turnProgress; 312 double var5 = this.posZ + (this.minecartZ - this.posZ) / (double)this.turnProgress; 313 double var7 = MathHelper.wrapAngleTo180_double(this.minecartYaw - (double)this.rotationYaw); 314 this.rotationYaw = (float)((double)this.rotationYaw + var7 / (double)this.turnProgress); 315 this.rotationPitch = (float)((double)this.rotationPitch + (this.minecartPitch - (double)this.rotationPitch) / (double)this.turnProgress); 316 --this.turnProgress; 317 this.setPosition(var45, var46, var5); 318 this.setRotation(this.rotationYaw, this.rotationPitch); 319 } 320 else 321 { 322 this.setPosition(this.posX, this.posY, this.posZ); 323 this.setRotation(this.rotationYaw, this.rotationPitch); 324 } 325 } 326 else 327 { 328 this.prevPosX = this.posX; 329 this.prevPosY = this.posY; 330 this.prevPosZ = this.posZ; 331 this.motionY -= 0.03999999910593033D; 332 int var1 = MathHelper.floor_double(this.posX); 333 int var2 = MathHelper.floor_double(this.posY); 334 int var3 = MathHelper.floor_double(this.posZ); 335 336 if (BlockRail.isRailBlockAt(this.worldObj, var1, var2 - 1, var3)) 337 { 338 --var2; 339 } 340 341 double var4 = 0.4D; 342 double var6 = 0.0078125D; 343 int var8 = this.worldObj.getBlockId(var1, var2, var3); 344 345 if (canUseRail() && BlockRail.isRailBlock(var8)) 346 { 347 Vec3 var9 = this.func_70489_a(this.posX, this.posY, this.posZ); 348 int var10 = ((BlockRail)Block.blocksList[var8]).getBasicRailMetadata(worldObj, this, var1, var2, var3); 349 this.posY = (double)var2; 350 boolean var11 = false; 351 boolean var12 = false; 352 353 if (var8 == Block.railPowered.blockID) 354 { 355 var11 = (worldObj.getBlockMetadata(var1, var2, var3) & 8) != 0; 356 var12 = !var11; 357 } 358 359 if (((BlockRail)Block.blocksList[var8]).isPowered()) 360 { 361 var10 &= 7; 362 } 363 364 if (var10 >= 2 && var10 <= 5) 365 { 366 this.posY = (double)(var2 + 1); 367 } 368 369 adjustSlopeVelocities(var10); 370 371 int[][] var13 = field_70500_g[var10]; 372 double var14 = (double)(var13[1][0] - var13[0][0]); 373 double var16 = (double)(var13[1][2] - var13[0][2]); 374 double var18 = Math.sqrt(var14 * var14 + var16 * var16); 375 double var20 = this.motionX * var14 + this.motionZ * var16; 376 377 if (var20 < 0.0D) 378 { 379 var14 = -var14; 380 var16 = -var16; 381 } 382 383 double var22 = Math.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ); 384 this.motionX = var22 * var14 / var18; 385 this.motionZ = var22 * var16 / var18; 386 double var24; 387 double var26; 388 389 if (this.riddenByEntity != null) 390 { 391 var24 = this.riddenByEntity.motionX * this.riddenByEntity.motionX + this.riddenByEntity.motionZ * this.riddenByEntity.motionZ; 392 var26 = this.motionX * this.motionX + this.motionZ * this.motionZ; 393 394 if (var24 > 1.0E-4D && var26 < 0.01D) 395 { 396 this.motionX += this.riddenByEntity.motionX * 0.1D; 397 this.motionZ += this.riddenByEntity.motionZ * 0.1D; 398 var12 = false; 399 } 400 } 401 402 if (var12 && shouldDoRailFunctions()) 403 { 404 var24 = Math.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ); 405 406 if (var24 < 0.03D) 407 { 408 this.motionX *= 0.0D; 409 this.motionY *= 0.0D; 410 this.motionZ *= 0.0D; 411 } 412 else 413 { 414 this.motionX *= 0.5D; 415 this.motionY *= 0.0D; 416 this.motionZ *= 0.5D; 417 } 418 } 419 420 var24 = 0.0D; 421 var26 = (double)var1 + 0.5D + (double)var13[0][0] * 0.5D; 422 double var28 = (double)var3 + 0.5D + (double)var13[0][2] * 0.5D; 423 double var30 = (double)var1 + 0.5D + (double)var13[1][0] * 0.5D; 424 double var32 = (double)var3 + 0.5D + (double)var13[1][2] * 0.5D; 425 var14 = var30 - var26; 426 var16 = var32 - var28; 427 double var34; 428 double var36; 429 430 if (var14 == 0.0D) 431 { 432 this.posX = (double)var1 + 0.5D; 433 var24 = this.posZ - (double)var3; 434 } 435 else if (var16 == 0.0D) 436 { 437 this.posZ = (double)var3 + 0.5D; 438 var24 = this.posX - (double)var1; 439 } 440 else 441 { 442 var34 = this.posX - var26; 443 var36 = this.posZ - var28; 444 var24 = (var34 * var14 + var36 * var16) * 2.0D; 445 } 446 447 this.posX = var26 + var14 * var24; 448 this.posZ = var28 + var16 * var24; 449 this.setPosition(this.posX, this.posY + (double)this.yOffset, this.posZ); 450 451 moveMinecartOnRail(var1, var2, var3); 452 453 if (var13[0][1] != 0 && MathHelper.floor_double(this.posX) - var1 == var13[0][0] && MathHelper.floor_double(this.posZ) - var3 == var13[0][2]) 454 { 455 this.setPosition(this.posX, this.posY + (double)var13[0][1], this.posZ); 456 } 457 else if (var13[1][1] != 0 && MathHelper.floor_double(this.posX) - var1 == var13[1][0] && MathHelper.floor_double(this.posZ) - var3 == var13[1][2]) 458 { 459 this.setPosition(this.posX, this.posY + (double)var13[1][1], this.posZ); 460 } 461 462 applyDragAndPushForces(); 463 464 Vec3 var52 = this.func_70489_a(this.posX, this.posY, this.posZ); 465 466 if (var52 != null && var9 != null) 467 { 468 double var39 = (var9.yCoord - var52.yCoord) * 0.05D; 469 var22 = Math.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ); 470 471 if (var22 > 0.0D) 472 { 473 this.motionX = this.motionX / var22 * (var22 + var39); 474 this.motionZ = this.motionZ / var22 * (var22 + var39); 475 } 476 477 this.setPosition(this.posX, var52.yCoord, this.posZ); 478 } 479 480 int var51 = MathHelper.floor_double(this.posX); 481 int var53 = MathHelper.floor_double(this.posZ); 482 483 if (var51 != var1 || var53 != var3) 484 { 485 var22 = Math.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ); 486 this.motionX = var22 * (double)(var51 - var1); 487 this.motionZ = var22 * (double)(var53 - var3); 488 } 489 490 double var41; 491 492 updatePushForces(); 493 494 if(shouldDoRailFunctions()) 495 { 496 ((BlockRail)Block.blocksList[var8]).onMinecartPass(worldObj, this, var1, var2, var3); 497 } 498 499 if (var11 && shouldDoRailFunctions()) 500 { 501 var41 = Math.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ); 502 503 if (var41 > 0.01D) 504 { 505 double var43 = 0.06D; 506 this.motionX += this.motionX / var41 * var43; 507 this.motionZ += this.motionZ / var41 * var43; 508 } 509 else if (var10 == 1) 510 { 511 if (this.worldObj.isBlockNormalCube(var1 - 1, var2, var3)) 512 { 513 this.motionX = 0.02D; 514 } 515 else if (this.worldObj.isBlockNormalCube(var1 + 1, var2, var3)) 516 { 517 this.motionX = -0.02D; 518 } 519 } 520 else if (var10 == 0) 521 { 522 if (this.worldObj.isBlockNormalCube(var1, var2, var3 - 1)) 523 { 524 this.motionZ = 0.02D; 525 } 526 else if (this.worldObj.isBlockNormalCube(var1, var2, var3 + 1)) 527 { 528 this.motionZ = -0.02D; 529 } 530 } 531 } 532 } 533 else 534 { 535 moveMinecartOffRail(var1, var2, var3); 536 } 537 538 this.doBlockCollisions(); 539 this.rotationPitch = 0.0F; 540 double var47 = this.prevPosX - this.posX; 541 double var48 = this.prevPosZ - this.posZ; 542 543 if (var47 * var47 + var48 * var48 > 0.001D) 544 { 545 this.rotationYaw = (float)(Math.atan2(var48, var47) * 180.0D / Math.PI); 546 547 if (this.field_70499_f) 548 { 549 this.rotationYaw += 180.0F; 550 } 551 } 552 553 double var49 = (double)MathHelper.wrapAngleTo180_float(this.rotationYaw - this.prevRotationYaw); 554 555 if (var49 < -170.0D || var49 >= 170.0D) 556 { 557 this.rotationYaw += 180.0F; 558 this.field_70499_f = !this.field_70499_f; 559 } 560 561 this.setRotation(this.rotationYaw, this.rotationPitch); 562 563 AxisAlignedBB box = null; 564 if (getCollisionHandler() != null) 565 { 566 box = getCollisionHandler().getMinecartCollisionBox(this); 567 } 568 else 569 { 570 box = boundingBox.expand(0.2D, 0.0D, 0.2D); 571 } 572 573 List var15 = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, box); 574 575 if (var15 != null && !var15.isEmpty()) 576 { 577 for (int var50 = 0; var50 < var15.size(); ++var50) 578 { 579 Entity var17 = (Entity)var15.get(var50); 580 581 if (var17 != this.riddenByEntity && var17.canBePushed() && var17 instanceof EntityMinecart) 582 { 583 var17.applyEntityCollision(this); 584 } 585 } 586 } 587 588 if (this.riddenByEntity != null && this.riddenByEntity.isDead) 589 { 590 if (this.riddenByEntity.ridingEntity == this) 591 { 592 this.riddenByEntity.ridingEntity = null; 593 } 594 595 this.riddenByEntity = null; 596 } 597 598 updateFuel(); 599 MinecraftForge.EVENT_BUS.post(new MinecartUpdateEvent(this, var1, var2, var3)); 600 } 601 } 602 603 @SideOnly(Side.CLIENT) 604 public Vec3 func_70495_a(double par1, double par3, double par5, double par7) 605 { 606 int var9 = MathHelper.floor_double(par1); 607 int var10 = MathHelper.floor_double(par3); 608 int var11 = MathHelper.floor_double(par5); 609 610 if (BlockRail.isRailBlockAt(this.worldObj, var9, var10 - 1, var11)) 611 { 612 --var10; 613 } 614 615 int var12 = this.worldObj.getBlockId(var9, var10, var11); 616 617 if (!BlockRail.isRailBlock(var12)) 618 { 619 return null; 620 } 621 else 622 { 623 int var13 = ((BlockRail)Block.blocksList[var12]).getBasicRailMetadata(worldObj, this, var9, var10, var11); 624 625 par3 = (double)var10; 626 627 if (var13 >= 2 && var13 <= 5) 628 { 629 par3 = (double)(var10 + 1); 630 } 631 632 int[][] var14 = field_70500_g[var13]; 633 double var15 = (double)(var14[1][0] - var14[0][0]); 634 double var17 = (double)(var14[1][2] - var14[0][2]); 635 double var19 = Math.sqrt(var15 * var15 + var17 * var17); 636 var15 /= var19; 637 var17 /= var19; 638 par1 += var15 * par7; 639 par5 += var17 * par7; 640 641 if (var14[0][1] != 0 && MathHelper.floor_double(par1) - var9 == var14[0][0] && MathHelper.floor_double(par5) - var11 == var14[0][2]) 642 { 643 par3 += (double)var14[0][1]; 644 } 645 else if (var14[1][1] != 0 && MathHelper.floor_double(par1) - var9 == var14[1][0] && MathHelper.floor_double(par5) - var11 == var14[1][2]) 646 { 647 par3 += (double)var14[1][1]; 648 } 649 650 return this.func_70489_a(par1, par3, par5); 651 } 652 } 653 654 public Vec3 func_70489_a(double par1, double par3, double par5) 655 { 656 int var7 = MathHelper.floor_double(par1); 657 int var8 = MathHelper.floor_double(par3); 658 int var9 = MathHelper.floor_double(par5); 659 660 if (BlockRail.isRailBlockAt(this.worldObj, var7, var8 - 1, var9)) 661 { 662 --var8; 663 } 664 665 int var10 = this.worldObj.getBlockId(var7, var8, var9); 666 667 if (BlockRail.isRailBlock(var10)) 668 { 669 int var11 = ((BlockRail)Block.blocksList[var10]).getBasicRailMetadata(worldObj, this, var7, var8, var9); 670 par3 = (double)var8; 671 672 if (var11 >= 2 && var11 <= 5) 673 { 674 par3 = (double)(var8 + 1); 675 } 676 677 int[][] var12 = field_70500_g[var11]; 678 double var13 = 0.0D; 679 double var15 = (double)var7 + 0.5D + (double)var12[0][0] * 0.5D; 680 double var17 = (double)var8 + 0.5D + (double)var12[0][1] * 0.5D; 681 double var19 = (double)var9 + 0.5D + (double)var12[0][2] * 0.5D; 682 double var21 = (double)var7 + 0.5D + (double)var12[1][0] * 0.5D; 683 double var23 = (double)var8 + 0.5D + (double)var12[1][1] * 0.5D; 684 double var25 = (double)var9 + 0.5D + (double)var12[1][2] * 0.5D; 685 double var27 = var21 - var15; 686 double var29 = (var23 - var17) * 2.0D; 687 double var31 = var25 - var19; 688 689 if (var27 == 0.0D) 690 { 691 par1 = (double)var7 + 0.5D; 692 var13 = par5 - (double)var9; 693 } 694 else if (var31 == 0.0D) 695 { 696 par5 = (double)var9 + 0.5D; 697 var13 = par1 - (double)var7; 698 } 699 else 700 { 701 double var33 = par1 - var15; 702 double var35 = par5 - var19; 703 var13 = (var33 * var27 + var35 * var31) * 2.0D; 704 } 705 706 par1 = var15 + var27 * var13; 707 par3 = var17 + var29 * var13; 708 par5 = var19 + var31 * var13; 709 710 if (var29 < 0.0D) 711 { 712 ++par3; 713 } 714 715 if (var29 > 0.0D) 716 { 717 par3 += 0.5D; 718 } 719 720 return this.worldObj.getWorldVec3Pool().getVecFromPool(par1, par3, par5); 721 } 722 else 723 { 724 return null; 725 } 726 } 727 728 /** 729 * (abstract) Protected helper method to write subclass entity data to NBT. 730 */ 731 protected void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) 732 { 733 par1NBTTagCompound.setInteger("Type", this.minecartType); 734 735 if (isPoweredCart()) 736 { 737 par1NBTTagCompound.setDouble("PushX", this.pushX); 738 par1NBTTagCompound.setDouble("PushZ", this.pushZ); 739 par1NBTTagCompound.setInteger("Fuel", this.fuel); 740 } 741 742 if (getSizeInventory() > 0) 743 { 744 NBTTagList var2 = new NBTTagList(); 745 746 for (int var3 = 0; var3 < this.cargoItems.length; ++var3) 747 { 748 if (this.cargoItems[var3] != null) 749 { 750 NBTTagCompound var4 = new NBTTagCompound(); 751 var4.setByte("Slot", (byte)var3); 752 this.cargoItems[var3].writeToNBT(var4); 753 var2.appendTag(var4); 754 } 755 } 756 757 par1NBTTagCompound.setTag("Items", var2); 758 } 759 } 760 761 /** 762 * (abstract) Protected helper method to read subclass entity data from NBT. 763 */ 764 protected void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) 765 { 766 this.minecartType = par1NBTTagCompound.getInteger("Type"); 767 768 if (isPoweredCart()) 769 { 770 this.pushX = par1NBTTagCompound.getDouble("PushX"); 771 this.pushZ = par1NBTTagCompound.getDouble("PushZ"); 772 try 773 { 774 this.fuel = par1NBTTagCompound.getInteger("Fuel"); 775 } 776 catch (ClassCastException e) 777 { 778 this.fuel = par1NBTTagCompound.getShort("Fuel"); 779 } 780 } 781 782 if (getSizeInventory() > 0) 783 { 784 NBTTagList var2 = par1NBTTagCompound.getTagList("Items"); 785 this.cargoItems = new ItemStack[this.getSizeInventory()]; 786 787 for (int var3 = 0; var3 < var2.tagCount(); ++var3) 788 { 789 NBTTagCompound var4 = (NBTTagCompound)var2.tagAt(var3); 790 int var5 = var4.getByte("Slot") & 255; 791 792 if (var5 >= 0 && var5 < this.cargoItems.length) 793 { 794 this.cargoItems[var5] = ItemStack.loadItemStackFromNBT(var4); 795 } 796 } 797 } 798 } 799 800 @SideOnly(Side.CLIENT) 801 public float getShadowSize() 802 { 803 return 0.0F; 804 } 805 806 /** 807 * Applies a velocity to each of the entities pushing them away from each other. Args: entity 808 */ 809 public void applyEntityCollision(Entity par1Entity) 810 { 811 MinecraftForge.EVENT_BUS.post(new MinecartCollisionEvent(this, par1Entity)); 812 if (getCollisionHandler() != null) 813 { 814 getCollisionHandler().onEntityCollision(this, par1Entity); 815 return; 816 } 817 if (!this.worldObj.isRemote) 818 { 819 if (par1Entity != this.riddenByEntity) 820 { 821 if (par1Entity instanceof EntityLiving && !(par1Entity instanceof EntityPlayer) && !(par1Entity instanceof EntityIronGolem) && canBeRidden() && this.motionX * this.motionX + this.motionZ * this.motionZ > 0.01D && this.riddenByEntity == null && par1Entity.ridingEntity == null) 822 { 823 par1Entity.mountEntity(this); 824 } 825 826 double var2 = par1Entity.posX - this.posX; 827 double var4 = par1Entity.posZ - this.posZ; 828 double var6 = var2 * var2 + var4 * var4; 829 830 if (var6 >= 9.999999747378752E-5D) 831 { 832 var6 = (double)MathHelper.sqrt_double(var6); 833 var2 /= var6; 834 var4 /= var6; 835 double var8 = 1.0D / var6; 836 837 if (var8 > 1.0D) 838 { 839 var8 = 1.0D; 840 } 841 842 var2 *= var8; 843 var4 *= var8; 844 var2 *= 0.10000000149011612D; 845 var4 *= 0.10000000149011612D; 846 var2 *= (double)(1.0F - this.entityCollisionReduction); 847 var4 *= (double)(1.0F - this.entityCollisionReduction); 848 var2 *= 0.5D; 849 var4 *= 0.5D; 850 851 if (par1Entity instanceof EntityMinecart) 852 { 853 double var10 = par1Entity.posX - this.posX; 854 double var12 = par1Entity.posZ - this.posZ; 855 Vec3 var14 = this.worldObj.getWorldVec3Pool().getVecFromPool(var10, 0.0D, var12).normalize(); 856 Vec3 var15 = this.worldObj.getWorldVec3Pool().getVecFromPool((double)MathHelper.cos(this.rotationYaw * (float)Math.PI / 180.0F), 0.0D, (double)MathHelper.sin(this.rotationYaw * (float)Math.PI / 180.0F)).normalize(); 857 double var16 = Math.abs(var14.dotProduct(var15)); 858 859 if (var16 < 0.800000011920929D) 860 { 861 return; 862 } 863 864 double var18 = par1Entity.motionX + this.motionX; 865 double var20 = par1Entity.motionZ + this.motionZ; 866 867 if (((EntityMinecart)par1Entity).isPoweredCart() && !isPoweredCart()) 868 { 869 this.motionX *= 0.20000000298023224D; 870 this.motionZ *= 0.20000000298023224D; 871 this.addVelocity(par1Entity.motionX - var2, 0.0D, par1Entity.motionZ - var4); 872 par1Entity.motionX *= 0.949999988079071D; 873 par1Entity.motionZ *= 0.949999988079071D; 874 } 875 else if (!((EntityMinecart)par1Entity).isPoweredCart() && isPoweredCart()) 876 { 877 par1Entity.motionX *= 0.20000000298023224D; 878 par1Entity.motionZ *= 0.20000000298023224D; 879 par1Entity.addVelocity(this.motionX + var2, 0.0D, this.motionZ + var4); 880 this.motionX *= 0.949999988079071D; 881 this.motionZ *= 0.949999988079071D; 882 } 883 else 884 { 885 var18 /= 2.0D; 886 var20 /= 2.0D; 887 this.motionX *= 0.20000000298023224D; 888 this.motionZ *= 0.20000000298023224D; 889 this.addVelocity(var18 - var2, 0.0D, var20 - var4); 890 par1Entity.motionX *= 0.20000000298023224D; 891 par1Entity.motionZ *= 0.20000000298023224D; 892 par1Entity.addVelocity(var18 + var2, 0.0D, var20 + var4); 893 } 894 } 895 else 896 { 897 this.addVelocity(-var2, 0.0D, -var4); 898 par1Entity.addVelocity(var2 / 4.0D, 0.0D, var4 / 4.0D); 899 } 900 } 901 } 902 } 903 } 904 905 /** 906 * Returns the number of slots in the inventory. 907 */ 908 public int getSizeInventory() 909 { 910 return (minecartType == 1 && getClass() == EntityMinecart.class ? 27 : 0); 911 } 912 913 /** 914 * Returns the stack in slot i 915 */ 916 public ItemStack getStackInSlot(int par1) 917 { 918 return this.cargoItems[par1]; 919 } 920 921 /** 922 * Removes from an inventory slot (first arg) up to a specified number (second arg) of items and returns them in a 923 * new stack. 924 */ 925 public ItemStack decrStackSize(int par1, int par2) 926 { 927 if (this.cargoItems[par1] != null) 928 { 929 ItemStack var3; 930 931 if (this.cargoItems[par1].stackSize <= par2) 932 { 933 var3 = this.cargoItems[par1]; 934 this.cargoItems[par1] = null; 935 return var3; 936 } 937 else 938 { 939 var3 = this.cargoItems[par1].splitStack(par2); 940 941 if (this.cargoItems[par1].stackSize == 0) 942 { 943 this.cargoItems[par1] = null; 944 } 945 946 return var3; 947 } 948 } 949 else 950 { 951 return null; 952 } 953 } 954 955 /** 956 * When some containers are closed they call this on each slot, then drop whatever it returns as an EntityItem - 957 * like when you close a workbench GUI. 958 */ 959 public ItemStack getStackInSlotOnClosing(int par1) 960 { 961 if (this.cargoItems[par1] != null) 962 { 963 ItemStack var2 = this.cargoItems[par1]; 964 this.cargoItems[par1] = null; 965 return var2; 966 } 967 else 968 { 969 return null; 970 } 971 } 972 973 /** 974 * Sets the given item stack to the specified slot in the inventory (can be crafting or armor sections). 975 */ 976 public void setInventorySlotContents(int par1, ItemStack par2ItemStack) 977 { 978 this.cargoItems[par1] = par2ItemStack; 979 980 if (par2ItemStack != null && par2ItemStack.stackSize > this.getInventoryStackLimit()) 981 { 982 par2ItemStack.stackSize = this.getInventoryStackLimit(); 983 } 984 } 985 986 /** 987 * Returns the name of the inventory. 988 */ 989 public String getInvName() 990 { 991 return "container.minecart"; 992 } 993 994 /** 995 * Returns the maximum stack size for a inventory slot. Seems to always be 64, possibly will be extended. *Isn't 996 * this more of a set than a get?* 997 */ 998 public int getInventoryStackLimit() 999 { 1000 return 64; 1001 } 1002 1003 /** 1004 * Called when an the contents of an Inventory change, usually 1005 */ 1006 public void onInventoryChanged() {} 1007 1008 /** 1009 * Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig. 1010 */ 1011 public boolean interact(EntityPlayer par1EntityPlayer) 1012 { 1013 if (MinecraftForge.EVENT_BUS.post(new MinecartInteractEvent(this, par1EntityPlayer))) 1014 { 1015 return true; 1016 } 1017 1018 if (canBeRidden()) 1019 { 1020 if (this.riddenByEntity != null && this.riddenByEntity instanceof EntityPlayer && this.riddenByEntity != par1EntityPlayer) 1021 { 1022 return true; 1023 } 1024 1025 if (!this.worldObj.isRemote) 1026 { 1027 par1EntityPlayer.mountEntity(this); 1028 } 1029 } 1030 else if (getSizeInventory() > 0) 1031 { 1032 if (!this.worldObj.isRemote) 1033 { 1034 par1EntityPlayer.displayGUIChest(this); 1035 } 1036 } 1037 else if (this.minecartType == 2 && getClass() == EntityMinecart.class) 1038 { 1039 ItemStack var2 = par1EntityPlayer.inventory.getCurrentItem(); 1040 1041 if (var2 != null && var2.itemID == Item.coal.shiftedIndex) 1042 { 1043 if (--var2.stackSize == 0) 1044 { 1045 par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, (ItemStack)null); 1046 } 1047 1048 this.fuel += 3600; 1049 } 1050 1051 this.pushX = this.posX - par1EntityPlayer.posX; 1052 this.pushZ = this.posZ - par1EntityPlayer.posZ; 1053 } 1054 1055 return true; 1056 } 1057 1058 @SideOnly(Side.CLIENT) 1059 1060 /** 1061 * Sets the position and rotation. Only difference from the other one is no bounding on the rotation. Args: posX, 1062 * posY, posZ, yaw, pitch 1063 */ 1064 public void setPositionAndRotation2(double par1, double par3, double par5, float par7, float par8, int par9) 1065 { 1066 this.minecartX = par1; 1067 this.minecartY = par3; 1068 this.minecartZ = par5; 1069 this.minecartYaw = (double)par7; 1070 this.minecartPitch = (double)par8; 1071 this.turnProgress = par9 + 2; 1072 this.motionX = this.velocityX; 1073 this.motionY = this.velocityY; 1074 this.motionZ = this.velocityZ; 1075 } 1076 1077 /** 1078 * Do not make give this method the name canInteractWith because it clashes with Container 1079 */ 1080 public boolean isUseableByPlayer(EntityPlayer par1EntityPlayer) 1081 { 1082 return this.isDead ? false : par1EntityPlayer.getDistanceSqToEntity(this) <= 64.0D; 1083 } 1084 1085 @SideOnly(Side.CLIENT) 1086 1087 /** 1088 * Sets the velocity to the args. Args: x, y, z 1089 */ 1090 public void setVelocity(double par1, double par3, double par5) 1091 { 1092 this.velocityX = this.motionX = par1; 1093 this.velocityY = this.motionY = par3; 1094 this.velocityZ = this.motionZ = par5; 1095 } 1096 1097 /** 1098 * Is this minecart powered (Fuel > 0) 1099 */ 1100 public boolean isMinecartPowered() 1101 { 1102 return (this.dataWatcher.getWatchableObjectByte(16) & 1) != 0; 1103 } 1104 1105 /** 1106 * Set if this minecart is powered (Fuel > 0) 1107 */ 1108 protected void setMinecartPowered(boolean par1) 1109 { 1110 if (par1) 1111 { 1112 this.dataWatcher.updateObject(16, Byte.valueOf((byte)(this.dataWatcher.getWatchableObjectByte(16) | 1))); 1113 } 1114 else 1115 { 1116 this.dataWatcher.updateObject(16, Byte.valueOf((byte)(this.dataWatcher.getWatchableObjectByte(16) & -2))); 1117 } 1118 } 1119 1120 public void openChest() {} 1121 1122 public void closeChest() {} 1123 1124 /** 1125 * Sets the current amount of damage the minecart has taken. Decreases over time. The cart breaks when this is over 1126 * 40. 1127 */ 1128 public void setDamage(int par1) 1129 { 1130 this.dataWatcher.updateObject(19, Integer.valueOf(par1)); 1131 } 1132 1133 /** 1134 * Gets the current amount of damage the minecart has taken. Decreases over time. The cart breaks when this is over 1135 * 40. 1136 */ 1137 public int getDamage() 1138 { 1139 return this.dataWatcher.getWatchableObjectInt(19); 1140 } 1141 1142 public void func_70497_h(int par1) 1143 { 1144 this.dataWatcher.updateObject(17, Integer.valueOf(par1)); 1145 } 1146 1147 public int func_70496_j() 1148 { 1149 return this.dataWatcher.getWatchableObjectInt(17); 1150 } 1151 1152 public void func_70494_i(int par1) 1153 { 1154 this.dataWatcher.updateObject(18, Integer.valueOf(par1)); 1155 } 1156 1157 public int func_70493_k() 1158 { 1159 return this.dataWatcher.getWatchableObjectInt(18); 1160 } 1161 1162 /** 1163 * Drops the cart as a item. The exact item dropped is defined by getItemDropped(). 1164 */ 1165 public void dropCartAsItem() 1166 { 1167 for(ItemStack item : getItemsDropped()) 1168 { 1169 entityDropItem(item, 0); 1170 } 1171 } 1172 1173 /** 1174 * Override this to define which items your cart drops when broken. 1175 * This does not include items contained in the inventory, 1176 * that is handled elsewhere. 1177 * @return A list of items dropped. 1178 */ 1179 public List<ItemStack> getItemsDropped() 1180 { 1181 List<ItemStack> items = new ArrayList<ItemStack>(); 1182 items.add(new ItemStack(Item.minecartEmpty)); 1183 1184 switch(minecartType) 1185 { 1186 case 1: 1187 items.add(new ItemStack(Block.chest)); 1188 break; 1189 case 2: 1190 items.add(new ItemStack(Block.stoneOvenIdle)); 1191 break; 1192 } 1193 return items; 1194 } 1195 1196 /** 1197 * This function returns an ItemStack that represents this cart. 1198 * This should be an ItemStack that can be used by the player to place the cart. 1199 * This is the item that was registered with the cart via the registerMinecart function, 1200 * but is not necessary the item the cart drops when destroyed. 1201 * @return An ItemStack that can be used to place the cart. 1202 */ 1203 public ItemStack getCartItem() 1204 { 1205 return MinecartRegistry.getItemForCart(this); 1206 } 1207 1208 /** 1209 * Returns true if this cart is self propelled. 1210 * @return True if powered. 1211 */ 1212 public boolean isPoweredCart() 1213 { 1214 return minecartType == 2 && getClass() == EntityMinecart.class; 1215 } 1216 1217 /** 1218 * Returns true if this cart is a storage cart 1219 * Some carts may have inventories but not be storage carts 1220 * and some carts without inventories may be storage carts. 1221 * @return True if this cart should be classified as a storage cart. 1222 */ 1223 public boolean isStorageCart() 1224 { 1225 return minecartType == 1 && getClass() == EntityMinecart.class; 1226 } 1227 1228 /** 1229 * Returns true if this cart can be ridden by an Entity. 1230 * @return True if this cart can be ridden. 1231 */ 1232 public boolean canBeRidden() 1233 { 1234 if(minecartType == 0 && getClass() == EntityMinecart.class) 1235 { 1236 return true; 1237 } 1238 return false; 1239 } 1240 1241 /** 1242 * Returns true if this cart can currently use rails. 1243 * This function is mainly used to gracefully detach a minecart from a rail. 1244 * @return True if the minecart can use rails. 1245 */ 1246 public boolean canUseRail() 1247 { 1248 return canUseRail; 1249 } 1250 1251 /** 1252 * Set whether the minecart can use rails. 1253 * This function is mainly used to gracefully detach a minecart from a rail. 1254 * @param use Whether the minecart can currently use rails. 1255 */ 1256 public void setCanUseRail(boolean use) 1257 { 1258 canUseRail = use; 1259 } 1260 1261 /** 1262 * Return false if this cart should not call IRail.onMinecartPass() and should ignore Powered Rails. 1263 * @return True if this cart should call IRail.onMinecartPass(). 1264 */ 1265 public boolean shouldDoRailFunctions() 1266 { 1267 return true; 1268 } 1269 1270 /** 1271 * Simply returns the minecartType variable. 1272 * @return minecartType 1273 */ 1274 public int getMinecartType() 1275 { 1276 return minecartType; 1277 } 1278 1279 /** 1280 * Gets the current global Minecart Collision handler if none 1281 * is registered, returns null 1282 * @return The collision handler or null 1283 */ 1284 public static IMinecartCollisionHandler getCollisionHandler() 1285 { 1286 return collisionHandler; 1287 } 1288 1289 /** 1290 * Sets the global Minecart Collision handler, overwrites any 1291 * that is currently set. 1292 * @param handler The new handler 1293 */ 1294 public static void setCollisionHandler(IMinecartCollisionHandler handler) 1295 { 1296 collisionHandler = handler; 1297 } 1298 1299 /** 1300 * Carts should return their drag factor here 1301 * @return The drag rate. 1302 */ 1303 protected double getDrag() 1304 { 1305 return riddenByEntity != null ? defaultDragRidden : defaultDragEmpty; 1306 } 1307 1308 /** 1309 * Moved to allow overrides. 1310 * This code applies drag and updates push forces. 1311 */ 1312 protected void applyDragAndPushForces() 1313 { 1314 if(isPoweredCart()) 1315 { 1316 double d27 = MathHelper.sqrt_double(pushX * pushX + pushZ * pushZ); 1317 if(d27 > 0.01D) 1318 { 1319 pushX /= d27; 1320 pushZ /= d27; 1321 double d29 = 0.04; 1322 motionX *= 0.8D; 1323 motionY *= 0.0D; 1324 motionZ *= 0.8D; 1325 motionX += pushX * d29; 1326 motionZ += pushZ * d29; 1327 } 1328 else 1329 { 1330 motionX *= 0.9D; 1331 motionY *= 0.0D; 1332 motionZ *= 0.9D; 1333 } 1334 } 1335 motionX *= getDrag(); 1336 motionY *= 0.0D; 1337 motionZ *= getDrag(); 1338 } 1339 1340 /** 1341 * Moved to allow overrides. 1342 * This code updates push forces. 1343 */ 1344 protected void updatePushForces() 1345 { 1346 if(isPoweredCart()) 1347 { 1348 double push = MathHelper.sqrt_double(pushX * pushX + pushZ * pushZ); 1349 if(push > 0.01D && motionX * motionX + motionZ * motionZ > 0.001D) 1350 { 1351 pushX /= push; 1352 pushZ /= push; 1353 if(pushX * motionX + pushZ * motionZ < 0.0D) 1354 { 1355 pushX = 0.0D; 1356 pushZ = 0.0D; 1357 } 1358 else 1359 { 1360 pushX = motionX; 1361 pushZ = motionZ; 1362 } 1363 } 1364 } 1365 } 1366 1367 /** 1368 * Moved to allow overrides. 1369 * This code handles minecart movement and speed capping when on a rail. 1370 */ 1371 protected void moveMinecartOnRail(int i, int j, int k) 1372 { 1373 int id = worldObj.getBlockId(i, j, k); 1374 if (!BlockRail.isRailBlock(id)) 1375 { 1376 return; 1377 } 1378 float railMaxSpeed = ((BlockRail)Block.blocksList[id]).getRailMaxSpeed(worldObj, this, i, j, k); 1379 1380 double maxSpeed = Math.min(railMaxSpeed, getMaxSpeedRail()); 1381 double mX = motionX; 1382 double mZ = motionZ; 1383 if(riddenByEntity != null) 1384 { 1385 mX *= 0.75D; 1386 mZ *= 0.75D; 1387 } 1388 if(mX < -maxSpeed) mX = -maxSpeed; 1389 if(mX > maxSpeed) mX = maxSpeed; 1390 if(mZ < -maxSpeed) mZ = -maxSpeed; 1391 if(mZ > maxSpeed) mZ = maxSpeed; 1392 moveEntity(mX, 0.0D, mZ); 1393 } 1394 1395 /** 1396 * Moved to allow overrides. 1397 * This code handles minecart movement and speed capping when not on a rail. 1398 */ 1399 protected void moveMinecartOffRail(int i, int j, int k) 1400 { 1401 double d2 = getMaxSpeedGround(); 1402 if(!onGround) 1403 { 1404 d2 = getMaxSpeedAirLateral(); 1405 } 1406 if(motionX < -d2) motionX = -d2; 1407 if(motionX > d2) motionX = d2; 1408 if(motionZ < -d2) motionZ = -d2; 1409 if(motionZ > d2) motionZ = d2; 1410 double moveY = motionY; 1411 if(getMaxSpeedAirVertical() > 0 && motionY > getMaxSpeedAirVertical()) 1412 { 1413 moveY = getMaxSpeedAirVertical(); 1414 if(Math.abs(motionX) < 0.3f && Math.abs(motionZ) < 0.3f) 1415 { 1416 moveY = 0.15f; 1417 motionY = moveY; 1418 } 1419 } 1420 if(onGround) 1421 { 1422 motionX *= 0.5D; 1423 motionY *= 0.5D; 1424 motionZ *= 0.5D; 1425 } 1426 moveEntity(motionX, moveY, motionZ); 1427 if(!onGround) 1428 { 1429 motionX *= getDragAir(); 1430 motionY *= getDragAir(); 1431 motionZ *= getDragAir(); 1432 } 1433 } 1434 1435 /** 1436 * Moved to allow overrides. 1437 * This code applies fuel consumption. 1438 */ 1439 protected void updateFuel() 1440 { 1441 if (fuel > 0) fuel--; 1442 if (fuel <= 0) pushX = pushZ = 0.0D; 1443 setMinecartPowered(fuel > 0); 1444 } 1445 1446 /** 1447 * Moved to allow overrides, This code handle slopes affecting velocity. 1448 * @param metadata The blocks position metadata 1449 */ 1450 protected void adjustSlopeVelocities(int metadata) 1451 { 1452 double acceleration = 0.0078125D; 1453 if (metadata == 2) 1454 { 1455 motionX -= acceleration; 1456 } 1457 else if (metadata == 3) 1458 { 1459 motionX += acceleration; 1460 } 1461 else if (metadata == 4) 1462 { 1463 motionZ += acceleration; 1464 } 1465 else if (metadata == 5) 1466 { 1467 motionZ -= acceleration; 1468 } 1469 } 1470 1471 /** 1472 * Getters/setters for physics variables 1473 */ 1474 1475 /** 1476 * Returns the carts max speed. 1477 * Carts going faster than 1.1 cause issues with chunk loading. 1478 * Carts cant traverse slopes or corners at greater than 0.5 - 0.6. 1479 * This value is compared with the rails max speed to determine 1480 * the carts current max speed. A normal rails max speed is 0.4. 1481 * @return Carts max speed. 1482 */ 1483 public float getMaxSpeedRail() 1484 { 1485 return maxSpeedRail; 1486 } 1487 1488 public void setMaxSpeedRail(float value) 1489 { 1490 maxSpeedRail = value; 1491 } 1492 1493 public float getMaxSpeedGround() 1494 { 1495 return maxSpeedGround; 1496 } 1497 1498 public void setMaxSpeedGround(float value) 1499 { 1500 maxSpeedGround = value; 1501 } 1502 1503 public float getMaxSpeedAirLateral() 1504 { 1505 return maxSpeedAirLateral; 1506 } 1507 1508 public void setMaxSpeedAirLateral(float value) 1509 { 1510 maxSpeedAirLateral = value; 1511 } 1512 1513 public float getMaxSpeedAirVertical() 1514 { 1515 return maxSpeedAirVertical; 1516 } 1517 1518 public void setMaxSpeedAirVertical(float value) 1519 { 1520 maxSpeedAirVertical = value; 1521 } 1522 1523 public double getDragAir() 1524 { 1525 return dragAir; 1526 } 1527 1528 public void setDragAir(double value) 1529 { 1530 dragAir = value; 1531 } 1532 }