Posted June 24, 20178 yr I've created custom overlay rendering on entity (just like fire overlay) when entity has potion effect. My problem is my custom overlay not rendered on other entities but only work with player. Not sure why it doesn't work Please let me know if I doing something wrong, Thanks. Picture Code @SubscribeEvent public void onRenderLiving(RenderLivingEvent.Post event) { EntityLivingBase living = event.getEntity(); System.out.println(living.getActivePotionEffects().contains(MPPotions.INFECTED_CRYSTALLIZE)); // debug test - always return false if (living.isPotionActive(MPPotions.INFECTED_CRYSTALLIZE)) { GlStateManager.disableLighting(); TextureMap texturemap = this.mc.getTextureMapBlocks(); TextureAtlasSprite textureatlassprite = texturemap.getAtlasSprite("moreplanets:blocks/infected_crystallize"); GlStateManager.pushMatrix(); GlStateManager.translate((float)event.getX(), (float)event.getY(), (float)event.getZ()); float f = living.width * 1.4F; GlStateManager.scale(f, f, f); Tessellator tessellator = Tessellator.getInstance(); VertexBuffer worldrenderer = tessellator.getBuffer(); float f1 = 0.5F; float f2 = 0.0F; float f3 = living.height / f; float f4 = (float)(living.posY - living.getEntityBoundingBox().minY); GlStateManager.rotate(-event.getRenderer().getRenderManager().playerViewY, 0.0F, 1.0F, 0.0F); GlStateManager.translate(0.0F, 0.0F, -0.3F + (int)f3 * 0.02F); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); float f5 = 0.0F; int i = 0; worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX); while (f3 > 0.0F) { event.getRenderer().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); float f6 = textureatlassprite.getMinU(); float f7 = textureatlassprite.getMinV(); float f8 = textureatlassprite.getMaxU(); float f9 = textureatlassprite.getMaxV(); if (i / 2 % 2 == 0) { float f10 = f8; f8 = f6; f6 = f10; } worldrenderer.pos(f1 - f2, 0.0F - f4, f5).tex(f8, f9).endVertex(); worldrenderer.pos(-f1 - f2, 0.0F - f4, f5).tex(f6, f9).endVertex(); worldrenderer.pos(-f1 - f2, 1.4F - f4, f5).tex(f6, f7).endVertex(); worldrenderer.pos(f1 - f2, 1.4F - f4, f5).tex(f8, f7).endVertex(); f3 -= 0.45F; f4 -= 0.45F; f1 *= 0.9F; f5 += 0.03F; ++i; } tessellator.draw(); GlStateManager.popMatrix(); GlStateManager.enableLighting(); }
June 26, 20178 yr Author I've looking at Twilight Forest render event, Ice Cubed will rendered if entity has slowness attribute. https://github.com/TeamTwilight/twilightforest/blob/1.11.2/src/main/java/twilightforest/client/TFClientEvents.java#L53-L61 So I've try the same way as TW does. (Sorry I'm not expert at custom packet and I really don't understand how to do step by step as you said) But this working correctly. private static final AttributeModifier CRYSTALLIZE_POTION_MODIFIER = new AttributeModifier(UUID.fromString("0B0BC323-E263-4EF8-9108-4B6503129B16"), "generic.crystallize_effect", 0, 0); @SubscribeEvent public void onRenderLiving(RenderLivingEvent.Post event) { EntityLivingBase living = event.getEntity(); // check if entity has crystallize potion modifier boolean hasPotion = living.getEntityAttribute(InfectedCrystallizeEffect.CRYSTALLIZE_EFFECT) != null ? living.getEntityAttribute(InfectedCrystallizeEffect.CRYSTALLIZE_EFFECT).hasModifier(CRYSTALLIZE_POTION_MODIFIER) : false; if (hasPotion) { GlStateManager.disableLighting(); TextureMap texturemap = this.mc.getTextureMapBlocks(); TextureAtlasSprite textureatlassprite = texturemap.getAtlasSprite("moreplanets:blocks/infected_crystallize"); GlStateManager.pushMatrix(); GlStateManager.translate((float)event.getX(), (float)event.getY(), (float)event.getZ()); float f = living.width * 1.4F; GlStateManager.scale(f, f, f); Tessellator tessellator = Tessellator.getInstance(); VertexBuffer worldrenderer = tessellator.getBuffer(); float f1 = 0.5F; float f2 = 0.0F; float f3 = living.height / f; float f4 = (float)(living.posY - living.getEntityBoundingBox().minY); GlStateManager.rotate(-event.getRenderer().getRenderManager().playerViewY, 0.0F, 1.0F, 0.0F); GlStateManager.translate(0.0F, 0.0F, -0.3F + (int)f3 * 0.02F); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); float f5 = 0.0F; int i = 0; worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX); while (f3 > 0.0F) { event.getRenderer().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); float f6 = textureatlassprite.getMinU(); float f7 = textureatlassprite.getMinV(); float f8 = textureatlassprite.getMaxU(); float f9 = textureatlassprite.getMaxV(); if (i / 2 % 2 == 0) { float f10 = f8; f8 = f6; f6 = f10; } worldrenderer.pos(f1 - f2, 0.0F - f4, f5).tex(f8, f9).endVertex(); worldrenderer.pos(-f1 - f2, 0.0F - f4, f5).tex(f6, f9).endVertex(); worldrenderer.pos(-f1 - f2, 1.4F - f4, f5).tex(f6, f7).endVertex(); worldrenderer.pos(f1 - f2, 1.4F - f4, f5).tex(f8, f7).endVertex(); f3 -= 0.45F; f4 -= 0.45F; f1 *= 0.9F; f5 += 0.03F; ++i; } tessellator.draw(); GlStateManager.popMatrix(); GlStateManager.enableLighting(); } } @SubscribeEvent public void onEntityJoinWorld(EntityJoinWorldEvent event) { if (event.getEntity() instanceof EntityLivingBase) { EntityLivingBase living = (EntityLivingBase) event.getEntity(); // check if generic.crystallize_effect is not registed to AttributeMap // also prevent exception on server side if (living.getAttributeMap().getAttributeInstanceByName("generic.crystallize_effect") == null) { living.getAttributeMap().registerAttribute(InfectedCrystallizeEffect.CRYSTALLIZE_EFFECT); } } } // Potion class public static final IAttribute CRYSTALLIZE_EFFECT = new RangedAttribute((IAttribute)null, "generic.crystallize_effect", 0.0D, 0.0D, 0.0D).setShouldWatch(true); public InfectedCrystallizeEffect() { super("infected_crystallize", true, ColorHelper.rgbToDecimal(136, 97, 209), 0); this.registerPotionAttributeModifier(InfectedCrystallizeEffect.CRYSTALLIZE_EFFECT, "0B0BC323-E263-4EF8-9108-4B6503129B16", 0.0D, 0); } Edited June 26, 20178 yr by lamp3345
June 27, 20178 yr Author Hm, I found some problem. Not a game breaking, So how I can fix this after reload worlds? [12:48:10] [Server thread/WARN]: Ignoring unknown attribute 'generic.crystallize_effect' Server Log from SharedMonsterAttributes#setAttributeModifiers Edited June 27, 20178 yr by lamp3345
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.