From 99e56760ebfc089e6d910a09eb1dfcbfdf140175 Mon Sep 17 00:00:00 2001 From: syeyoung Date: Wed, 10 Feb 2021 23:32:31 +0900 Subject: better rendering --- .../dungeon/actions/ActionBreakWithSuperBoom.java | 45 +++++++++++++++++++++- .../dungeonsguide/dungeon/actions/ActionClick.java | 5 ++- .../dungeon/actions/ActionClickSet.java | 13 ++++++- .../dungeon/actions/ActionDropItem.java | 4 +- .../dungeonsguide/dungeon/actions/ActionKill.java | 5 ++- .../dungeonsguide/dungeon/actions/ActionMove.java | 6 ++- .../dungeon/actions/ActionMoveNearestAir.java | 6 ++- .../eventlistener/DungeonListener.java | 1 - 8 files changed, 76 insertions(+), 9 deletions(-) (limited to 'src/main/java/kr/syeyoung') diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionBreakWithSuperBoom.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionBreakWithSuperBoom.java index 9ab52808..04b839e6 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionBreakWithSuperBoom.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionBreakWithSuperBoom.java @@ -6,8 +6,19 @@ import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; import kr.syeyoung.dungeonsguide.utils.RenderUtils; import lombok.Data; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.BlockRendererDispatcher; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.WorldRenderer; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.client.renderer.vertex.DefaultVertexFormats; +import net.minecraft.client.renderer.vertex.VertexBuffer; +import net.minecraft.entity.Entity; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; +import net.minecraft.util.BlockPos; +import net.minecraft.util.MathHelper; import java.awt.*; import java.util.HashSet; @@ -34,11 +45,41 @@ public class ActionBreakWithSuperBoom extends AbstractAction { @Override public void onRenderWorld(DungeonRoom dungeonRoom, float partialTicks) { - RenderUtils.highlightBlock(target.getBlockPos(dungeonRoom), new Color(255, 0,0,255),partialTicks, false); + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture); + + BlockPos blockpos = target.getBlockPos(dungeonRoom); + + Entity viewing_from = Minecraft.getMinecraft().getRenderViewEntity(); + + double x_fix = viewing_from.lastTickPosX + ((viewing_from.posX - viewing_from.lastTickPosX) * partialTicks); + double y_fix = viewing_from.lastTickPosY + ((viewing_from.posY - viewing_from.lastTickPosY) * partialTicks); + double z_fix = viewing_from.lastTickPosZ + ((viewing_from.posZ - viewing_from.lastTickPosZ) * partialTicks); + + GlStateManager.pushMatrix(); + GlStateManager.translate(-x_fix, -y_fix, -z_fix); + GlStateManager.disableLighting(); + GlStateManager.enableAlpha(); + GlStateManager.enableBlend(); + + Tessellator tessellator = Tessellator.getInstance(); + WorldRenderer vertexbuffer = tessellator.getWorldRenderer(); + vertexbuffer.begin(7, DefaultVertexFormats.BLOCK); + + BlockRendererDispatcher blockrendererdispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher(); + blockrendererdispatcher.getBlockModelRenderer().renderModel(Minecraft.getMinecraft().theWorld, + blockrendererdispatcher.getBlockModelShapes().getModelForState(Blocks.tnt.getDefaultState()), + Blocks.tnt.getDefaultState(), blockpos, vertexbuffer, false); + tessellator.draw(); + + GlStateManager.enableLighting(); + GlStateManager.popMatrix(); + + RenderUtils.highlightBlock(blockpos, new Color(0, 255,255,50), partialTicks, false); + RenderUtils.drawTextAtWorld("Superboom", blockpos.getX() + 0.5f, blockpos.getY() + 0.5f, blockpos.getZ() + 0.5f, 0xFFFFFF00, 0.03f, false, false, partialTicks); } @Override public String toString() { - return "Click\n- target: "+target.toString(); + return "BreakWithSuperboom\n- target: "+target.toString(); } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionClick.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionClick.java index 18467809..fb7dfd8c 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionClick.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionClick.java @@ -8,6 +8,7 @@ import kr.syeyoung.dungeonsguide.utils.RenderUtils; import lombok.Data; import lombok.EqualsAndHashCode; import net.minecraft.item.ItemStack; +import net.minecraft.util.BlockPos; import net.minecraftforge.event.entity.player.PlayerInteractEvent; import java.awt.*; @@ -46,7 +47,9 @@ public class ActionClick extends AbstractAction { } @Override public void onRenderWorld(DungeonRoom dungeonRoom, float partialTicks) { - RenderUtils.highlightBlock(target.getBlockPos(dungeonRoom), new Color(0, 255,0,50),partialTicks, true); + BlockPos pos = target.getBlockPos(dungeonRoom); + RenderUtils.highlightBlock(pos, new Color(0, 255,255,50),partialTicks, true); + RenderUtils.drawTextAtWorld("Click", pos.getX() + 0.5f, pos.getY() + 0.3f, pos.getZ() + 0.5f, 0xFFFFFF00, 0.02f, false, false, partialTicks); } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionClickSet.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionClickSet.java index 7a3c99f4..e2f919c5 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionClickSet.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionClickSet.java @@ -9,6 +9,7 @@ import kr.syeyoung.dungeonsguide.utils.RenderUtils; import lombok.Data; import lombok.EqualsAndHashCode; import net.minecraft.item.ItemStack; +import net.minecraft.util.BlockPos; import net.minecraftforge.event.entity.player.PlayerInteractEvent; import java.awt.*; @@ -50,9 +51,19 @@ public class ActionClickSet extends AbstractAction { @Override public void onRenderWorld(DungeonRoom dungeonRoom, float partialTicks) { + float xAcc = 0; + float yAcc = 0; + float zAcc = 0; + int size = target.getOffsetPointList().size(); for (OffsetPoint offsetPoint : target.getOffsetPointList()) { - RenderUtils.highlightBlock(offsetPoint.getBlockPos(dungeonRoom), new Color(0, 255,0,50),partialTicks, true); + BlockPos pos = offsetPoint.getBlockPos(dungeonRoom); + xAcc += pos.getX() + 0.5f; + yAcc += pos.getY()+ 0.5f; + zAcc += pos.getZ()+ 0.5f; + RenderUtils.highlightBlock(offsetPoint.getBlockPos(dungeonRoom), new Color(0, 255,255,50),partialTicks, true); } + + RenderUtils.drawTextAtWorld("Click", xAcc / size, yAcc / size, zAcc / size, 0xFFFFFF00, 0.02f, false, false, partialTicks); } @Override diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionDropItem.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionDropItem.java index fb86c997..a7b35667 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionDropItem.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionDropItem.java @@ -42,7 +42,9 @@ public class ActionDropItem extends AbstractAction { } @Override public void onRenderWorld(DungeonRoom dungeonRoom, float partialTicks) { - RenderUtils.highlightBlock(target.getBlockPos(dungeonRoom), new Color(0, 0,255,50),partialTicks, true); + BlockPos pos = target.getBlockPos(dungeonRoom); + RenderUtils.highlightBlock(pos, new Color(0, 255,255,50),partialTicks, true); + RenderUtils.drawTextAtWorld("Drop Item", pos.getX() + 0.5f, pos.getY() + 0.3f, pos.getZ() + 0.5f, 0xFFFFFF00, 0.02f, false, false, partialTicks); } @Override diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionKill.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionKill.java index c43b2568..7d7c0488 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionKill.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionKill.java @@ -10,6 +10,7 @@ import kr.syeyoung.dungeonsguide.utils.RenderUtils; import lombok.Data; import lombok.EqualsAndHashCode; import net.minecraft.entity.Entity; +import net.minecraft.util.BlockPos; import net.minecraft.util.Vec3; import net.minecraftforge.event.entity.living.LivingDeathEvent; @@ -51,7 +52,9 @@ public class ActionKill extends AbstractAction { } @Override public void onRenderWorld(DungeonRoom dungeonRoom, float partialTicks) { - RenderUtils.highlightBlock(target.getBlockPos(dungeonRoom), new Color(255, 0,0,50),partialTicks, true); + BlockPos pos = target.getBlockPos(dungeonRoom); + RenderUtils.highlightBlock(pos, new Color(0, 255,255,50),partialTicks, true); + RenderUtils.drawTextAtWorld("Spawn", pos.getX() + 0.5f, pos.getY() + 0.3f, pos.getZ() + 0.5f, 0xFFFFFF00, 0.02f, false, false, partialTicks); } @Override diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMove.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMove.java index 591db2ca..e80cdd84 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMove.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMove.java @@ -5,6 +5,8 @@ import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; import kr.syeyoung.dungeonsguide.utils.RenderUtils; import lombok.Data; import net.minecraft.client.Minecraft; +import net.minecraft.util.BlockPos; +import net.minecraft.util.MathHelper; import java.awt.*; import java.util.HashSet; @@ -31,7 +33,9 @@ public class ActionMove extends AbstractAction { @Override public void onRenderWorld(DungeonRoom dungeonRoom, float partialTicks) { - RenderUtils.highlightBlock(target.getBlockPos(dungeonRoom), new Color(0, 255,255,50),partialTicks, false); + BlockPos pos = target.getBlockPos(dungeonRoom); + RenderUtils.drawTextAtWorld("Destination", pos.getX() + 0.5f, pos.getY() + 0.6f, pos.getZ() + 0.5f, 0xFF00FF00, 1f, true, false, partialTicks); + RenderUtils.drawTextAtWorld(String.format("%.2f",MathHelper.sqrt_double(pos.distanceSq(Minecraft.getMinecraft().thePlayer.getPosition())))+"m", pos.getX() + 0.5f, pos.getY() + 0.3f, pos.getZ() + 0.5f, 0xFFFFFF00, 1f, true, false, partialTicks); } @Override diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMoveNearestAir.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMoveNearestAir.java index fda4cd92..92c2fe69 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMoveNearestAir.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMoveNearestAir.java @@ -5,6 +5,8 @@ import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; import kr.syeyoung.dungeonsguide.utils.RenderUtils; import lombok.Data; import net.minecraft.client.Minecraft; +import net.minecraft.util.BlockPos; +import net.minecraft.util.MathHelper; import java.awt.*; import java.util.HashSet; @@ -30,7 +32,9 @@ public class ActionMoveNearestAir extends AbstractAction { } @Override public void onRenderWorld(DungeonRoom dungeonRoom, float partialTicks) { - RenderUtils.highlightBlock(target.getBlockPos(dungeonRoom), new Color(0, 255,255,50),partialTicks, false); + BlockPos pos = target.getBlockPos(dungeonRoom); + RenderUtils.drawTextAtWorld("Destination", pos.getX() + 0.5f, pos.getY() + 0.6f, pos.getZ() + 0.5f, 0xFF00FF00, 1f, true, false, partialTicks); + RenderUtils.drawTextAtWorld(String.format("%.2f", MathHelper.sqrt_double(pos.distanceSq(Minecraft.getMinecraft().thePlayer.getPosition())))+"m", pos.getX() + 0.5f, pos.getY() + 0.3f, pos.getZ() + 0.5f, 0xFFFFFF00, 1f, true, false, partialTicks); } @Override diff --git a/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/DungeonListener.java b/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/DungeonListener.java index 63d2c013..6ec18f73 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/DungeonListener.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/DungeonListener.java @@ -479,7 +479,6 @@ public class DungeonListener { private Map entityIdToPosMap = new HashMap(); @SubscribeEvent public void onEntitySpawn(EntityJoinWorldEvent spawn) { - System.out.println("Spawned "+spawn.entity); EntitySpawnManager.getSpawnLocation().put(spawn.entity.getEntityId(), new Vec3(spawn.entity.posX, spawn.entity.posY, spawn.entity.posZ)); } -- cgit