TechMage66

EssenceBeamRenderer

May 16th, 2015
368
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.73 KB | None | 0 0
  1. package com.techmage.magetech.client.render.tileentity;
  2.  
  3. import com.techmage.magetech.utility.Location;
  4. import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
  5. import net.minecraft.entity.Entity;
  6. import net.minecraft.tileentity.TileEntity;
  7. import net.minecraft.util.ResourceLocation;
  8. import net.minecraftforge.common.util.ForgeDirection;
  9.  
  10. public class EssenceBeamRenderer extends TileEntitySpecialRenderer
  11. {
  12.  
  13.     public Float pixel = 1F / 16F;
  14.  
  15.     @Override
  16.     public void renderTileEntityAt(TileEntity tile, double translateX, double translateY, double translateZ, float f)
  17.     {
  18.  
  19.     }
  20.  
  21.     public void renderBeam(Location source, Location dest)
  22.     {
  23.         ForgeDirection dir = getBeamDirection (source, dest);
  24.         int dist = getBeamDistance(source, dest);
  25.  
  26.         switch (dir)
  27.         {
  28.             case NORTH:
  29.                 //renderBeamNorth(dist);
  30.                 break;
  31.             case SOUTH:
  32.                 //renderBeamSouth(dist);
  33.                 break;
  34.             case WEST:
  35.                 //renderBeamWest(dist);
  36.                 break;
  37.             case EAST:
  38.                 //renderBeamEast(dist);
  39.                 break;
  40.             case UP:
  41.                 //renderBeamUp(dist);
  42.                 break;
  43.             case DOWN:
  44.                 //renderBeamDown(dist);
  45.                 break;
  46.             default:
  47.                 break;
  48.         }
  49.     }
  50.  
  51.     public ForgeDirection getBeamDirection(Location source, Location dest)
  52.     {
  53.         int difX = source.x - dest.x;
  54.         int difY = source.y - dest.y;
  55.         int difZ = source.z - dest.z;
  56.  
  57.         if (difX == 0 && difY == 0 && difZ > 0)
  58.             return ForgeDirection.NORTH;
  59.         if (difX == 0 && difY == 0 && difZ < 0)
  60.             return ForgeDirection.SOUTH;
  61.  
  62.         if (difX > 0 && difY == 0 && difZ == 0)
  63.             return ForgeDirection.WEST;
  64.         if (difX < 0 && difY == 0 && difZ == 0)
  65.             return ForgeDirection.EAST;
  66.  
  67.         if (difX == 0 && difY > 0 && difZ == 0)
  68.             return ForgeDirection.DOWN;
  69.         if (difX == 0 && difY < 0 && difZ == 0)
  70.             return ForgeDirection.UP;
  71.  
  72.         return  ForgeDirection.UNKNOWN;
  73.     }
  74.  
  75.     public int getBeamDistance(Location source, Location dest)
  76.     {
  77.         if (source.x - dest.x > 0)
  78.             return source.x - dest.x;
  79.         if (source.x - dest.x < 0)
  80.             return dest.x - source.x;
  81.  
  82.         if (source.y - dest.y > 0)
  83.             return source.y - dest.y;
  84.         if (source.y - dest.y < 0)
  85.             return dest.y - source.y;
  86.  
  87.         if (source.z - dest.z > 0)
  88.             return source.z - dest.z;
  89.         if (source.z - dest.z < 0)
  90.             return dest.z - source.z;
  91.  
  92.         return 0;
  93.     }
  94. }
Advertisement
Add Comment
Please, Sign In to add comment