Advertisement
Corosus

Untitled

Dec 4th, 2012
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 22.09 KB | None | 0 0
  1. package net.tropicraft.entities;
  2.  
  3. import java.io.IOException;
  4. import java.util.List;
  5.  
  6. import net.minecraft.client.Minecraft;
  7. import net.minecraft.src.AxisAlignedBB;
  8. import net.minecraft.src.Block;
  9. import net.minecraft.src.DamageSource;
  10. import net.minecraft.src.Entity;
  11. import net.minecraft.src.EntityAITasks;
  12. import net.minecraft.src.EntityCreature;
  13. import net.minecraft.src.EntityCreeper;
  14. import net.minecraft.src.EntityEnderman;
  15. import net.minecraft.src.EntityLiving;
  16. import net.minecraft.src.EntityPlayer;
  17. import net.minecraft.src.GameSettings;
  18. import net.minecraft.src.GuiIngame;
  19. import net.minecraft.src.ItemStack;
  20. import net.minecraft.src.KeyBinding;
  21. import net.minecraft.src.MathHelper;
  22. import net.minecraft.src.ModLoader;
  23. import net.minecraft.src.MovingObjectPosition;
  24. import net.minecraft.src.NBTTagCompound;
  25. import net.minecraft.src.Vec3;
  26. import net.minecraft.src.World;
  27. import net.tropicraft.mods.TropicraftMod;
  28.  
  29. import org.lwjgl.opengl.GL11;
  30.  
  31. import cpw.mods.fml.client.FMLClientHandler;
  32. import cpw.mods.fml.common.Side;
  33. import cpw.mods.fml.common.asm.SideOnly;
  34.  
  35. public class EntityDart extends Entity {
  36.  
  37.     GuiIngame gui;
  38.     Minecraft mc;
  39.     public GameSettings gamesettings;
  40.     public double sinc;
  41.     public int k;
  42.     private float herp;
  43.     private float moveSpeedAct;
  44.     private int xTile;
  45.     private int yTile;
  46.     private int zTile;
  47.     private int inTile;
  48.     private int inData;
  49. /*  private int up;
  50.     private int down;
  51.     private int left;
  52.     private int right;
  53.     private int attack;
  54.     private int use;
  55.     private int jump; */
  56. //  public float mouse;
  57.     public float Fov;
  58.     private boolean inGround;
  59.     public boolean doesDartBelongToPlayer;
  60.     public int dartShake;
  61.     public EntityLiving owner;
  62.     private int ticksInGround;
  63.     private int ticksInAir;
  64.     public float prevYaw;
  65.     public float prevPitch;
  66.     public double prevPosX;
  67.     public double prevPosY;
  68.     public double prevPosZ;
  69.     private boolean hasRidden;
  70.     public EntityAITasks prevTasks = null;
  71.  
  72.     public EntityDart(World world) {
  73.         super(world);
  74.         prevTasks = null;
  75.         xTile = -1;
  76.         yTile = -1;
  77.         zTile = -1;
  78.         inTile = 0;
  79.         inData = 0;
  80.         inGround = false;
  81.         doesDartBelongToPlayer = false;
  82.         dartShake = 0;
  83.         ticksInAir = 0;
  84.         setSize(0.125F, 0.125F);
  85.         herp = -20F;
  86.  
  87.     }
  88.  
  89.     public EntityDart(World world, double d, double d1, double d2) {
  90.         super(world);
  91.         prevTasks = null;
  92.         xTile = -1;
  93.         yTile = -1;
  94.         zTile = -1;
  95.         inTile = 0;
  96.         inData = 0;
  97.         inGround = false;
  98.         doesDartBelongToPlayer = false;
  99.         dartShake = 0;
  100.         ticksInAir = 0;
  101.         setSize(0.5F, 0.5F);
  102.         setPosition(d, d1, d2);
  103.         yOffset = 0.0F;
  104.     }
  105.  
  106.     public EntityDart(World world, EntityLiving entityliving, float f) {
  107.         super(world);
  108.         prevTasks = null;
  109.         xTile = -1;
  110.         yTile = -1;
  111.         zTile = -1;
  112.         inTile = 0;
  113.         inData = 0;
  114.         inGround = false;
  115.         doesDartBelongToPlayer = false;
  116.         dartShake = 0;
  117.         ticksInAir = 0;
  118.         owner = entityliving;
  119.         doesDartBelongToPlayer = entityliving instanceof EntityPlayer;
  120.         setSize(0.5F, 0.5F);
  121.         setLocationAndAngles(entityliving.posX, entityliving.posY
  122.                 + (double) entityliving.getEyeHeight(), entityliving.posZ,
  123.                 entityliving.rotationYaw, entityliving.rotationPitch);
  124.         posX -= MathHelper.cos((rotationYaw / 180F) * 3.141593F) * 0.16F;
  125.         posY -= 0.10000000149011612D;
  126.         posZ -= MathHelper.sin((rotationYaw / 180F) * 3.141593F) * 0.16F;
  127.         setPosition(posX, posY, posZ);
  128.         yOffset = 0.0F;
  129.         motionX = -MathHelper.sin((rotationYaw / 180F) * 3.141593F)
  130.                 * MathHelper.cos((rotationPitch / 180F) * 3.141593F);
  131.         motionZ = MathHelper.cos((rotationYaw / 180F) * 3.141593F)
  132.                 * MathHelper.cos((rotationPitch / 180F) * 3.141593F);
  133.         motionY = -MathHelper.sin((rotationPitch / 180F) * 3.141593F);
  134.         setArrowHeading(motionX, motionY, motionZ, f * 1.75F, 1.0F);
  135.         /*up = ModLoader.getMinecraftInstance().gameSettings.keyBindForward.keyCode;
  136.         down = ModLoader.getMinecraftInstance().gameSettings.keyBindBack.keyCode;
  137.         left = ModLoader.getMinecraftInstance().gameSettings.keyBindLeft.keyCode;
  138.         right = ModLoader.getMinecraftInstance().gameSettings.keyBindRight.keyCode;
  139.         attack = ModLoader.getMinecraftInstance().gameSettings.keyBindAttack.keyCode;
  140.         use = ModLoader.getMinecraftInstance().gameSettings.keyBindUseItem.keyCode;
  141.         jump = ModLoader.getMinecraftInstance().gameSettings.keyBindJump.keyCode;
  142.         mouse = ModLoader.getMinecraftInstance().gameSettings.mouseSensitivity;*/
  143.     //  Fov = ModLoader.getMinecraftInstance().gameSettings.fovSetting;
  144.         Fov = TropicraftMod.proxy.getFOV();
  145.         sinc = 0.0D;
  146.         k = 0;
  147.         hasRidden = false;
  148.         // System.out.println("Rotation Yaw = " + rotationYaw);
  149.     }
  150.  
  151.     @Override
  152.     protected void entityInit() {
  153.         prevTasks = null;
  154.     }
  155.  
  156.     public void setArrowHeading(double d, double d1, double d2, float f,
  157.             float f1) {
  158.         float f2 = MathHelper.sqrt_double(d * d + d1 * d1 + d2 * d2);
  159.         d /= f2;
  160.         d1 /= f2;
  161.         d2 /= f2;
  162.         d += rand.nextGaussian() * .0074999998323619366D * (double) f1;
  163.         d1 += rand.nextGaussian() * 0.0074999998323619366D * (double) f1;
  164.         d2 += rand.nextGaussian() * 0.0074999998323619366D * (double) f1;
  165.         d *= f;
  166.         d1 *= f;
  167.         d2 *= f;
  168.         motionX = d;
  169.         motionY = d1;
  170.         motionZ = d2;
  171.         float f3 = MathHelper.sqrt_double(d * d + d2 * d2);
  172.         prevRotationYaw = rotationYaw = (float) ((Math.atan2(d, d2) * 180D) / 3.1415927410125732D);
  173.         prevRotationPitch = rotationPitch = (float) ((Math.atan2(d1, f3) * 180D) / 3.1415927410125732D);
  174.         ticksInGround = 0;
  175.     }
  176.  
  177.     /*@Override
  178.     public void setVelocity(double d, double d1, double d2) {
  179.         motionX = d;
  180.         motionY = d1;
  181.         motionZ = d2;
  182.         if (prevRotationPitch == 0.0F && prevRotationYaw == 0.0F) {
  183.             float f = MathHelper.sqrt_double(d * d + d2 * d2);
  184.             prevRotationYaw = rotationYaw = (float) ((Math.atan2(d, d2) * 180D) / 3.1415927410125732D);
  185.             prevRotationPitch = rotationPitch = (float) ((Math.atan2(d1, f) * 180D) / 3.1415927410125732D);
  186.             prevRotationPitch = rotationPitch;
  187.             prevRotationYaw = rotationYaw;
  188.             setLocationAndAngles(posX, posY, posZ, rotationYaw, rotationPitch);
  189.             ticksInGround = 0;
  190.         }
  191.     } */
  192.  
  193.     @Override
  194.     public void onUpdate() {
  195.         super.onUpdate();
  196.         if (prevRotationPitch == 0.0F && prevRotationYaw == 0.0F) {
  197.             float f = MathHelper.sqrt_double(motionX * motionX + motionZ
  198.                     * motionZ);
  199.             prevRotationYaw = rotationYaw = (float) ((Math.atan2(motionX,
  200.                     motionZ) * 180D) / 3.1415927410125732D);
  201.             prevRotationPitch = rotationPitch = (float) ((Math
  202.                     .atan2(motionY, f) * 180D) / 3.1415927410125732D);
  203.         }
  204.  
  205.         int i = worldObj.getBlockId(xTile, yTile, zTile);
  206.         if (i > 0) {
  207.             Block.blocksList[i].setBlockBoundsBasedOnState(worldObj, xTile,
  208.                     yTile, zTile);
  209.             AxisAlignedBB axisalignedbb = Block.blocksList[i]
  210.                     .getCollisionBoundingBoxFromPool(worldObj, xTile, yTile,
  211.                             zTile);
  212.             if (axisalignedbb != null
  213.                     && axisalignedbb.isVecInside(Vec3.createVectorHelper(posX, posY, posZ))) {
  214.                 inGround = true;
  215.             }
  216.         }
  217.  
  218.         if (dartShake > 0) {
  219.             dartShake--;
  220.         }
  221.  
  222.         if (inGround) {
  223.             int j = worldObj.getBlockId(xTile, yTile, zTile);
  224.             int k = worldObj.getBlockMetadata(xTile, yTile, zTile);
  225.             if (j != inTile || k != inData) {
  226.                 inGround = false;
  227.                 motionX *= rand.nextFloat() * 0.2F;
  228.                 motionY *= rand.nextFloat() * 0.2F;
  229.                 motionZ *= rand.nextFloat() * 0.2F;
  230.                 ticksInGround = 0;
  231.                 ticksInAir = 0;
  232.                 return;
  233.             }
  234.             ticksInGround++;
  235.             if (ticksInGround == 1200) {
  236.                 setDead();
  237.             }
  238.             return;
  239.         }
  240.         ticksInAir++;
  241.         Vec3 vec3d = Vec3.createVectorHelper(posX, posY, posZ);
  242.         Vec3 vec3d1 = Vec3.createVectorHelper(posX + motionX,
  243.                 posY + motionY, posZ + motionZ);
  244.         MovingObjectPosition movingobjectposition = worldObj
  245.                 .rayTraceBlocks_do_do(vec3d, vec3d1, false, true);
  246.         vec3d = Vec3.createVectorHelper(posX, posY, posZ);
  247.         vec3d1 = Vec3.createVectorHelper(posX + motionX,
  248.                 posY + motionY, posZ + motionZ);
  249.         if (movingobjectposition != null) {
  250.             vec3d1 = Vec3.createVectorHelper(
  251.                     movingobjectposition.hitVec.xCoord,
  252.                     movingobjectposition.hitVec.yCoord,
  253.                     movingobjectposition.hitVec.zCoord);
  254.         }
  255.         Entity entity = null;
  256.         List list = worldObj.getEntitiesWithinAABBExcludingEntity(
  257.                 this,
  258.                 boundingBox.addCoord(motionX, motionY, motionZ).expand(1.0D,
  259.                         1.0D, 1.0D));
  260.  
  261.  
  262.         if (worldObj.isRemote) list = null;
  263.  
  264.         double d = 0.0D;
  265.         if (list != null) {
  266.             for (int l = 0; l < list.size(); l++) {
  267.                 Entity entity1 = (Entity) list.get(l);
  268.                 if (!entity1.canBeCollidedWith() || entity1 == owner
  269.                         && ticksInAir < 10) {
  270.                     continue;
  271.                 }
  272.                 float f4 = 0.3F;
  273.                 AxisAlignedBB axisalignedbb1 = entity1.boundingBox.expand(f4, f4,
  274.                         f4);
  275.                 MovingObjectPosition movingobjectposition1 = axisalignedbb1
  276.                         .calculateIntercept(vec3d, vec3d1);
  277.                 if (movingobjectposition1 == null) {
  278.                     continue;
  279.                 }
  280.                 double d1 = vec3d.distanceTo(movingobjectposition1.hitVec);
  281.                 if (d1 < d || d == 0.0D) {
  282.                     entity = entity1;
  283.                     d = d1;
  284.                 }
  285.             }
  286.         }
  287.  
  288.         if (entity != null) {
  289.             movingobjectposition = new MovingObjectPosition(entity);
  290.         }
  291.         if (movingobjectposition != null) {
  292.             if (movingobjectposition.entityHit != null) {
  293.                 if (!(movingobjectposition.entityHit instanceof EntityLiving)) {
  294.                     movingobjectposition.entityHit
  295.                     .attackEntityFrom(DamageSource
  296.                             .causePlayerDamage((EntityPlayer) owner), 1);
  297.                     this.setDead();
  298.                     return;
  299.                 }
  300.                 if (movingobjectposition.entityHit instanceof EntityEIH
  301.                         || movingobjectposition.entityHit instanceof EntityEnderman) { // makes
  302.                     // the
  303.                     // dart
  304.                     // bounce
  305.                     // off
  306.                     // EIH
  307.                     motionX *= -.01D;
  308.                     motionY *= .5D;
  309.                     motionZ *= -.01D;
  310.                     rotationYaw += 180F;
  311.                     prevRotationYaw += 180F;
  312.                     ticksInAir = 0;
  313.  
  314.                     return;
  315.                 }
  316.                 if (entity.riddenByEntity instanceof EntityDart) { // prevents
  317.                     // endless
  318.                     // paralysis
  319.                     motionX *= 0D;
  320.                     motionY *= 0D;
  321.                     motionZ *= 0D;
  322.                     rotationYaw += 180F;
  323.                     prevRotationYaw += 180F;
  324.                     ticksInAir = 0;
  325.                     return;
  326.                 }
  327.                 if (movingobjectposition.entityHit instanceof EntityPlayer) {
  328.                     //try {
  329.                     //TropicraftMod.dartSettings.dupeOptions(1);
  330.                     //} catch (IOException e) {
  331.                     // TODO Auto-generated catch block
  332.                     //e.printStackTrace();
  333.                     //}
  334.                     mountEntity(entity);
  335.                     herp = -20;
  336.                 }
  337.                 if (movingobjectposition.entityHit.attackEntityFrom(
  338.                         DamageSource.causeMobDamage(owner), 0)) { // mounts
  339.                     // entity on
  340.                     // hit
  341.  
  342.                     k = 0;
  343.                     if (entity instanceof EntityLiving) {
  344.                         moveSpeedAct = EntityDartHelper
  345.                                 .getEntityMoveSpeed((EntityLiving) entity);
  346.                     }
  347.  
  348.                     mountEntity(entity);
  349.                     movingobjectposition.entityHit.velocityChanged = false;
  350.  
  351.                     worldObj.playSoundAtEntity(this, "darthit", 1.0F,
  352.                             1.2F / (rand.nextFloat() * 0.2F + 0.9F));
  353.  
  354.                 } else { // this sends the arrow back if the enemy mob is
  355.                     // cooling down
  356.                     motionX *= 0D;
  357.                     motionY *= 0D;
  358.                     motionZ *= 0D;
  359.                     rotationYaw += 180F;
  360.                     prevRotationYaw += 180F;
  361.                     ticksInAir = 0;
  362.                 }
  363.             } else { // how far it sticks in
  364.                 xTile = movingobjectposition.blockX;
  365.                 yTile = movingobjectposition.blockY;
  366.                 zTile = movingobjectposition.blockZ;
  367.                 inTile = worldObj.getBlockId(xTile, yTile, zTile);
  368.                 inData = worldObj.getBlockMetadata(xTile, yTile, zTile);
  369.                 motionX = (float) (movingobjectposition.hitVec.xCoord - posX);
  370.                 motionY = (float) (movingobjectposition.hitVec.yCoord - posY);
  371.                 motionZ = (float) (movingobjectposition.hitVec.zCoord - posZ);
  372.                 float f1 = MathHelper.sqrt_double(motionX * motionX + motionY
  373.                         * motionY + motionZ * motionZ);
  374.                 posX -= (motionX / (double) f1) * 0.05000000074505806D;
  375.                 posY -= (motionY / (double) f1) * 0.05000000074505806D;
  376.                 posZ -= (motionZ / (double) f1) * 0.05000000074505806D;
  377.                 worldObj.playSoundAtEntity(this, "darthit", 1.0F,
  378.                         1.2F / (rand.nextFloat() * 0.2F + 0.9F));
  379.                 inGround = true;
  380.                 dartShake = 7; // sets time arrow vibrates
  381.             }
  382.         }
  383.  
  384.         if (((worldObj.isRemote && ridingEntity instanceof EntityPlayer) || !worldObj.isRemote) && ((this.ridingEntity != null && ridingEntity.shouldRiderSit()) || this.getFlag(2))) { // applies status effect
  385.             if (prevTasks == null && ridingEntity instanceof EntityLiving) {
  386.                 prevTasks = EntityDartHelper
  387.                         .getEntityAITasks((EntityLiving) ridingEntity);
  388.             }
  389.  
  390.             if (k < 135) {
  391.                 paralyze(ridingEntity);
  392.             } else {
  393.  
  394.                 if (ridingEntity instanceof EntityLiving) {
  395.                     EntityDartHelper.setEntityAITasks(
  396.                             (EntityLiving) ridingEntity, prevTasks);
  397.                     EntityDartHelper.setEntityMoveSpeed(
  398.                             (EntityLiving) ridingEntity, moveSpeedAct);
  399.                 }
  400.  
  401.                 if (ridingEntity instanceof EntityPlayer) {
  402.                     /*      ModLoader.getMinecraftInstance().gameSettings.keyBindForward = new KeyBinding(
  403.                             "key.forward", up);
  404.                     ModLoader.getMinecraftInstance().gameSettings.keyBindBack = new KeyBinding(
  405.                             "key.back", down);
  406.                     ModLoader.getMinecraftInstance().gameSettings.keyBindLeft = new KeyBinding(
  407.                             "key.left", left);
  408.                     ModLoader.getMinecraftInstance().gameSettings.keyBindRight = new KeyBinding(
  409.                             "key.right", right);
  410.                     ModLoader.getMinecraftInstance().gameSettings.keyBindAttack = new KeyBinding(
  411.                             "key.attack", attack);
  412.                     ModLoader.getMinecraftInstance().gameSettings.keyBindUseItem = new KeyBinding(
  413.                             "key.use", use);
  414.                     ModLoader.getMinecraftInstance().gameSettings.keyBindJump = new KeyBinding(
  415.                             "key.jump", jump);
  416.                     ModLoader.getMinecraftInstance().gameSettings.mouseSensitivity = mouse; */
  417.                     if(worldObj.isRemote && ((EntityPlayer)ridingEntity).username.equals(getClientUsername())) TropicraftMod.proxy.setFOV(Fov);
  418.                 }
  419.                 setDead();
  420.             }
  421.             k++;
  422.         }
  423.         if (hasRidden && ridingEntity == null) {
  424.             /*      ModLoader.getMinecraftInstance().gameSettings.keyBindForward = new KeyBinding(
  425.                     "key.forward", up);
  426.             ModLoader.getMinecraftInstance().gameSettings.keyBindBack = new KeyBinding(
  427.                     "key.back", down);
  428.             ModLoader.getMinecraftInstance().gameSettings.keyBindLeft = new KeyBinding(
  429.                     "key.left", left);
  430.             ModLoader.getMinecraftInstance().gameSettings.keyBindRight = new KeyBinding(
  431.                     "key.right", right);
  432.             ModLoader.getMinecraftInstance().gameSettings.keyBindAttack = new KeyBinding(
  433.                     "key.attack", attack);
  434.             ModLoader.getMinecraftInstance().gameSettings.keyBindUseItem = new KeyBinding(
  435.                     "key.use", use);
  436.             ModLoader.getMinecraftInstance().gameSettings.keyBindJump = new KeyBinding(
  437.                     "key.jump", jump);
  438.             ModLoader.getMinecraftInstance().gameSettings.mouseSensitivity = mouse;
  439.             ModLoader.getMinecraftInstance().gameSettings.fovSetting = Fov; */
  440.             if(worldObj.isRemote && ((EntityPlayer)ridingEntity).username.equals(getClientUsername()))
  441.                 TropicraftMod.proxy.setFOV(Fov);
  442.             hasRidden = false;
  443.         }
  444.  
  445.         posX += motionX;
  446.         posY += motionY;
  447.         posZ += motionZ;
  448.         float f2 = MathHelper
  449.                 .sqrt_double(motionX * motionX + motionZ * motionZ);
  450.         rotationYaw = (float) ((Math.atan2(motionX, motionZ) * 180D) / 3.1415927410125732D);
  451.         for (rotationPitch = (float) ((Math.atan2(motionY, f2) * 180D) / 3.1415927410125732D); rotationPitch
  452.                 - prevRotationPitch < -180F; prevRotationPitch -= 360F) {
  453.         }
  454.         for (; rotationPitch - prevRotationPitch >= 180F; prevRotationPitch += 360F) {
  455.         }
  456.         for (; rotationYaw - prevRotationYaw < -180F; prevRotationYaw -= 360F) {
  457.         }
  458.         for (; rotationYaw - prevRotationYaw >= 180F; prevRotationYaw += 360F) {
  459.         }
  460.         rotationPitch = prevRotationPitch + (rotationPitch - prevRotationPitch)
  461.                 * 0.2F;
  462.         rotationYaw = prevRotationYaw + (rotationYaw - prevRotationYaw) * 0.2F;
  463.         float f3 = 0.99F;
  464.         float f5 = 0.03F;
  465.         if (isInWater()) {
  466.             for (int i1 = 0; i1 < 4; i1++) {
  467.                 float f6 = 0.25F;
  468.                 worldObj.spawnParticle("bubble", posX - motionX * (double) f6,
  469.                         posY - motionY * (double) f6, posZ - motionZ
  470.                         * (double) f6, motionX, motionY, motionZ);
  471.             }
  472.  
  473.             f3 = 0.8F;
  474.         }
  475.  
  476.         motionX *= f3;
  477.         motionY *= f3;
  478.         motionZ *= f3;
  479.         motionY -= f5;
  480.         setPosition(posX, posY, posZ);
  481.  
  482.     }
  483.    
  484.     @SideOnly(Side.CLIENT)
  485.     public String getClientUsername() {
  486.         if (mc == null) mc = FMLClientHandler.instance().getClient();
  487.         if (mc.thePlayer != null) return mc.thePlayer.username;
  488.         return "";
  489.     }
  490.  
  491.     public static int sign(double f) {
  492.         if (f != f) {
  493.             throw new IllegalArgumentException("NaN");
  494.         }
  495.         if (f == 0) {
  496.             return 0;
  497.         }
  498.         f *= Double.POSITIVE_INFINITY;
  499.         if (f == Double.POSITIVE_INFINITY) {
  500.             return +1;
  501.         }
  502.         if (f == Double.NEGATIVE_INFINITY) {
  503.             return -1;
  504.         }
  505.  
  506.         // this should never be reached, but I've been wrong before...
  507.         throw new IllegalArgumentException("Unfathomed double");
  508.     }
  509.  
  510.     public void writeEntityToNBT(NBTTagCompound nbttagcompound) {
  511.         nbttagcompound.setShort("xTile", (short) xTile);
  512.         nbttagcompound.setShort("yTile", (short) yTile);
  513.         nbttagcompound.setShort("zTile", (short) zTile);
  514.         nbttagcompound.setByte("inTile", (byte) inTile);
  515.         nbttagcompound.setByte("inData", (byte) inData);
  516.         nbttagcompound.setByte("shake", (byte) dartShake);
  517.         nbttagcompound.setByte("inGround", (byte) (inGround ? 1 : 0));
  518.         nbttagcompound.setBoolean("player", doesDartBelongToPlayer);
  519.  
  520.     }
  521.  
  522.     public void readEntityFromNBT(NBTTagCompound nbttagcompound) {
  523.         xTile = nbttagcompound.getShort("xTile");
  524.         yTile = nbttagcompound.getShort("yTile");
  525.         zTile = nbttagcompound.getShort("zTile");
  526.         inTile = nbttagcompound.getByte("inTile") & 0xff;
  527.         inData = nbttagcompound.getByte("inData") & 0xff;
  528.         dartShake = nbttagcompound.getByte("shake") & 0xff;
  529.         inGround = nbttagcompound.getByte("inGround") == 1;
  530.         doesDartBelongToPlayer = nbttagcompound.getBoolean("player");
  531.  
  532.     }
  533.  
  534.     public void onCollideWithPlayer(EntityPlayer entityplayer) {
  535.         if (worldObj.isRemote) {
  536.             return;
  537.         }
  538.         if (inGround
  539.                 && doesDartBelongToPlayer
  540.                 && dartShake <= 0
  541.                 && entityplayer.inventory
  542.                 .addItemStackToInventory(new ItemStack(
  543.                         TropicraftMod.paraDart, 1))) {
  544.             worldObj.playSoundAtEntity(
  545.                     this,
  546.                     "random.pop",
  547.                     0.2F,
  548.                     ((rand.nextFloat() - rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
  549.             entityplayer.onItemPickup(this, 1);
  550.             setDead();
  551.         }
  552.     }
  553.  
  554.     public float getShadowSize() {
  555.         return 0.0F;
  556.     }
  557.    
  558.     public void setVelocity1(double par1, double par3, double par5)
  559.     {
  560.         this.motionX = par1;
  561.         this.motionY = par3;
  562.         this.motionZ = par5;
  563.     }
  564.  
  565.     public void paralyze(Entity entity) { // contains status effect
  566.         if (entity instanceof EntityLiving) {
  567.  
  568.             if (entity instanceof EntityCreeper) {
  569.                 EntityDartHelper.setCreeperIgnitionTime((EntityCreeper) entity,
  570.                         0);
  571.             }
  572.  
  573.             entity.rotationYaw = entity.prevRotationYaw;
  574.             if (entity instanceof EntityCreature) {
  575.                 EntityDartHelper.setEntityToAttack((EntityCreature) entity,
  576.                         null);
  577.             }
  578.  
  579.             EntityDartHelper.setEntityAttackTime((EntityLiving) entity, 60);
  580.             EntityDartHelper.setEntityMoveSpeed((EntityLiving) entity, 0);
  581.             EntityDartHelper.setIsEntityJumping((EntityLiving) entity, false);
  582.  
  583.             if (entity.onGround) {
  584.                 //entity.setVelocity1(0D, -.5D, 0D);
  585.                 entity.motionX = 0;
  586.                 entity.motionY = 0;
  587.                 entity.motionZ = 0;
  588.                 entity.posX = ((EntityLiving) entity).lastTickPosX;
  589.                 entity.posY = ((EntityLiving) entity).lastTickPosY;
  590.                 entity.posZ = ((EntityLiving) entity).lastTickPosZ;
  591.                 // ((EntityCreature)entity).lastTickPosX = entity.prevPosX;
  592.                 // ((EntityCreature)entity).lastTickPosY = entity.prevPosY;
  593.                 // ((EntityCreature)entity).lastTickPosZ = entity.prevPosZ;
  594.                 entity.rotationPitch = entity.prevRotationPitch;
  595.                 entity.rotationYaw = entity.prevRotationYaw;
  596.             } else {
  597.             //  entity.setVelocity(0D, -.5D, 0D);
  598.                 entity.motionX = 0;
  599.                 entity.motionY = -.5D;
  600.                 entity.motionZ = 0;
  601.                 entity.posX = ((EntityLiving) entity).lastTickPosX;
  602.                 // entity.posY = ((EntityLiving)entity).lastTickPosY;
  603.                 entity.posZ = ((EntityLiving) entity).lastTickPosZ;
  604.                 entity.rotationPitch = entity.prevRotationPitch;
  605.                 entity.rotationYaw = entity.prevRotationYaw;
  606.  
  607.                 if ((int) entity.posY > worldObj.getHeightValue(
  608.                         (int) entity.posX, (int) entity.posY)) {
  609.                     // entity.set
  610.                     entity.motionY = -0.5D;
  611.                 }
  612.             }
  613.             // ((EntityCreature)entity).numTicksToChaseTarget = 0;
  614.             // entity.onGround = false;
  615.  
  616.             EntityDartHelper.setEntityAITasks((EntityLiving) entity, null);
  617.         }
  618.         if (entity instanceof EntityPlayer) {
  619.             hasRidden = true;
  620.             /*  ModLoader.getMinecraftInstance().gameSettings.keyBindForward = new KeyBinding(
  621.                     "key.forward", 99);
  622.             ModLoader.getMinecraftInstance().gameSettings.keyBindBack = new KeyBinding(
  623.                     "key.back", 100);
  624.             ModLoader.getMinecraftInstance().gameSettings.keyBindLeft = new KeyBinding(
  625.                     "key.left", 101);
  626.             ModLoader.getMinecraftInstance().gameSettings.keyBindRight = new KeyBinding(
  627.                     "key.right", 102);
  628.             ModLoader.getMinecraftInstance().gameSettings.keyBindAttack = new KeyBinding(
  629.                     "key.attack", 103);
  630.             ModLoader.getMinecraftInstance().gameSettings.keyBindUseItem = new KeyBinding(
  631.                     "key.use", 104);
  632.             ModLoader.getMinecraftInstance().gameSettings.keyBindJump = new KeyBinding(
  633.                     "key.jump", 105);
  634.             ModLoader.getMinecraftInstance().gameSettings.mouseSensitivity = 0.0F; */
  635.             if(worldObj.isRemote && ((EntityPlayer)ridingEntity).username.equals(getClientUsername())) trollFOV((EntityPlayer)entity);
  636.  
  637.         }
  638.  
  639.     }
  640.  
  641.     protected boolean canTriggerWalking() {
  642.         return false;
  643.     }
  644.  
  645.     public void trollFOV(EntityPlayer entity) {
  646.  
  647.         sinc = (100D - (double) k) * .125D;
  648.         float trollov = 0F;
  649.         if (k <= 126) {
  650.             trollov = Fov + (float) ((Math.sin(sinc)) / sinc);
  651.         }
  652.         if (k == 100) {
  653.             trollov = Fov + 1;
  654.         }
  655.         if (k > 125) {
  656.             if (herp == -20F && entity.worldObj.isRemote) {
  657.                 herp = (TropicraftMod.proxy.getFOV() - Fov) / 10;
  658.             }
  659.             if (entity.worldObj.isRemote) {
  660.                 trollov = TropicraftMod.proxy.getFOV() - herp;
  661.             }
  662.         }
  663.  
  664.         if (entity.worldObj.isRemote)
  665.             TropicraftMod.proxy.setFOV(trollov);
  666.  
  667.     }
  668.  
  669.     public void mountEntity(Entity entity) {
  670.         super.mountEntity(entity);
  671.     }
  672.  
  673.     private void trollRender(int k, int i, int j) {
  674.         float f = 1.0F / (float) k * .9F;
  675.         GL11.glDisable(3008 /*
  676.          * GL_ALPHA_TEST
  677.          */);
  678.         GL11.glDisable(2929 /*
  679.          * GL_DEPTH_TEST
  680.          */);
  681.         GL11.glDepthMask(false);
  682.         GL11.glBlendFunc(770, 771);
  683.         GL11.glColor4f(1.0F, .5F, 1.0F, 1.0F);
  684.  
  685.     }
  686. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement