
sFXprt
Members-
Posts
68 -
Joined
-
Last visited
-
Days Won
1
Everything posted by sFXprt
-
Got it, thanks for letting me know 👍
-
As the title states I want to render a layer or really anything that makes the entities I select turn blue, similar to the red layering of when a player is on fire but with my own twists to it. I have looked in vanilla code and saw that RenderBlockScreenEffectEvent holds all the information before the layering is added to the player(apparently its a block layered onto a player I am unsure) I want to do this but there is no actual code about how to do it its just documentation and get() methods. I've seen other members on the forum mention RenderSystem.setShaderColor but I dont understand how to get the ShaderInstance of the entity. Right now I am stuck between using RenderSystem or creating my own Layering which again has little to no documentation on it. Currently this is all I have @SubscribeEvent public static void onLivingRender(RenderLivingEvent.Pre e){ LivingEntity entity = e.getEntity(); if(entity.getPersistentData().contains(XprtData.ICE_BALL_FROZEN)){ RenderSystem.setShader(GameRenderer::getRendertypeEntityNoOutlineShader); RenderSystem.setShaderColor(0,0,255,1); } } I noticed in the event it has LivingRenderer class which has getModel() which also has a render method which can be used to re-render the model which I have also tried to do but when getting the RenderType from its ResourceLocation it just returns a default player model head and is placed directly at head level of the entity. Very weird
-
ah I think I know what to do now. Thank you
-
I understand that part already, the problem is trying to get other players to see the change
-
Currently I have a mod that involves flying, which when activated shows the user's players crawling/swimming in the air while flying but this is only visible to the person flying and not other clients on the server (I achieved this by using LocalPlayer and checking for id/Entity#equals then forcing swimming pose). How do I get other players to see the person flying's pose as crawling/swimming as well? The current things I have tried is iterating through online player list in ServerLevel and casting the ServerPlayer to Players and getting ClientLevel from said Players and force editing the pose for any entities in the entitiesForRendering() method that matches the criteria for flying. But that did not work at all and nothing happened. (Sorry I have no code on me right now I am on the phone away from computer) I also attempted to send packets to each nearby player that has said flying player rendered. This resulted in the flyer to no longer force crawl/swim in the air. I even attempted to mess with each clients LocalPlayer in attempt to show the flyer as crawl/swimming but that failed too and causes a bit of lag which is not optimal for me. Any ideas or solutions would help me greatly!
-
I can easily draw the bounding box of an entity on the client side, but now the problem is that I can only see the lines when I am not behind any blocks. Here is the draw method public static void drawLineBox(Client client, PoseStack matrixStack, AABB aabb) { Vec3 camVec = client.getInstance().getEntityRenderDispatcher().camera.getPosition(); VertexConsumer vertexConsumer = Minecraft.getInstance().renderBuffers().bufferSource().getBuffer(RenderType.lines()); RenderSystem.disableDepthTest(); matrixStack.pushPose(); matrixStack.translate(-camVec.x(), -camVec.y(), -camVec.z()); LevelRenderer.renderLineBox(matrixStack, vertexConsumer, aabb, 15f, 15f, 15f, 1F); matrixStack.popPose(); RenderSystem.enableDepthTest(); } Here is how I call it @SubscribeEvent public static void onRender(RenderLevelStageEvent e){ Client client = new Client(); if(e.getStage().equals(RenderLevelStageEvent.Stage.AFTER_ENTITIES)){ for(Entity entity : client.getInstance().level.entitiesForRendering()){ if(entity instanceof LivingEntity target){ if(!Utils.isPlayer(target)){ drawLineBox(client, e.getPoseStack(), target.getBoundingBox()); } } } } } Like I said it renders the boxes perfectly but I can only see them when my vision isn't blocked. I tried following an x-ray mod which drew using Tesselator and VertexBuffer instead of just purely LevelRenderer. https://github.com/AdvancedXRay/XRay-Mod/blob/main/src/main/java/pro/mikey/xray/xray/Render.java#:~:text=static void renderBlocks(RenderLevelStageEvent event) { After closely following the code and editing it to match my goals it wouldn't render any entities except just randomly rendering blocks that had nothing to do with entities(I used Entity#position() instead of Entity#getBoundingBox()) However the code in the github above does in fact allow me to see the box through blocks which is exactly what I want but draws the wrong things and in the wrong area. Before anyone says, I've already tried disabling and re-enabling depth test using various classes/methods. I've used the following below RenderSystem.disableDepthTest(); GlStateManager._disableDepthTest(); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glDisable(GL11.GL_DEPTH); RenderSystem.depthMask(false); which none of them work at all when drawing with LevelRenderer which makes me things its a LevelRenderer issue? Ill look into code using LevelRenderer if I find any...
-
@warjort how do I render the boxes through blocks? I tried to disableDepthTest and enable it after and it didnt work
-
@warjortthank you so much that fixed it and I completely understand now I'm going to revamp code. Thanks
-
As the title states, I finally managed to figure out how to draw entities. Problem is, I can't figure out why its drawing the boxes twice. https://ibb.co/X3xhyY0 Here is the code that draws public static void drawLineBox(PoseStack matrixStack, AABB aabb, Camera camEntity, float r, float g, float b, float a) { double d0 = camEntity.getPosition().x(); double d1 = camEntity.getPosition().y(); double d2 = camEntity.getPosition().z(); RenderSystem.depthMask(false); // disable showing lines through blocks VertexConsumer vertexConsumer = Minecraft.getInstance().renderBuffers().bufferSource().getBuffer(RenderType.lines()); matrixStack.pushPose(); matrixStack.translate(-d0, -d1, -d2); // because we start at 0,0,0 relative to camera LevelRenderer.renderLineBox(matrixStack, vertexConsumer, aabb, r, g, b, a); matrixStack.popPose(); } Here is where its called from @SubscribeEvent public static void onRender(RenderLevelStageEvent e){ for(Entity entity : Minecraft.getInstance().level.entitiesForRendering()){ drawLineBox(e.getPoseStack(), entity.getBoundingBoxForCulling(), e.getCamera(),15.9f, 15.9f, 15.9f, 15.5f); } } Any ideas? I'm not familiar with drawing with forge/and or OpenGL. On C++ its extremely easy and I understand the concept of drawing but here I have no idea. EDIT: Im assuming this has to do with FoV as moving the slider down makes the two boxes render in the same exact place thus making it look a lot better than what I see in the picture, however I just want to make sure if thats it or theres some error on my part thats making the boxes render twice
-
1.19.3 Cant Set Custom Xp Cost in AnvilUpdateEvent
sFXprt replied to sFXprt's topic in Modder Support
@ChampionAsh5357I see, thanks for your help anyways. -
1.19.3 Cant Set Custom Xp Cost in AnvilUpdateEvent
sFXprt replied to sFXprt's topic in Modder Support
Thanks, I understand, I found a mod that does what I want anyways so no need. But on the topic what do you mean by determining the output. Would it be by their super class? Or by ItemStack#getRepairCosr -
As the title states, I cant set the maximum xp spent on repair to 30. @SubscribeEvent public static void onAnvilUpdate(AnvilUpdateEvent e){ if(e.getCost() > 30){ e.setCost(30); } } Before people ask, I tried it two ways, one with just how it is above and one with setting e.setOutput to e.getOutput and nothing works. I even downloaded an external mod that fixes Anvil Repair Costs but that didnt work either. EDIT: Ive done debugging and realized the cost is always 0 when unenchanted and once enough enchantments are put it then return 1 for e.getCost(), I am so confused how do I get it to set to a max cost of 30 xp level?? EDIT #2: I now realize that anvil repair cost depends on each individual enchantment cost defined in their classes. Which we cant change that so what can I do to change the overall cost? Im gonna look through vanilla code to figure this out. EDIT #3: After looking through vanilla code, ive seen that the itemstacks hold repaircost, ive tried to set cost to 30 if its over 30 and it still isnt working, ive tried this on both AnvilRepair and AnvilUpdate Event...
-
@warjort thank you for your response, I can now access any given entitys renderer instance so how would I go about drawing it? Only example that comes to my mind is the glowing effect. Which I've tried to find its functionality through vanilla code to no avail. Best I found was it referring to a glowing.png file which upon opening the picture it displayed a skeleton head with white squares surrounding it. EDIT: I've found this other forge topic which is exactly what I'm trying to achieve - However it runs on different code, specifically I cant find setTranslation() and RenderGlobal doesn't exist(maybe its RenderSystem now?)
-
@warjort Thanks for helping me understand things better, so where do I go from now say for instance I want to draw an Rectangular Box around an Entity. Would I go about this using the RenderSystem class? If so could I get a simple example? I tried following Wurst Client source code which led me to seeing RenderSystem, VertexBuffer, and something called a MatrixStack being used? Which was called to get the View Matrix Matrix4f viewMatrix = matrixStack.peek().getPositionMatrix(); https://github.com/Wurst-Imperium/Wurst7/blob/master/src/main/java/net/wurstclient/hacks/chestesp/ChestEspRenderer.java#:~:text=Matrix4f viewMatrix %3D matrixStack.peek().getPositionMatrix()%3B
-
Hi, I am trying to get the View Matrix so I can draw stuff in the game such as ESP or block/item/entity glow. Issue is I cant find the correct View Matrix. I am able to find the Projection Matrix from Minecraft.getInstance().gameRenderer.getProjectionMatrix(Minecraft.getInstance().options.fov().get()); and it works but I cant find the View Matrix at all. I've looked through all the classes and methods and the closest thing I found was RenderSystem.getModelViewMatrix(); RenderSystem.getShader().MODEL_VIEW_MATRIX.getFloatBuffer() Minecraft.getInstance().gameRenderer.blitShader.MODEL_VIEW_MATRIX.getFloatBuffer(); Minecraft.getInstance().gameRenderer.getShader("").MODEL_VIEW_MATRIX.getFloatBuffer(); // Anyone know what goes in the string argument?? which both causes the game to print the usual unexpected errors message when running the code. This is all my code does so far Vector3f screen_pos = WorldToScreen(new Vector3f((float) entity.position().x(), (float) entity.position().y(), (float) entity.position().z()), view_matrix, height, width); Utils.MessageEx(p, "Screen X: " + screen_pos.x() + " Screen Y: " + screen_pos.y(), false); All it does is return "An unexpected error has occurred" in the chat and I can't trace the exception error since its not stored in the logs unless a crash occurs(please let me know how to trace exceptions without crash) So I'm just assuming I'm getting uninitialized matrix data which results in some null exception or something. EDIT: I think I may have found it, calling Matrix4f m = new PoseStack().last().pose(); returns valid numbers in after World To Screen is called. Before I start rendering can anyone confirm this is indeed the most up to date View Matrix? And is there an interface forge uses to render objects. I know it dabbles in OpenGL but I am very unfamiliar with it and I was hoping it had built in rendering to combat open use of GL