Advertisement
Guest User

TestEntity

a guest
Sep 3rd, 2015
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.73 KB | None | 0 0
  1. package com.vincentmet.modelrailroad.entities.TEST2;
  2.  
  3. import net.minecraft.entity.passive.EntityAmbientCreature;
  4. import net.minecraft.entity.player.EntityPlayer;
  5. import net.minecraft.world.World;
  6. import cpw.mods.fml.relauncher.Side;
  7. import cpw.mods.fml.relauncher.SideOnly;
  8.  
  9. public class TestEntity extends EntityAmbientCreature{
  10.  
  11.     public boolean stationary;
  12.    
  13.     public TestEntity(World world) {
  14.         super(world);
  15.     }
  16.    
  17.     public TestEntity(World world, int x, int y, int z) {
  18.         super(world);
  19.     }
  20.    
  21.     protected boolean canDespawn(){
  22.         return false;
  23.     }
  24.    
  25.     public boolean interact(EntityPlayer entityplayer){
  26.         if (riddenByEntity == null || riddenByEntity == entityplayer){
  27.             entityplayer.mountEntity(this);
  28.             return true;
  29.         }else{
  30.             return false;
  31.         }
  32.     }
  33.    
  34.     public void moveEntity(double d, double d1, double d2){
  35.         if (riddenByEntity != null){
  36.             this.prevRotationYaw = this.rotationYaw = this.riddenByEntity.rotationYaw;
  37.             this.rotationPitch = this.riddenByEntity.rotationPitch * 0.5F;
  38.             this.setRotation(this.rotationYaw, this.rotationPitch);
  39.             this.rotationYawHead = this.renderYawOffset = this.rotationYaw;
  40.             stationary = true;
  41.             motionX += riddenByEntity.motionX * 10;
  42.             motionZ += riddenByEntity.motionZ * 10;
  43.             if (isCollidedHorizontally){
  44.                 isJumping = true;
  45.             }else{
  46.                 isJumping = false;
  47.             }
  48.             super.moveEntity(motionX, motionY, motionZ);
  49.         }else{
  50.             stationary = false;
  51.             super.moveEntity(d, d1, d2);
  52.         }
  53.     }
  54.    
  55.     public void onUpdate(){
  56.         super.onUpdate();
  57.         if (riddenByEntity != null){
  58.             this.randomYawVelocity = 0;
  59.             this.rotationYaw = riddenByEntity.rotationYaw;
  60.         }
  61.     }
  62.     protected boolean isAIEnabled(){
  63.         return true;
  64.     }
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement