use of gregtech.api.util.Position in project GregTech by GregTechCE.
the class ProgressWidget method drawInBackground.
@Override
public void drawInBackground(int mouseX, int mouseY, IRenderContext context) {
Position pos = getPosition();
Size size = getSize();
if (emptyBarArea != null) {
emptyBarArea.draw(pos.x, pos.y, size.width, size.height);
}
if (filledBarArea != null) {
// fuck this precision-dependent things, they are so fucking annoying
if (moveType == MoveType.HORIZONTAL) {
filledBarArea.drawSubArea(pos.x, pos.y, (int) (size.width * lastProgressValue), size.height, 0.0, 0.0, ((int) (size.width * lastProgressValue)) / (size.width * 1.0), 1.0);
} else if (moveType == MoveType.VERTICAL) {
int progressValueScaled = (int) (size.height * lastProgressValue);
filledBarArea.drawSubArea(pos.x, pos.y + size.height - progressValueScaled, size.width, progressValueScaled, 0.0, 1.0 - (progressValueScaled / (size.height * 1.0)), 1.0, (progressValueScaled / (size.height * 1.0)));
} else if (moveType == MoveType.VERTICAL_INVERTED) {
int progressValueScaled = (int) (size.height * lastProgressValue);
filledBarArea.drawSubArea(pos.x, pos.y, size.width, progressValueScaled, 0.0, 0.0, 1.0, (progressValueScaled / (size.height * 1.0)));
}
}
}
use of gregtech.api.util.Position in project GregTech by GregTechCE.
the class SliderWidget method drawInBackground.
@Override
public void drawInBackground(int mouseX, int mouseY, IRenderContext context) {
Position pos = getPosition();
Size size = getSize();
if (backgroundArea != null) {
backgroundArea.draw(pos.x, pos.y, size.width, size.height);
}
if (displayString == null) {
this.displayString = getDisplayString();
}
sliderIcon.draw(pos.x + (int) (this.sliderPosition * (float) (size.width - 8)), pos.y, sliderWidth, size.height);
FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer;
fontRenderer.drawString(displayString, pos.x + size.width / 2 - fontRenderer.getStringWidth(displayString) / 2, pos.y + size.height / 2 - fontRenderer.FONT_HEIGHT / 2, textColor);
GlStateManager.color(1.0f, 1.0f, 1.0f);
}
use of gregtech.api.util.Position in project GregTech by GregTechCE.
the class SliderWidget method mouseDragged.
@Override
public boolean mouseDragged(int mouseX, int mouseY, int button, long timeDragged) {
if (this.isMouseDown) {
Position pos = getPosition();
Size size = getSize();
this.sliderPosition = (float) (mouseX - (pos.x + 4)) / (float) (size.width - 8);
if (this.sliderPosition < 0.0F) {
this.sliderPosition = 0.0F;
}
if (this.sliderPosition > 1.0F) {
this.sliderPosition = 1.0F;
}
this.displayString = this.getDisplayString();
writeClientAction(1, buffer -> buffer.writeFloat(sliderPosition));
return true;
}
return false;
}
use of gregtech.api.util.Position in project GregTech by GregTechCE.
the class MemorizedRecipeWidget method drawInForeground.
@Override
public void drawInForeground(int mouseX, int mouseY) {
super.drawInForeground(mouseX, mouseY);
if (recipeLocked) {
Position pos = getPosition();
GlStateManager.disableDepth();
GuiTextures.LOCK.draw(pos.x, pos.y + 10, 8, 8);
GlStateManager.enableDepth();
}
}
use of gregtech.api.util.Position in project GregTech by GregTechCE.
the class StonePileModelGenerator method generateCuboidList.
private static List<IndexedCuboid6> generateCuboidList(Random random) {
ArrayList<IndexedCuboid6> result = new ArrayList<>();
List<PositionedRect> occupiedAreas = new ArrayList<>();
int stonePlaceAttempts = 64;
int maxStones = 8;
int stonesPlaced = 0;
for (int i = 0; i < stonePlaceAttempts && stonesPlaced < maxStones; i++) {
int sizeX = 2 + random.nextInt(3);
int sizeZ = 2 + random.nextInt(3);
int stoneHeight = 4 + random.nextInt(4);
int posX = random.nextInt(16 - sizeX);
int posZ = random.nextInt(16 - sizeZ);
PositionedRect rect = new PositionedRect(new Position(posX, posZ), new Size(sizeX, sizeZ));
if (occupiedAreas.stream().noneMatch(rect::intersects)) {
Vector3 minVector = new Vector3(posX / 16.0, 0 / 16.0, posZ / 16.0);
Cuboid6 bounds = new Cuboid6(minVector, minVector.copy());
bounds.max.add(sizeX / 16.0, stoneHeight / 16.0, sizeZ / 16.0);
int brightness = 100 + random.nextInt(130);
result.add(new IndexedCuboid6(brightness, bounds));
occupiedAreas.add(rect);
stonesPlaced++;
}
}
return result;
}
Aggregations