CreepersNemisis

TNT Line Drawing Class Concept v2.1

Feb 6th, 2013
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.17 KB | None | 0 0
  1. package net.minecraft.src;
  2.  
  3. import java.awt.Color; //temp so you get the idea
  4. import java.util.ArrayList;
  5. import java.util.HashMap;
  6.  
  7. import net.minecraft.client.renderer.Tessellator;
  8. import net.minecraft.client.renderer.entity.RenderManager;
  9. import net.minecraft.entity.player.EntityPlayer;
  10. import org.lwjgl.opengl.GL11;
  11. import org.lwjgl.opengl.GL12;
  12.  
  13. public class EntityLineCreator extends BaseMod
  14. {
  15.     private /*Color*/ linecolor;
  16.     private boolean colormodulation = false;
  17.     private int linebrightness = 255
  18.     private HashMap entitycolors = new HashMap();
  19.    
  20.     private /*Entity*/ trackedentitytype;
  21.     private ArrayList</*Entity*/> entities = new ArrayList</*Entity*/>();
  22.    
  23.     private HashMap xcoords = new HashMap();
  24.     private HashMap ycoords = new HashMap();
  25.     private HashMap zcoords = new HashMap();
  26.    
  27.     private HashMap oldxcoords = new HashMap();
  28.     private HashMap oldycoords = new HashMap();
  29.     private HashMap oldzcoords = new HashMap();
  30.    
  31.     public EntityLineCreator(/*Entity*/ trackedentityclass, /*Color*/ colorofline, boolean modulatecolor) {
  32.         trackedentitytype = trackedentityclass;
  33.         linecolor = colorofline;
  34.         colormodulation = modulatecolor;
  35.         entities = /*World.getEntities(trackedentitytype)*/ //get all entities of the tracked type
  36.     }
  37.    
  38.     public void render(RenderWorldLastEvent event)
  39.     {
  40.         if (player == null || info == null || info.getPoint1() == null && info.getPoint2() == null)
  41.             return;
  42.         GL11.glPushMatrix();
  43.         GL11.glEnable(GL12.GL_RESCALE_NORMAL);
  44.         GL11.glDisable(GL11.GL_DEPTH_TEST);
  45.         GL11.glDisable(GL11.GL_TEXTURE_2D);
  46.         Tessellator tess = Tessellator.instance;
  47.         Tessellator.renderingWorldRenderer = false;
  48.  
  49.         entities = /*World.getEntities(trackedentitytype)*/
  50.         if(entities.size() == 0) return; //if there aren't any entities return
  51.         logCoords(); //make the current coords old
  52.         getEntityCoords(); //get the new coords
  53.         drawLine(tess); //draw a bunch of lines
  54.     }
  55.    
  56.     public void logCoords() {
  57.         oldxcoords = xcoords;
  58.         oldycoords = ycoords;
  59.         oldzcoords = zcoords;
  60.     }
  61.    
  62.     public void getEntityCoords() {
  63.         xcoords.clear();
  64.         ycoords.clear();
  65.         zcoords.clear();
  66.         for(/*Entity e : entities*/) {
  67.             xcoords.put(/*e.getID(), e.getX()*/);
  68.             ycoords.put(/*e.getID(), e.getY()*/);
  69.             zcoords.put(/*e.getID(), e.getZ()*/);
  70.         }
  71.     }
  72.    
  73.     private void drawLine(Tessellator tess)
  74.     {
  75.         if (oldxcoords.isEmpty() || oldycoords.isEmpty() || oldzcoords.isEmpty()) {
  76.             if(colormodulation == true) {
  77.                 if(entitycolors.get(/*e.getID()*/) == null || entitycolors.get(/*e.getID()*/) == 0) {
  78.                     entitycolors.put(/*e.getID()*/, 255);
  79.                 } else {
  80.                     entitycolors.put(/*e.getID()*/, entitycolors.get(/*e.getID()*/) - 1);
  81.                 }
  82.                 /*tess.setDrawingColor(new Color(linecolor.getRed(),linecolor.getBlue(),linecolor.getGreen(),entitycolors.get(/*e.getID()*/)))*/
  83.             } else {
  84.                 /*tess.setDrawingColor(new Color(linecolor.getRed(),linecolor.getBlue(),linecolor.getGreen())*/;
  85.             }
  86.             tess.startDrawing(GL11.GL_LINES);
  87.             tess.addVertex(oldxcoords.get(/*e.getID()*/),oldycoords.get(/*e.getID()*/),oldzcoords.get(/*e.getID()*/));
  88.             tess.addVertex(xcoords.get(/*e.getID()*/), ycoords.get(/*e.getID()*/), zcoords.get(/*e.getID()*/));
  89.             tess.draw();
  90.         }
  91.     }
  92. }
Advertisement
Add Comment
Please, Sign In to add comment