Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package svk.industrialTech.gui;
- import org.lwjgl.input.Mouse;
- import svk.industrialTech.utils.RenderHelper;
- import net.minecraft.client.Minecraft;
- import net.minecraft.util.ResourceLocation;
- public class SpurtScroll
- {
- public final ResourceLocation texture = new ResourceLocation("minecraft:textures/gui/container/creative_inventory/tabs.png");
- int posX, posY, sizeY, amountSteps, step;
- public SpurtScroll(int posX, int posY, int sizeY, int amountSteps)
- {
- this.posX = posX;
- this.posY = posY;
- this.sizeY = sizeY;
- this.amountSteps = amountSteps;
- }
- public void draw()
- {
- Minecraft.getMinecraft().getTextureManager().bindTexture(texture);
- if(amountSteps == 0)
- {
- RenderHelper.drawTextureCustomSize(posX, posY, 232+12, 0, 12, 15, 256, 256);
- }
- else
- {
- float percent = ((float) step/amountSteps);
- if(step == 0) RenderHelper.drawTextureCustomSize(posX, posY, 232, 0, 12, 15, 256, 256);
- else if(step < amountSteps) RenderHelper.drawTextureCustomSize(posX, posY + sizeY * percent - 15*percent, 232, 0, 12, 15, 256, 256);
- else if(step == amountSteps) RenderHelper.drawTextureCustomSize(posX, posY + sizeY * percent - 15, 232, 0, 12, 15, 256, 256);
- }
- }
- public void mouseClickMove(int x, int y, int key, long time)
- {
- if(x >= posX && y >= posY && x <= posX+12 && y <= posY+sizeY)
- {
- float percent = (float) (y - posY)/sizeY;
- float stepSize = 1.0F/(amountSteps+1);
- this.step = (int) (percent/stepSize);
- }
- }
- public void handleMouseInput(int x, int y)
- {
- if(x >= posX && y >= posY && x <= posX+12 && y <= posY+sizeY)
- {
- int scrollType = Mouse.getEventDWheel();
- if(scrollType < 0) //Back
- {
- this.scrollDown();
- }
- else if(scrollType > 0)//Back to the future
- {
- this.scrollUp();
- }
- }
- }
- public void scrollUp()
- {
- this.step = this.step > 0 ? this.step -= 1 : this.step;
- }
- public void scrollDown()
- {
- this.step = this.step < amountSteps ? this.step += 1 : this.step;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment