Skip to content

Commit

Permalink
Cleanup waypoints (#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
MicrocontrollersDev authored Jun 20, 2024
1 parent 7c08a51 commit ad81840
Show file tree
Hide file tree
Showing 3 changed files with 129 additions and 142 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,6 @@ public boolean shouldMakeBeacon() {
@SubscribeEvent
public void onRenderWorldLast(RenderWorldLastEvent event) {
if (!shouldMakeBeacon()) return;
WaypointUtil.renderBeaconBeam(block, HytilsConfig.miniWallsMiddleBeaconColor.getRGB(), 1.0f, event.partialTicks);
WaypointUtil.renderBeaconBeam(block, HytilsConfig.miniWallsMiddleBeaconColor, event.partialTicks);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,20 @@

package org.polyfrost.hytils.handlers.render;

import cc.polyfrost.oneconfig.config.core.OneColor;
import cc.polyfrost.oneconfig.utils.hypixel.LocrawInfo;
import cc.polyfrost.oneconfig.utils.hypixel.LocrawUtil;
import org.polyfrost.hytils.config.HytilsConfig;
import org.polyfrost.hytils.events.TitleEvent;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.entity.Entity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityChest;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumChatFormatting;
import net.minecraftforge.client.event.RenderWorldLastEvent;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.event.world.WorldEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import org.lwjgl.opengl.GL11;
import org.polyfrost.hytils.config.HytilsConfig;
import org.polyfrost.hytils.events.TitleEvent;
import org.polyfrost.hytils.util.WaypointUtil;

import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
Expand Down Expand Up @@ -83,92 +76,11 @@ public void onWorldRendered(RenderWorldLastEvent event) {
if (entity instanceof TileEntityChest) {
BlockPos pos = entity.getPos();
if (!highlightedChestPositions.contains(pos)) continue;
drawBoundingBox(event, pos);
WaypointUtil.drawBoundingBox(event, pos, HytilsConfig.highlightChestsColor);
}
}
}

private void drawBoundingBox(RenderWorldLastEvent event, BlockPos pos) {
Entity viewer = Minecraft.getMinecraft().getRenderViewEntity();
double viewerX = viewer.lastTickPosX + (viewer.posX - viewer.lastTickPosX) * event.partialTicks;
double viewerY = viewer.lastTickPosY + (viewer.posY - viewer.lastTickPosY) * event.partialTicks;
double viewerZ = viewer.lastTickPosZ + (viewer.posZ - viewer.lastTickPosZ) * event.partialTicks;

double x = pos.getX() - viewerX;
double y = pos.getY() - viewerY;
double z = pos.getZ() - viewerZ;
GlStateManager.disableCull();
drawFilledBoundingBox(new AxisAlignedBB(x, y, z, x + 1, y + 1, z + 1).expand(0.01, 0.01, 0.01), HytilsConfig.highlightChestsColor);
GlStateManager.enableCull();
}

/**
* Taken from NotEnoughUpdates under Creative Commons Attribution-NonCommercial 3.0
* https://github.com/Moulberry/NotEnoughUpdates/blob/master/LICENSE
*
* @author Moulberry
*/
private void drawFilledBoundingBox(AxisAlignedBB aabb, OneColor c) {
GlStateManager.enableBlend();
GlStateManager.disableLighting();
GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
GlStateManager.disableTexture2D();

Tessellator tessellator = Tessellator.getInstance();
WorldRenderer worldrenderer = tessellator.getWorldRenderer();

GlStateManager.color(c.getRed() / 255f, c.getGreen() / 255f, c.getBlue() / 255f, c.getAlpha() / 255f * (float) 0.8);

//vertical
worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION);
worldrenderer.pos(aabb.minX, aabb.minY, aabb.minZ).endVertex();
worldrenderer.pos(aabb.maxX, aabb.minY, aabb.minZ).endVertex();
worldrenderer.pos(aabb.maxX, aabb.minY, aabb.maxZ).endVertex();
worldrenderer.pos(aabb.minX, aabb.minY, aabb.maxZ).endVertex();
tessellator.draw();
worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION);
worldrenderer.pos(aabb.minX, aabb.maxY, aabb.maxZ).endVertex();
worldrenderer.pos(aabb.maxX, aabb.maxY, aabb.maxZ).endVertex();
worldrenderer.pos(aabb.maxX, aabb.maxY, aabb.minZ).endVertex();
worldrenderer.pos(aabb.minX, aabb.maxY, aabb.minZ).endVertex();
tessellator.draw();


GlStateManager.color(c.getRed() / 255f * 0.8f, c.getGreen() / 255f * 0.8f, c.getBlue() / 255f * 0.8f, c.getAlpha() / 255f * (float) 0.8);

//x
worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION);
worldrenderer.pos(aabb.minX, aabb.minY, aabb.maxZ).endVertex();
worldrenderer.pos(aabb.minX, aabb.maxY, aabb.maxZ).endVertex();
worldrenderer.pos(aabb.minX, aabb.maxY, aabb.minZ).endVertex();
worldrenderer.pos(aabb.minX, aabb.minY, aabb.minZ).endVertex();
tessellator.draw();
worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION);
worldrenderer.pos(aabb.maxX, aabb.minY, aabb.minZ).endVertex();
worldrenderer.pos(aabb.maxX, aabb.maxY, aabb.minZ).endVertex();
worldrenderer.pos(aabb.maxX, aabb.maxY, aabb.maxZ).endVertex();
worldrenderer.pos(aabb.maxX, aabb.minY, aabb.maxZ).endVertex();
tessellator.draw();


GlStateManager.color(c.getRed() / 255f * 0.9f, c.getGreen() / 255f * 0.9f, c.getBlue() / 255f * 0.9f, c.getAlpha() / 255f * (float) 0.8);
//z
worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION);
worldrenderer.pos(aabb.minX, aabb.maxY, aabb.minZ).endVertex();
worldrenderer.pos(aabb.maxX, aabb.maxY, aabb.minZ).endVertex();
worldrenderer.pos(aabb.maxX, aabb.minY, aabb.minZ).endVertex();
worldrenderer.pos(aabb.minX, aabb.minY, aabb.minZ).endVertex();
tessellator.draw();
worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION);
worldrenderer.pos(aabb.minX, aabb.minY, aabb.maxZ).endVertex();
worldrenderer.pos(aabb.maxX, aabb.minY, aabb.maxZ).endVertex();
worldrenderer.pos(aabb.maxX, aabb.maxY, aabb.maxZ).endVertex();
worldrenderer.pos(aabb.minX, aabb.maxY, aabb.maxZ).endVertex();
tessellator.draw();
GlStateManager.enableTexture2D();
GlStateManager.disableBlend();
}

private boolean isNotSupported() {
return LocrawUtil.INSTANCE.getLocrawInfo() == null || (LocrawUtil.INSTANCE.getLocrawInfo().getGameType() != LocrawInfo.GameType.SKYWARS && LocrawUtil.INSTANCE.getLocrawInfo().getGameType() != LocrawInfo.GameType.BLITZ_SG && (LocrawUtil.INSTANCE.getLocrawInfo().getGameType() != LocrawInfo.GameType.DUELS || !LocrawUtil.INSTANCE.getLocrawInfo().getGameMode().contains("_SW_")));
}
Expand Down
Loading

0 comments on commit ad81840

Please sign in to comment.