aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/EventListener.java2
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/DefaultRoomProcessor.java2
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/ProcessorFactory.java1
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessor.java2
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorBlazeSolver.java50
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/utils/RenderUtils.java71
6 files changed, 108 insertions, 20 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/EventListener.java b/src/main/java/kr/syeyoung/dungeonsguide/EventListener.java
index fca29550..93457e8e 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/EventListener.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/EventListener.java
@@ -84,7 +84,7 @@ public class EventListener {
fontRenderer.drawString("room uuid: "+dungeonRoom.getDungeonRoomInfo().getUuid() + (dungeonRoom.getDungeonRoomInfo().isRegistered() ?"":" (not registered)"), 5, 138, 0xFFFFFF);
fontRenderer.drawString("room name: "+dungeonRoom.getDungeonRoomInfo().getName(), 5, 148, 0xFFFFFF);
if (dungeonRoom.getRoomProcessor() != null)
- dungeonRoom.getRoomProcessor().drawScreen();
+ dungeonRoom.getRoomProcessor().drawScreen(postRender.partialTicks);
}
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/DefaultRoomProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/DefaultRoomProcessor.java
index 9edbcae9..596ebb74 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/DefaultRoomProcessor.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/DefaultRoomProcessor.java
@@ -14,7 +14,7 @@ public class DefaultRoomProcessor implements RoomProcessor {
}
@Override
- public void drawScreen() {
+ public void drawScreen(float partialTicks) {
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/ProcessorFactory.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/ProcessorFactory.java
index d404a1e4..3f65c642 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/ProcessorFactory.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/ProcessorFactory.java
@@ -23,5 +23,6 @@ public class ProcessorFactory {
static {
registerRoomProcessor("default", new DefaultRoomProcessor.Generator());
+ registerRoomProcessor("puzzle_blaze_solver", new RoomProcessorBlazeSolver.Generator());
}
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessor.java
index 24e29332..ed8a89f7 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessor.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessor.java
@@ -4,5 +4,5 @@ import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom;
public interface RoomProcessor {
void tick();
- void drawScreen();
+ void drawScreen(float partialTicks);
} \ No newline at end of file
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorBlazeSolver.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorBlazeSolver.java
index 7574b79c..ec1ed164 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorBlazeSolver.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorBlazeSolver.java
@@ -2,11 +2,16 @@ package kr.syeyoung.dungeonsguide.roomprocessor;
import com.google.common.base.Predicate;
import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom;
+import kr.syeyoung.dungeonsguide.utils.RenderUtils;
+import kr.syeyoung.dungeonsguide.utils.TextUtils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
+import net.minecraft.client.renderer.Tessellator;
import net.minecraft.entity.Entity;
+import net.minecraft.entity.item.EntityArmorStand;
import net.minecraft.entity.monster.EntityBlaze;
import net.minecraft.util.BlockPos;
+import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;
@@ -20,7 +25,8 @@ public class RoomProcessorBlazeSolver implements RoomProcessor {
private DungeonRoom dungeonRoom;
private boolean highToLow = false;
- private List<Entity> entityList = new ArrayList<Entity>();
+ private List<EntityArmorStand> entityList = new ArrayList<EntityArmorStand>();
+ private EntityArmorStand next;
public RoomProcessorBlazeSolver(DungeonRoom dungeonRoom) {
this.dungeonRoom = dungeonRoom;
Object highToLow = dungeonRoom.getDungeonRoomInfo().getProperties().get("order");
@@ -33,19 +39,49 @@ public class RoomProcessorBlazeSolver implements RoomProcessor {
World w = dungeonRoom.getContext().getWorld();
final BlockPos low = dungeonRoom.getMin();
final BlockPos high = dungeonRoom.getMax();
- entityList = new ArrayList<Entity>(w.getEntities(EntityBlaze.class, new Predicate<EntityBlaze>() {
+ entityList = new ArrayList<EntityArmorStand>(w.getEntities(EntityArmorStand.class, new Predicate<EntityArmorStand>() {
@Override
- public boolean apply(@Nullable EntityBlaze input) {
+ public boolean apply(@Nullable EntityArmorStand input) {
BlockPos pos = input.getPosition();
return low.getX() < pos.getX() && pos.getX() < high.getX()
- && low.getZ() < pos.getZ() && pos.getZ() < high.getZ();
+ && low.getZ() < pos.getZ() && pos.getZ() < high.getZ() && input.getName().toLowerCase().contains("blaze");
}
}));
+
+ EntityArmorStand semi_target = null;
+ int health = (highToLow ? Integer.MIN_VALUE : Integer.MAX_VALUE);
+ for (EntityArmorStand ea : entityList) {
+ String name = ea.getName();
+ String colorGone = TextUtils.stripColor(name);
+ String health2 = colorGone.split("/")[1];
+ try {
+ int heal = Integer.parseInt(health2);
+ if (highToLow && heal > health) {
+ health = heal;
+ semi_target = ea;
+ } else if (!highToLow && heal < health) {
+ health = heal;
+ semi_target = ea;
+ }
+ } catch (Exception e){}
+
+ }
+
+ next = semi_target;
}
@Override
- public void drawScreen() {
- FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
- fr.drawString("hehe blaze solver here", 100, 100, 0xFFFFFFFF);
+ public void drawScreen(float partialTicks) {
+ if (next == null) return;
+ Vec3 pos = next.getPositionEyes(partialTicks);
+ RenderUtils.drawTextAtWorld("NEXT", (float)pos.xCoord, (float)pos.yCoord, (float)pos.zCoord, 0xFFFF0000, 3, true, false, partialTicks);
+ }
+
+ public static class Generator implements RoomProcessorGenerator<RoomProcessorBlazeSolver> {
+ @Override
+ public RoomProcessorBlazeSolver createNew(DungeonRoom dungeonRoom) {
+ RoomProcessorBlazeSolver defaultRoomProcessor = new RoomProcessorBlazeSolver(dungeonRoom);
+ return defaultRoomProcessor;
+ }
}
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/utils/RenderUtils.java b/src/main/java/kr/syeyoung/dungeonsguide/utils/RenderUtils.java
index 659e25ca..8207e7d7 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/utils/RenderUtils.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/utils/RenderUtils.java
@@ -2,12 +2,19 @@ package kr.syeyoung.dungeonsguide.utils;
import kr.syeyoung.dungeonsguide.dungeon.doorfinder.DungeonDoor;
import net.minecraft.client.Minecraft;
+import net.minecraft.client.entity.EntityPlayerSP;
+import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.renderer.GlStateManager;
+import net.minecraft.client.renderer.Tessellator;
+import net.minecraft.client.renderer.WorldRenderer;
+import net.minecraft.client.renderer.entity.RenderManager;
+import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.entity.Entity;
import net.minecraft.util.BlockPos;
import net.minecraft.util.Vec3;
import org.lwjgl.opengl.GL11;
+import javax.vecmath.Vector3f;
import java.awt.*;
public class RenderUtils {
@@ -156,18 +163,62 @@ public class RenderUtils {
//...
}
+ public static void drawTextAtWorld(String text, float x, float y, float z, int color, float scale, boolean increase, boolean renderBlackBox, float partialTicks) {
+ float lScale = scale;
- private void drawLineWithGL(Vec3 blockA, Vec3 blockB) {
- int d = Math.round((float)blockA.distanceTo(blockB)+0.2f);
- GL11.glColor3f(0F, 1F, 0F);
- float oz = (blockA.xCoord - blockB.xCoord == 0?0:-1f/16f);
- float ox = (blockA.zCoord - blockB.zCoord == 0?0:1f/16f);
- GL11.glBegin(GL11.GL_LINE_STRIP);
+ RenderManager renderManager = Minecraft.getMinecraft().getRenderManager();
+ FontRenderer fontRenderer = Minecraft.getMinecraft().fontRendererObj;
- //you will want to modify these offsets.
- GL11.glVertex3d(blockA.xCoord + 0.5,blockA.yCoord - 0.01,blockA.zCoord + 0.5);
- GL11.glVertex3d(blockB.xCoord + 0.5,blockB.yCoord - 0.01,blockB.zCoord + 0.5);
+ Vector3f renderPos = getRenderPos(x, y, z, partialTicks);
- GL11.glEnd();
+ if (increase) {
+ double distance = Math.sqrt(renderPos.x * renderPos.x + renderPos.y * renderPos.y + renderPos.z * renderPos.z);
+ double multiplier = distance / 120f; //mobs only render ~120 blocks away
+ lScale *= 0.45f * multiplier;
+ }
+
+ GL11.glColor4f(1f, 1f, 1f, 0.5f);
+ GL11.glPushMatrix();
+ GL11.glTranslatef(renderPos.x, renderPos.y, renderPos.z);
+ GL11.glRotatef(-renderManager.playerViewY, 0.0f, 1.0f, 0.0f);
+ GL11.glRotatef(renderManager.playerViewX, 1.0f, 0.0f, 0.0f);
+ GL11.glScalef(-lScale, -lScale, lScale);
+ GL11.glDisable(GL11.GL_LIGHTING);
+ GL11.glDepthMask(false);
+ GL11.glDisable(GL11.GL_DEPTH_TEST);
+ GL11.glEnable(GL11.GL_BLEND);
+ GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
+
+ int textWidth = fontRenderer.getStringWidth(text);
+
+ Tessellator tessellator = Tessellator.getInstance();
+ WorldRenderer worldRenderer = tessellator.getWorldRenderer();
+ if (renderBlackBox) {
+ double j = textWidth / 2;
+ GlStateManager.disableTexture2D();
+ worldRenderer.begin(7, DefaultVertexFormats.POSITION_COLOR);
+ worldRenderer.pos((double)(-j - 1), (double)(-1), 0.0).color(0.0f, 0.0f, 0.0f, 0.25f).endVertex();
+ worldRenderer.pos((double)(-j - 1), (double)8, 0.0).color(0.0f, 0.0f, 0.0f, 0.25f).endVertex();
+ worldRenderer.pos((double)(j + 1), (double)8, 0.0).color(0.0f, 0.0f, 0.0f, 0.25f).endVertex();
+ worldRenderer.pos((double)(j + 1), (double)(-1), 0.0).color(0.0f, 0.0f, 0.0f, 0.25f).endVertex();
+ tessellator.draw();
+ GlStateManager.enableTexture2D();
+ }
+
+ fontRenderer.drawString(text, -textWidth / 2, 0, color);
+
+ GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
+ GL11.glDepthMask(true);
+ GL11.glEnable(GL11.GL_DEPTH_TEST);
+ GL11.glPopMatrix();
+ }
+
+ private static Vector3f getRenderPos(float x, float y, float z, float partialTicks) {
+ EntityPlayerSP sp = Minecraft.getMinecraft().thePlayer;
+ return new Vector3f(
+ x - (float) (sp.lastTickPosX + (sp.posX - sp.lastTickPosX) * partialTicks),
+ y - (float) (sp.lastTickPosY + (sp.posY - sp.lastTickPosY) * partialTicks),
+ z - (float) (sp.lastTickPosZ + (sp.posZ - sp.lastTickPosZ) * partialTicks)
+ );
}
}