diff options
Diffstat (limited to 'src/main/java/kr/syeyoung/dungeonsguide/roomprocessor')
3 files changed, 122 insertions, 13 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/GeneralRoomProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/GeneralRoomProcessor.java index b3a42aa0..6a0a3dfa 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/GeneralRoomProcessor.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/GeneralRoomProcessor.java @@ -17,25 +17,33 @@ import kr.syeyoung.dungeonsguide.roomedit.gui.GuiDungeonAddSet; import kr.syeyoung.dungeonsguide.roomedit.gui.GuiDungeonRoomEdit; import lombok.Getter; import lombok.Setter; +import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.ScaledResolution; +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.entity.item.EntityArmorStand; import net.minecraft.entity.passive.EntityBat; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; import net.minecraft.init.Items; -import net.minecraft.util.BlockPos; -import net.minecraft.util.ChatComponentText; -import net.minecraft.util.IChatComponent; +import net.minecraft.util.*; import net.minecraftforge.client.event.GuiScreenEvent; +import net.minecraftforge.client.event.RenderLivingEvent; import net.minecraftforge.event.entity.living.LivingDeathEvent; import net.minecraftforge.event.entity.living.LivingEvent; import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.fml.common.gameevent.InputEvent; +import org.lwjgl.opengl.GL11; import java.awt.*; import java.util.*; +import java.util.List; public class GeneralRoomProcessor implements RoomProcessor { @@ -129,6 +137,7 @@ public class GeneralRoomProcessor implements RoomProcessor { } } if (path != null) path.onRenderWorld(partialTicks); + } @Override diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessor.java index ff3b0ae3..a4f4188d 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessor.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessor.java @@ -4,6 +4,7 @@ import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; import kr.syeyoung.dungeonsguide.events.PlayerInteractEntityEvent; import net.minecraft.util.IChatComponent; import net.minecraftforge.client.event.GuiScreenEvent; +import net.minecraftforge.client.event.RenderLivingEvent; import net.minecraftforge.event.entity.living.LivingDeathEvent; import net.minecraftforge.event.entity.living.LivingEvent; import net.minecraftforge.event.entity.player.EntityInteractEvent; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorBlazeSolver.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorBlazeSolver.java index 38acb3c8..ab25e451 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorBlazeSolver.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorBlazeSolver.java @@ -6,11 +6,25 @@ import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; import kr.syeyoung.dungeonsguide.features.FeatureRegistry; import kr.syeyoung.dungeonsguide.utils.RenderUtils; import kr.syeyoung.dungeonsguide.utils.TextUtils; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.Gui; +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.entity.item.EntityArmorStand; -import net.minecraft.util.BlockPos; -import net.minecraft.util.Vec3; +import net.minecraft.entity.monster.EntityBlaze; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemBow; +import net.minecraft.util.*; import net.minecraft.world.World; import org.jetbrains.annotations.Nullable; +import org.lwjgl.opengl.GL11; import java.awt.*; import java.util.ArrayList; @@ -21,7 +35,9 @@ public class RoomProcessorBlazeSolver extends GeneralRoomProcessor { private boolean highToLow = false; private List<EntityArmorStand> entityList = new ArrayList<EntityArmorStand>(); + private List<EntityBlaze> blazeList = new ArrayList<>(); private EntityArmorStand next; + private EntityBlaze nextBlaze; public RoomProcessorBlazeSolver(DungeonRoom dungeonRoom) { super(dungeonRoom); Object highToLow = dungeonRoom.getDungeonRoomInfo().getProperties().get("order"); @@ -37,13 +53,15 @@ public class RoomProcessorBlazeSolver extends GeneralRoomProcessor { World w = dungeonRoom.getContext().getWorld(); final BlockPos low = dungeonRoom.getMin(); final BlockPos high = dungeonRoom.getMax(); - entityList = new ArrayList<EntityArmorStand>(w.getEntities(EntityArmorStand.class, new Predicate<EntityArmorStand>() { - @Override - 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() && input.getName().toLowerCase().contains("blaze"); - } + entityList = new ArrayList<EntityArmorStand>(w.getEntities(EntityArmorStand.class, input -> { + BlockPos pos = input.getPosition(); + return low.getX() < pos.getX() && pos.getX() < high.getX() + && low.getZ() < pos.getZ() && pos.getZ() < high.getZ() && input.getName().toLowerCase().contains("blaze"); + })); + blazeList = new ArrayList<EntityBlaze>(w.getEntities(EntityBlaze.class, input -> { + BlockPos pos = input.getPosition(); + return low.getX() < pos.getX() && pos.getX() < high.getX() + && low.getZ() < pos.getZ() && pos.getZ() < high.getZ() && input.getName().toLowerCase().contains("blaze"); })); EntityArmorStand semi_target = null; @@ -64,6 +82,10 @@ public class RoomProcessorBlazeSolver extends GeneralRoomProcessor { } catch (Exception e){} } + if (semi_target != null) { + EntityArmorStand finalSemi_target = semi_target; + nextBlaze = blazeList.stream().filter(e -> e.getDistanceSqToEntity(finalSemi_target) < 9).findFirst().orElse(null); + } next = semi_target; } @@ -75,10 +97,87 @@ public class RoomProcessorBlazeSolver extends GeneralRoomProcessor { if (!FeatureRegistry.SOLVER_BLAZE.isEnabled()) return; if (next == null) return; Vec3 pos = next.getPositionEyes(partialTicks); - RenderUtils.highlightBox(next, new Color(0,255,0,100), partialTicks, false); RenderUtils.drawTextAtWorld("NEXT", (float)pos.xCoord, (float)pos.yCoord, (float)pos.zCoord, 0xFFFF0000, 0.5f, true, false, partialTicks); + + 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); + + + for (EntityBlaze entity : blazeList) { + float f = entity.prevRotationYaw + (entity.rotationYaw - entity.prevRotationYaw) * partialTicks; + double x = entity.prevPosX + (entity.posX - entity.prevPosX) * partialTicks; + double y = entity.prevPosY + (entity.posY - entity.prevPosY) * partialTicks; + double z = entity.prevPosZ + (entity.posZ - entity.prevPosZ) * partialTicks; + + + GL11.glEnable(GL11.GL_STENCIL_TEST); + GL11.glClearStencil(0); + GlStateManager.disableDepth(); + GL11.glClear(GL11.GL_STENCIL_BUFFER_BIT); + + GL11.glStencilMask(0xFF); + GL11.glStencilFunc(GL11.GL_ALWAYS, 1, 0xFF); + GL11.glStencilOp(GL11.GL_KEEP, GL11.GL_REPLACE, GL11.GL_REPLACE); + + GlStateManager.pushMatrix(); + GlStateManager.pushAttrib(); + GlStateManager.translate(-x_fix, -y_fix, -z_fix); + + GlStateManager.colorMask(false, false, false, false); + Minecraft.getMinecraft().getRenderManager().doRenderEntity(entity, x,y,z,f,partialTicks, true); + GlStateManager.colorMask(true, true, true, true); + + GlStateManager.popMatrix(); + GlStateManager.popAttrib(); + + GL11.glStencilFunc(GL11.GL_EQUAL, 1, 0xFF); + GL11.glStencilOp(GL11.GL_KEEP, GL11.GL_KEEP, GL11.GL_KEEP); + +// Gui.drawRect(-9999,-9999, 9999, 9999, 0xFFFFFFFF); + + boolean border = false; + + if (entity != nextBlaze) + RenderUtils.highlightBox(entity, AxisAlignedBB.fromBounds(-0.8,0, -0.8, 0.8, 2, 0.8), new Color(255,255,255,255), partialTicks, false); + else + RenderUtils.highlightBox(entity, AxisAlignedBB.fromBounds(-0.8,0, -0.8, 0.8, 2, 0.8), new Color(0,255,0,255), partialTicks, false); + GlStateManager.color(1,1,1,1); + + + if (border) { + GL11.glStencilFunc(GL11.GL_NOTEQUAL, 3, 0x01); + GL11.glStencilOp(GL11.GL_KEEP, GL11.GL_REPLACE, GL11.GL_REPLACE); + GlStateManager.pushMatrix(); + GlStateManager.pushAttrib(); + GlStateManager.translate(-x_fix, -y_fix, -z_fix); + GlStateManager.translate(x, y + 0.7, z); + GlStateManager.scale(1.1f, 1.1f, 1.1f); + + GlStateManager.colorMask(false, false, false, false); + Minecraft.getMinecraft().getRenderManager().doRenderEntity(entity, 0, -0.7, 0, f, partialTicks, true); + GlStateManager.colorMask(true, true, true, true); + + GlStateManager.popMatrix(); + GlStateManager.popAttrib(); + + + GL11.glStencilFunc(GL11.GL_EQUAL, 3, 0xFF); + GL11.glStencilOp(GL11.GL_KEEP, GL11.GL_KEEP, GL11.GL_KEEP); + + RenderUtils.highlightBox(entity, AxisAlignedBB.fromBounds(-1, 0, -1, 1, 2, 1), new Color(0, 255, 255, 255), partialTicks, false); + } + + + GL11.glDisable(GL11.GL_STENCIL_TEST); + GlStateManager.enableDepth(); + } } + + public static class Generator implements RoomProcessorGenerator<RoomProcessorBlazeSolver> { @Override public RoomProcessorBlazeSolver createNew(DungeonRoom dungeonRoom) { |