package MineGod;
import org.lwjgl.opengl.GL11;
import org.newdawn.slick.geom.Rectangle;
import org.newdawn.slick.opengl.Texture;
public class ItemEntityDiamond extends ItemEntity {
static Texture diamondTex;
public ItemEntityDiamond(double x, double y) {
super(ItemEntityType.diamond, x, y);
itemID = 1;
width = 12;
height = 12;
maxAge = -1;
age = 0;
mask = new Rectangle((float)(this.x), (float)(yPos), (float)(width), (float)height);
// TODO Auto-generated constructor stub
}
public void doLogic(int delta, Chunk prevChunk, Chunk currChunk, Chunk nextChunk){
x += xSpeed*speed*delta;
yPos += ySpeed*speed*delta;
age += delta;
mask.setLocation((float)(x + width/2), (float)(yPos+height/2));
}
public void interactWithPlayerOnCollision(Player player){
player.inventory[itemID] = player.inventory[itemID]+1;
// set entity to dead.
dead = true;
}
public void render(double worldPos){
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
diamondTex.bind();
double renderX = x - worldPos;
GL11.glColor3d(1, 1, 1);
GL11.glBegin(GL11.GL_QUADS);
GL11.glNormal3d(0, 0, 1);
GL11.glTexCoord2d(0.0, 0.0);
GL11.glVertex3d(renderX, yPos, zIndex);
GL11.glTexCoord2d(1.0, 0.0);
GL11.glVertex3d(renderX + width, yPos, zIndex);
GL11.glTexCoord2d(1.0, 1.0);
GL11.glVertex3d(renderX + width, yPos + width, zIndex);
GL11.glTexCoord2d(0.0, 1.0);
GL11.glVertex3d(renderX, yPos + width, zIndex);
GL11.glEnd();
}
}