use of net.minecraft.client.Minecraft in project LogisticsPipes by RS485.
the class LogisticsHUDRenderer method renderPlayerDisplay.
public void renderPlayerDisplay(long renderTicks) {
if (!displayRenderer()) {
return;
}
Minecraft mc = FMLClientHandler.instance().getClient();
if (displayHUD() && displayCross) {
ScaledResolution res = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
int width = res.getScaledWidth();
int height = res.getScaledHeight();
if (GuiIngameForge.renderCrosshairs && mc.ingameGUI != null) {
mc.renderEngine.bindTexture(LogisticsHUDRenderer.TEXTURE);
GL11.glColor4d(0.0D, 0.0D, 0.0D, 1.0D);
GL11.glDisable(GL11.GL_BLEND);
mc.ingameGUI.drawTexturedModalRect(width / 2 - 7, height / 2 - 7, 0, 0, 16, 16);
}
}
}
use of net.minecraft.client.Minecraft in project LogisticsPipes by RS485.
the class LogisticsHUDRenderer method renderWorldRelative.
public void renderWorldRelative(long renderTicks, float partialTick) {
if (!displayRenderer()) {
return;
}
Minecraft mc = FMLClientHandler.instance().getClient();
EntityPlayer player = mc.thePlayer;
if (list.size() == 0 || Math.hypot(lastXPos - player.posX, Math.hypot(lastYPos - player.posY, lastZPos - player.posZ)) > 0.5 || (renderTicks % 10 == 0 && (lastXPos != player.posX || lastYPos != player.posY || lastZPos != player.posZ)) || renderTicks % 600 == 0) {
refreshList(player.posX, player.posY, player.posZ);
lastXPos = player.posX;
lastYPos = player.posY;
lastZPos = player.posZ;
}
boolean cursorHandled = false;
displayCross = false;
IHUDConfig config;
if (debugHUD == null) {
config = new HUDConfig(mc.thePlayer.inventory.armorInventory[3]);
} else {
config = new IHUDConfig() {
@Override
public boolean isHUDSatellite() {
return false;
}
@Override
public boolean isHUDProvider() {
return false;
}
@Override
public boolean isHUDPowerLevel() {
return false;
}
@Override
public boolean isHUDInvSysCon() {
return false;
}
@Override
public boolean isHUDCrafting() {
return false;
}
@Override
public boolean isHUDChassie() {
return false;
}
@Override
public void setHUDChassie(boolean state) {
}
@Override
public void setHUDCrafting(boolean state) {
}
@Override
public void setHUDInvSysCon(boolean state) {
}
@Override
public void setHUDPowerJunction(boolean state) {
}
@Override
public void setHUDProvider(boolean state) {
}
@Override
public void setHUDSatellite(boolean state) {
}
};
}
IHeadUpDisplayRendererProvider thisIsLast = null;
List<IHeadUpDisplayRendererProvider> toUse = list;
if (debugHUD != null) {
toUse = debugHUD.getHUDs();
}
for (IHeadUpDisplayRendererProvider renderer : toUse) {
if (renderer.getRenderer() == null) {
continue;
}
if (renderer.getRenderer().display(config)) {
GL11.glPushMatrix();
if (!cursorHandled) {
double x = renderer.getX() + 0.5 - player.posX;
double y = renderer.getY() + 0.5 - player.posY;
double z = renderer.getZ() + 0.5 - player.posZ;
if (Math.hypot(x, Math.hypot(y, z)) < 0.75 || (renderer instanceof IHeadUpDisplayBlockRendererProvider && (((IHeadUpDisplayBlockRendererProvider) renderer).isHUDInvalid() || !((IHeadUpDisplayBlockRendererProvider) renderer).isHUDExistent()))) {
refreshList(player.posX, player.posY, player.posZ);
GL11.glPopMatrix();
break;
}
int[] pos = getCursor(renderer);
if (pos.length == 2) {
if (renderer.getRenderer().cursorOnWindow(pos[0], pos[1])) {
renderer.getRenderer().handleCursor(pos[0], pos[1]);
if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
//if(FMLClientHandler.instance().getClient().thePlayer.isSneaking()) {
thisIsLast = renderer;
displayCross = true;
}
cursorHandled = true;
}
}
}
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
if (thisIsLast != renderer) {
displayOneView(renderer, config, partialTick, false);
}
GL11.glPopMatrix();
}
}
if (thisIsLast != null) {
GL11.glPushMatrix();
GL11.glDisable(GL11.GL_BLEND);
GL11.glDisable(GL11.GL_DEPTH_TEST);
displayOneView(thisIsLast, config, partialTick, true);
GL11.glEnable(GL11.GL_BLEND);
GL11.glEnable(GL11.GL_DEPTH_TEST);
GL11.glPopMatrix();
}
GL11.glPushMatrix();
MovingObjectPosition box = mc.objectMouseOver;
if (box != null && box.typeOfHit == MovingObjectType.BLOCK) {
if (Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)) {
progress = Math.min(progress + (2 * Math.max(1, (int) Math.floor((System.currentTimeMillis() - last) / 50.0D))), 100);
} else {
progress = Math.max(progress - (2 * Math.max(1, (int) Math.floor((System.currentTimeMillis() - last) / 50.0D))), 0);
}
if (progress != 0) {
List<String> textData = new ArrayList<>();
if (textData.isEmpty()) {
textData = SimpleServiceLocator.neiProxy.getInfoForPosition(player.worldObj, player, box);
}
if (!textData.isEmpty()) {
double xCoord = box.blockX + 0.5D;
double yCoord = box.blockY + 0.5D;
double zCoord = box.blockZ + 0.5D;
double x = xCoord - player.prevPosX - ((player.posX - player.prevPosX) * partialTick);
double y = yCoord - player.prevPosY - ((player.posY - player.prevPosY) * partialTick);
double z = zCoord - player.prevPosZ - ((player.posZ - player.prevPosZ) * partialTick);
GL11.glDisable(GL11.GL_DEPTH_TEST);
GL11.glTranslatef((float) x, (float) y, (float) z);
GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F);
GL11.glRotatef(getAngle(z, x) + 110F, 0.0F, 0.0F, 1.0F);
GL11.glRotatef((-1) * getAngle(Math.hypot(x + 0.8, z + 0.8), y + 0.5) + 180, 1.0F, 0.0F, 0.0F);
double dProgress = progress / 100D;
GL11.glTranslated(0.4D * dProgress + 0.6D, -0.2D * dProgress - 0.6D, -0.0D);
GL11.glScalef(0.01F, 0.01F, 1F);
int heigth = Math.max(32, 10 * textData.size() + 15);
int width = 0;
for (String s : textData) {
width = Math.max(width, mc.fontRenderer.getStringWidth(s) + 22);
}
width = Math.max(32, width + 15);
GL11.glColor4b((byte) 127, (byte) 127, (byte) 127, (byte) 96);
GuiGraphics.drawGuiBackGround(mc, (int) ((-0.5 * (width - 32)) * dProgress) - 16, (int) ((-0.5 * (heigth - 32)) * dProgress) - 16, (int) ((0.5 * (width - 32)) * dProgress) + 16, (int) ((0.5 * (heigth - 32)) * dProgress) + 16, 0, false);
GL11.glColor4b((byte) 127, (byte) 127, (byte) 127, (byte) 127);
if (progress == 100) {
GL11.glTranslated((int) ((-0.5 * (width - 32)) * dProgress) - 16, (int) ((-0.5 * (heigth - 32)) * dProgress) - 16, -0.0001D);
for (int i = 0; i < textData.size(); i++) {
mc.fontRenderer.drawString(textData.get(i), 28, 8 + i * 10, 0x000000);
}
ItemStack item = SimpleServiceLocator.neiProxy.getItemForPosition(player.worldObj, player, box);
if (item != null) {
float scaleX = 1.5F * 0.8F;
float scaleY = 1.5F * 0.8F;
float scaleZ = -0.0001F;
GL11.glScalef(scaleX, scaleY, scaleZ);
ItemStackRenderer itemStackRenderer = new ItemStackRenderer(5, 6, 0.0F, false, true, true);
itemStackRenderer.setItemstack(item).setDisplayAmount(DisplayAmount.NEVER);
itemStackRenderer.setScaleX(scaleX).setScaleY(scaleY).setScaleZ(scaleZ);
itemStackRenderer.renderInGui();
}
}
GL11.glEnable(GL11.GL_DEPTH_TEST);
}
}
} else if (!Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)) {
progress = 0;
}
GL11.glPopMatrix();
//Render Laser
GL11.glDisable(GL11.GL_DEPTH_TEST);
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
//GL11.glEnable(GL11.GL_LIGHTING);
for (LaserData data : lasers) {
GL11.glPushMatrix();
double x = data.getPosX() + 0.5 - player.prevPosX - ((player.posX - player.prevPosX) * partialTick);
double y = data.getPosY() + 0.5 - player.prevPosY - ((player.posY - player.prevPosY) * partialTick);
double z = data.getPosZ() + 0.5 - player.prevPosZ - ((player.posZ - player.prevPosZ) * partialTick);
GL11.glTranslatef((float) x, (float) y, (float) z);
switch(data.getDir()) {
case NORTH:
GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F);
break;
case SOUTH:
GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F);
break;
case EAST:
break;
case WEST:
GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F);
break;
case UP:
GL11.glRotatef(90.0F, 0.0F, 0.0F, 1.0F);
break;
case DOWN:
GL11.glRotatef(-90.0F, 0.0F, 0.0F, 1.0F);
break;
default:
break;
}
GL11.glScalef(0.01F, 0.01F, 0.01F);
Tessellator tessellator = Tessellator.instance;
for (float i = 0; i < 6 * data.getLength(); i++) {
setColor(i, data.getConnectionType());
float shift = 100f * i / 6f;
float start = 0.0f;
if (data.isStartPipe() && i == 0) {
start = -6.0f;
}
tessellator.startDrawingQuads();
tessellator.addVertex(19.7f + shift, 3.0f, -3.0f);
tessellator.addVertex(3.0f + shift + start, 3.0f, -3.0f);
tessellator.addVertex(3.0f + shift + start, 3.0f, 3.0f);
tessellator.addVertex(19.7f + shift, 3.0f, 3.0f);
tessellator.draw();
tessellator.startDrawingQuads();
tessellator.addVertex(19.7f + shift, -3.0f, 3.0f);
tessellator.addVertex(3.0f + shift + start, -3.0f, 3.0f);
tessellator.addVertex(3.0f + shift + start, -3.0f, -3.0f);
tessellator.addVertex(19.7f + shift, -3.0f, -3.0f);
tessellator.draw();
tessellator.startDrawingQuads();
tessellator.addVertex(19.7f + shift, 3.0f, 3.0f);
tessellator.addVertex(3.0f + shift + start, 3.0f, 3.0f);
tessellator.addVertex(3.0f + shift + start, -3.0f, 3.0f);
tessellator.addVertex(19.7f + shift, -3.0f, 3.0f);
tessellator.draw();
tessellator.startDrawingQuads();
tessellator.addVertex(19.7f + shift, -3.0f, -3.0f);
tessellator.addVertex(3.0f + shift + start, -3.0f, -3.0f);
tessellator.addVertex(3.0f + shift + start, 3.0f, -3.0f);
tessellator.addVertex(19.7f + shift, 3.0f, -3.0f);
tessellator.draw();
}
if (data.isStartPipe()) {
setColor(0, data.getConnectionType());
tessellator.startDrawingQuads();
tessellator.addVertex(-3.0f, 3.0f, 3.0f);
tessellator.addVertex(-3.0f, 3.0f, -3.0f);
tessellator.addVertex(-3.0f, -3.0f, -3.0f);
tessellator.addVertex(-3.0f, -3.0f, 3.0f);
tessellator.draw();
}
if (data.isFinalPipe()) {
setColor(6 * data.getLength() - 1, data.getConnectionType());
tessellator.startDrawingQuads();
tessellator.addVertex(100.0f * data.getLength() + 3f, 3.0f, -3.0f);
tessellator.addVertex(100.0f * data.getLength() + 3f, 3.0f, 3.0f);
tessellator.addVertex(100.0f * data.getLength() + 3f, -3.0f, 3.0f);
tessellator.addVertex(100.0f * data.getLength() + 3f, -3.0f, -3.0f);
tessellator.draw();
}
GL11.glPopMatrix();
}
GL11.glEnable(GL11.GL_TEXTURE_2D);
last = System.currentTimeMillis();
}
use of net.minecraft.client.Minecraft in project LogisticsPipes by RS485.
the class LogisticsHUDRenderer method getCursor.
private int[] getCursor(IHeadUpDisplayRendererProvider renderer) {
Minecraft mc = FMLClientHandler.instance().getClient();
EntityPlayer player = mc.thePlayer;
Vector3d playerView = Vector3d.getFromAngles((270 - player.rotationYaw) / 360 * -2 * Math.PI, (player.rotationPitch) / 360 * -2 * Math.PI);
Vector3d playerPos = new Vector3d();
playerPos.x = player.posX;
playerPos.y = player.posY;
playerPos.z = player.posZ;
Vector3d panelPos = new Vector3d();
panelPos.x = renderer.getX() + 0.5;
panelPos.y = renderer.getY() + 0.5;
panelPos.z = renderer.getZ() + 0.5;
Vector3d panelView = new Vector3d();
panelView.x = playerPos.x - panelPos.x;
panelView.y = playerPos.y - panelPos.y;
panelView.z = playerPos.z - panelPos.z;
panelPos.add(panelView, 0.44D);
double d = panelPos.x * panelView.x + panelPos.y * panelView.y + panelPos.z * panelView.z;
double c = panelView.x * playerPos.x + panelView.y * playerPos.y + panelView.z * playerPos.z;
double b = panelView.x * playerView.x + panelView.y * playerView.y + panelView.z * playerView.z;
double a = (d - c) / b;
Vector3d viewPos = new Vector3d();
viewPos.x = playerPos.x + a * playerView.x - panelPos.x;
viewPos.y = playerPos.y + a * playerView.y - panelPos.y;
viewPos.z = playerPos.z + a * playerView.z - panelPos.z;
Vector3d panelScalVector1 = new Vector3d();
if (panelView.y == 0) {
panelScalVector1.x = 0;
panelScalVector1.y = 1;
panelScalVector1.z = 0;
} else {
panelScalVector1 = panelView.getOrtogonal(-panelView.x, null, -panelView.z).makeVectorLength(1.0D);
}
Vector3d panelScalVector2 = new Vector3d();
if (panelView.z == 0) {
panelScalVector2.x = 0;
panelScalVector2.y = 0;
panelScalVector2.z = 1;
} else {
panelScalVector2 = panelView.getOrtogonal(1.0D, 0.0D, null).makeVectorLength(1.0D);
}
if (panelScalVector1.y == 0) {
return new int[] {};
}
double cursorY = -viewPos.y / panelScalVector1.y;
Vector3d restViewPos = viewPos.clone();
restViewPos.x += cursorY * panelScalVector1.x;
restViewPos.y = 0;
restViewPos.z += cursorY * panelScalVector1.z;
double cursorX;
if (panelScalVector2.x == 0) {
cursorX = restViewPos.z / panelScalVector2.z;
} else {
cursorX = restViewPos.x / panelScalVector2.x;
}
cursorX *= 50 / 0.47D;
cursorY *= 50 / 0.47D;
if (panelView.z < 0) {
cursorX *= -1;
}
if (panelView.y < 0) {
cursorY *= -1;
}
return new int[] { (int) cursorX, (int) cursorY };
}
use of net.minecraft.client.Minecraft in project LogisticsPipes by RS485.
the class RenderTickHandler method renderWorldLast.
//private static final ResourceLocation TEXTURE = new ResourceLocation("logisticspipes", "textures/blocks/pipes/White.png");
@SubscribeEvent
public void renderWorldLast(RenderWorldLastEvent worldEvent) {
if (LogisticsRenderPipe.config.isUseNewRenderer()) {
if (displayPipeGhost()) {
Minecraft mc = Minecraft.getMinecraft();
EntityPlayer player = mc.thePlayer;
MovingObjectPosition box = mc.objectMouseOver;
if (box != null && box.typeOfHit == MovingObjectType.BLOCK) {
ItemStack stack = FMLClientHandler.instance().getClient().thePlayer.inventory.mainInventory[FMLClientHandler.instance().getClient().thePlayer.inventory.currentItem];
CoreUnroutedPipe pipe = ((ItemLogisticsPipe) stack.getItem()).getDummyPipe();
int i = box.blockX;
int j = box.blockY;
int k = box.blockZ;
World world = player.getEntityWorld();
int side = box.sideHit;
Block worldBlock = world.getBlock(i, j, k);
if (worldBlock == Blocks.snow) {
side = 1;
} else if (worldBlock != Blocks.vine && worldBlock != Blocks.tallgrass && worldBlock != Blocks.deadbush && (worldBlock == null || !worldBlock.isReplaceable(world, i, j, k))) {
if (side == 0) {
j--;
}
if (side == 1) {
j++;
}
if (side == 2) {
k--;
}
if (side == 3) {
k++;
}
if (side == 4) {
i--;
}
if (side == 5) {
i++;
}
}
double xCoord = i;
double yCoord = j;
double zCoord = k;
boolean isFreeSpace = true;
ITubeOrientation orientation = null;
if (pipe instanceof CoreMultiBlockPipe) {
CoreMultiBlockPipe multipipe = (CoreMultiBlockPipe) pipe;
DoubleCoordinates placeAt = new DoubleCoordinates(xCoord, yCoord, zCoord);
LPPositionSet<DoubleCoordinatesType<CoreMultiBlockPipe.SubBlockTypeForShare>> globalPos = new LPPositionSet<>(DoubleCoordinatesType.class);
globalPos.add(new DoubleCoordinatesType<>(placeAt, CoreMultiBlockPipe.SubBlockTypeForShare.NON_SHARE));
LPPositionSet<DoubleCoordinatesType<CoreMultiBlockPipe.SubBlockTypeForShare>> positions = multipipe.getSubBlocks();
orientation = multipipe.getTubeOrientation(player, (int) xCoord, (int) zCoord);
if (orientation != null) {
orientation.rotatePositions(positions);
positions.stream().map(pos -> pos.add(placeAt)).forEach(globalPos::add);
globalPos.addToAll(orientation.getOffset());
for (DoubleCoordinatesType<CoreMultiBlockPipe.SubBlockTypeForShare> pos : globalPos) {
if (!player.getEntityWorld().canPlaceEntityOnSide(LogisticsPipes.LogisticsPipeBlock, pos.getXInt(), pos.getYInt(), pos.getZInt(), false, side, player, stack)) {
TileEntity tile = player.getEntityWorld().getTileEntity(pos.getXInt(), pos.getYInt(), pos.getZInt());
boolean canPlace = false;
if (tile instanceof LogisticsTileGenericSubMultiBlock) {
if (CoreMultiBlockPipe.canShare(((LogisticsTileGenericSubMultiBlock) tile).getSubTypes(), pos.getType())) {
canPlace = true;
}
}
if (!canPlace) {
isFreeSpace = false;
break;
}
}
}
} else {
return;
}
} else {
if (!player.getEntityWorld().canPlaceEntityOnSide(LogisticsPipes.LogisticsPipeBlock, i, j, k, false, side, player, stack)) {
isFreeSpace = false;
}
}
if (isFreeSpace) {
GL11.glPushMatrix();
double x;
double y;
double z;
if (orientation != null) {
x = xCoord + orientation.getOffset().getXInt() - player.prevPosX - ((player.posX - player.prevPosX) * worldEvent.partialTicks);
y = yCoord + orientation.getOffset().getYInt() - player.prevPosY - ((player.posY - player.prevPosY) * worldEvent.partialTicks);
z = zCoord + orientation.getOffset().getZInt() - player.prevPosZ - ((player.posZ - player.prevPosZ) * worldEvent.partialTicks);
} else {
x = xCoord - player.prevPosX - ((player.posX - player.prevPosX) * worldEvent.partialTicks);
y = yCoord - player.prevPosY - ((player.posY - player.prevPosY) * worldEvent.partialTicks);
z = zCoord - player.prevPosZ - ((player.posZ - player.prevPosZ) * worldEvent.partialTicks);
}
GL11.glTranslated(x + 0.001, y + 0.001, z + 0.001);
GL11.glEnable(GL11.GL_BLEND);
//GL11.glDepthMask(false);
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
mc.renderEngine.bindTexture(new ResourceLocation("logisticspipes", "textures/blocks/pipes/White.png"));
Tessellator tess = Tessellator.instance;
CCRenderState.reset();
CCRenderState.useNormals = true;
CCRenderState.alphaOverride = 0xff;
GL11.glEnable(GL11.GL_TEXTURE_2D);
CCRenderState.alphaOverride = 0x50;
CCRenderState.useNormals = true;
CCRenderState.hasBrightness = false;
CCRenderState.startDrawing();
pipe.getHighlightRenderer().renderHighlight(orientation);
tess.draw();
CCRenderState.alphaOverride = 0xff;
GL11.glDisable(GL11.GL_BLEND);
GL11.glDepthMask(true);
GL11.glPopMatrix();
}
}
}
}
}
use of net.minecraft.client.Minecraft in project LogisticsPipes by RS485.
the class RenderTickHandler method renderTick.
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void renderTick(RenderTickEvent event) {
if (event.phase == Phase.START) {
if (LogisticsGuiOverrenderer.getInstance().isCompatibleGui()) {
LogisticsGuiOverrenderer.getInstance().preRender();
}
ClientViewController.instance().tick();
} else {
renderTicks++;
if (LogisticsHUDRenderer.instance().displayRenderer()) {
GL11.glPushMatrix();
Minecraft mc = FMLClientHandler.instance().getClient();
//Orientation
mc.entityRenderer.setupCameraTransform(event.renderTickTime, 1);
ActiveRenderInfo.updateRenderInfo(mc.thePlayer, mc.gameSettings.thirdPersonView == 2);
LogisticsHUDRenderer.instance().renderWorldRelative(renderTicks, event.renderTickTime);
mc.entityRenderer.setupOverlayRendering();
GL11.glPopMatrix();
GL11.glPushMatrix();
LogisticsHUDRenderer.instance().renderPlayerDisplay(renderTicks);
GL11.glPopMatrix();
} else if (LogisticsGuiOverrenderer.getInstance().isCompatibleGui()) {
LogisticsGuiOverrenderer.getInstance().renderOverGui();
}
}
}
Aggregations