Posted January 26, 20169 yr Hi. I was wondering if it's possible to "hook" Mobs rendering and substitute with my own, or rather adding effects to their rendering for a specific entity in: for (Entity entity : (List<EntityMob>)worldObj.getEntitiesWithinAABB(EntityMob.class, box)) { } also contrl their sizes and everything. Thank you in advance. Not all things in the world are red, there are round objects too!
January 27, 20169 yr There is RenderLivingEvent.Pre/Post for this very purpose. Whatever flag(s) or other data you need will have to be sent to all tracking client players, however, so they know to perform the additional rendering. http://i.imgur.com/NdrFdld.png[/img]
January 28, 20169 yr Author OK, so I read a few tutorials and answers to questions, also some source code and came upp with this: @SubscribeEvent @SideOnly(Side.CLIENT) public void onRenderLivingPre(RenderLivingEvent.Pre event) { EntityLivingBase e = event.entity; if(e.getEntityData().getBoolean("shouldberesized")) { glPushMatrix(); glScalef(2F, 2F, 2F); } } @SubscribeEvent @SideOnly(Side.CLIENT) public void onRenderLivingPost(RenderLivingEvent.Post event) { EntityLivingBase e = event.entity; if(e.getEntityData().getBoolean("shouldberesized")) { glPopMatrix(); } } Dont worry about the "e.getEntityData().getBoolean("shouldberesized")" bit because that works. Also I didn't translate the position. But thats not my problem. The problem is that the entity (in my test cases, a Creeper) dont get doubled in size, it only floats up and then som strange perspective glitches happen. That entites behind the creeper gets in front as seen here: http://image.baver.se/img/BOR64wp In the picture, the creeper is standing besides the stone block, and the slime is about 10-15 blocks behind the creeper. So 2 problems, the scaling dont work and that the perspective is off. But maybe the perspective is because it isn't translated? Not all things in the world are red, there are round objects too!
January 29, 20169 yr Author Argh feel like ive tried everything. Somebody that at least know if im on the right track? Not all things in the world are red, there are round objects too!
February 1, 20169 yr if the reder works the de same in 1.8.9 as 1.8 you must change the size and respect to dis you must change also the translation to fix your render position, in 1.8 i beeen creating zombies whith diferents sizes form 1.5M to 7M and was a pain i could'n get a formula to calculate it dinamically and end fixing every size and translation at hand f6 is the scaling factor for the render and alt is the heigth the entity must be render whith relation to the ground GlStateManager.scale(1.0F * f6, 1.0F * f6, 1.0F * f6); GlStateManager.translate(0.0F, alt , 0.0F);
February 1, 20169 yr Author I tried now with the translate. And the result is that the creeper now is flying http://image.baver.se/img/iqfpdKn @SubscribeEvent @SideOnly(Side.CLIENT) public void onRenderLivingPre(RenderLivingEvent.Pre event) { EntityLivingBase e = event.entity; if(e.getEntityData().getBoolean("isConsumedSacrificeAltar")) { glPushMatrix(); glScalef(2F, 2F, 2F); glTranslatef(0, 4F, 0); } } @SubscribeEvent @SideOnly(Side.CLIENT) public void onRenderLivingPost(RenderLivingEvent.Post event) { EntityLivingBase e = event.entity; if(e.getEntityData().getBoolean("isConsumedSacrificeAltar")) { glPopMatrix(); } } Not all things in the world are red, there are round objects too!
February 1, 20169 yr in teresting in mi render model a positive value in GlStateManager.translate(0.0F, alt , 0.0F); causes the entity to go down, the other thing is mi values are not so high for example mi mob of 4M //4.M case 9:{ f6 = 2.00F ; alt = -0.75F; };break; a 4 as you have in the code must set the entity very deep down in the ground so your render model must be diferent from the mine //################################################################################################################# /** * Sets the models various rotation angles then renders the model. */ @Override public void render(Entity merEntity, float p_78088_2_, float p_78088_3_, float p_78088_4_, float p_78088_5_, float p_78088_6_, float p_78088_7_) { //System.out.println("render()"); this.setRotationAngles(p_78088_2_, p_78088_3_, p_78088_4_, p_78088_5_, p_78088_6_, p_78088_7_, merEntity); GlStateManager.pushMatrix(); if (this.isChild) { float f6 = 2.0F; GlStateManager.scale(1.5F / f6, 1.5F / f6, 1.5F / f6); GlStateManager.translate(0.0F, 16.0F * p_78088_7_, 0.0F); this.bipedHead.render(p_78088_7_); GlStateManager.popMatrix(); GlStateManager.pushMatrix(); GlStateManager.scale(1.0F / f6, 1.0F / f6, 1.0F / f6); GlStateManager.translate(0.0F, 24.0F * p_78088_7_, 0.0F); this.exclamacionIcon.render(p_78088_7_); this.bipedBody.render(p_78088_7_); this.bipedRightArm.render(p_78088_7_); this.bipedLeftArm.render(p_78088_7_); this.bipedRightLeg.render(p_78088_7_); this.bipedLeftLeg.render(p_78088_7_); this.bipedHeadwear.render(p_78088_7_); this.biPhalous_A00.render(p_78088_7_); this.biPhalous_B00.render(p_78088_7_); this.biPhalous_C00.render(p_78088_7_); this.biPhalous_D00.render(p_78088_7_); } else { if (merEntity instanceof aldeanoMercenario ){ aldeanoMercenario merc = (aldeanoMercenario) merEntity; //lrsb = merc.getDataWatcher().getWatchableObjectInt(23); lrsb = merc.getLrsb(); } if (merEntity instanceof zombieMercenario ){ zombieMercenario merc = (zombieMercenario) merEntity; //lrsb = merc.getDataWatcher().getWatchableObjectInt(23); lrsb = merc.getLrsb(); } if (merEntity instanceof zombieMercenarioE ){ zombieMercenarioE merc = (zombieMercenarioE) merEntity; //lrsb = merc.getDataWatcher().getWatchableObjectInt(23); lrsb = merc.getLrsb(); } tamaño = (byte) ((lrsb % 10000000 ) / 1000000 ); float f6 = 0.0F ; float alt = 0.0F; switch(tamaño) { //1.5M case 1:{ f6 = 0.75F ; alt = 0.5F ; };break; //1.624M case 2:{ f6 = 0.812F ; alt = 0.4F ; };break; //1.75M case 3:{ f6 = 0.875F ; alt = 0.2F ; };break; //1.87M case 4:{ f6 = 0.9375F; alt = 0.05F ; };break; //2.00M default:{ f6 = 1.0F ; alt = 0.00F ; };break; //2.25M case 6:{ f6 = 1.125F ; alt = -0.15F; };break; //2.5M case 7:{ f6 = 1.25F ; alt = -0.3F ; };break; //3.0M case 8:{ f6 = 1.5F ; alt = -0.5F ; };break; //4.M case 9:{ f6 = 2.00F ; alt = -0.75F; };break; //7M case 10:{ f6 = 3.5F ; alt = -1.00F; };break; } GlStateManager.scale(1.0F * f6, 1.0F * f6, 1.0F * f6); GlStateManager.translate(0.0F, alt , 0.0F); if (merEntity.isSneaking()) { GlStateManager.translate(0.0F, alt + 0.2F, 0.0F); } this.exclamacionIcon.render(p_78088_7_); this.bipedHead.render(p_78088_7_); this.bipedBody.render(p_78088_7_); this.bipedRightArm.render(p_78088_7_); this.bipedLeftArm.render(p_78088_7_); this.villagerArms.render(p_78088_7_); this.bipedRightLeg.render(p_78088_7_); this.bipedLeftLeg.render(p_78088_7_); this.bipedHeadwear.render(p_78088_7_); this.biPhalous_A00.render(p_78088_7_); this.biPhalous_B00.render(p_78088_7_); this.biPhalous_C00.render(p_78088_7_); this.biPhalous_D00.render(p_78088_7_); } GlStateManager.popMatrix();
February 1, 20169 yr Author Ok, made some progress.. If I only scale Y to 2F then the creeper gets taller, but now seems stretched because i only scaled Y. GL11.glScalef(1F, 2F, 1F); http://image.baver.se/img/nxeP8Po But then if I scale all (X Y Z) the Y scaling disappear. GL11.glScalef(2F, 2F, 2F); http://image.baver.se/img/NDm60iN Am I thinking wrong? Not all things in the world are red, there are round objects too!
February 2, 20169 yr I think your pushing and popping of the matrix is probably screwing up. You have them both happen conditionally, but what if one of the conditions isn't true? You might do extra pops or pushes. Furthermore, I'm not certain what happens if you push in the Pre event and pop in the Post event because these events are called for ALL the entities. So what will happen is that it will push, push, push, and then pop, pop, pop. I think you shouldn't need a matrix at all because I believe the render event should already have a matrix that is focused on the entity of interest. So I'd try just scaling directly. Check out my tutorials here: http://jabelarminecraft.blogspot.com/
February 2, 20169 yr Author The condition is the same for both the push and pop, so if the condition is true for the push it is also true for the pop. But you were right about the pushing and popping, commented those lines and tried again. Now the creeper scales in all directions perfectly (Only my translation that is screwed now, but I will fix it) BUT.. Theres always a but Now my tileentity also goes flying in the air. So the ariginal problem is solved, thanks. Now I will troubleshoot why my tilentity fly in the air. But thats probably because my translation is f* up [EDIT] It seems like if i dont push and pop signs and other mobs get screwed up. [EDIT2] It only happens if I look at the creeper though. Not all things in the world are red, there are round objects too!
February 3, 20169 yr Only my translation that is screwed now, but I will fix it if you scale you always need to also translate because otherwise the entity will scale into the ground. So you have to translate by the eye level then translate back by new scaled eye level. I figured out the formula for that: GL11.glTranslatef(0F, 1.5F-1.5F*scaleFactor, 0F); Maybe that is the issue you've been facing -- the model origin is offset from the entity origin by the eye level? Not sure about your entity flying away problem though... Instead of events, if this is for your own custom entities only, you can @Override the preRenderCallback() method in the custom Renderer class for your entity. I usually do my entity scaling there. Or you could also do it within your Model class. If you want to do the scaling for all entities then yes you need to get the events working for you. Check out my tutorials here: http://jabelarminecraft.blogspot.com/
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.