Class des Effets de Potions
-
Ah j’ai trouvé mais le code use des declarations qui meme si je les copies avec les dependances etc ne marche pas
-
Envoie le code ?
-
Il y a 2 choses qui sont dans la classe (net.minecraft.client.renderer.EntityRenderer):
WorldClient worldclient = this.mc.theWorld; double d0 = (entitylivingbase.lastTickPosY + (entitylivingbase.posY - entitylivingbase.lastTickPosY) * (double)p_78466_1_) * worldclient.provider.getVoidFogYFactor(); if (entitylivingbase.isPotionActive(Potion.blindness)) { int i = entitylivingbase.getActivePotionEffect(Potion.blindness).getDuration(); if (i < 20) { d0 *= (double)(1.0F - (float)i / 20.0F); } else { d0 = 0.0D; } } ]Code semi-complet:
:::private void updateFogColor(float p_78466_1_) { WorldClient worldclient = this.mc.theWorld; EntityLivingBase entitylivingbase = this.mc.renderViewEntity; float f1 = 0.25F + 0.75F * (float)this.mc.gameSettings.renderDistanceChunks / 16.0F; f1 = 1.0F - (float)Math.pow((double)f1, 0.25D); Vec3 vec3 = worldclient.getSkyColor(this.mc.renderViewEntity, p_78466_1_); float f2 = (float)vec3.xCoord; float f3 = (float)vec3.yCoord; float f4 = (float)vec3.zCoord; Vec3 vec31 = worldclient.getFogColor(p_78466_1_); this.fogColorRed = (float)vec31.xCoord; this.fogColorGreen = (float)vec31.yCoord; this.fogColorBlue = (float)vec31.zCoord; float f5; if (this.mc.gameSettings.renderDistanceChunks >= 4) { Vec3 vec32 = MathHelper.sin(worldclient.getCelestialAngleRadians(p_78466_1_)) > 0.0F ? Vec3.createVectorHelper(-1.0D, 0.0D, 0.0D) : Vec3.createVectorHelper(1.0D, 0.0D, 0.0D); f5 = (float)entitylivingbase.getLook(p_78466_1_).dotProduct(vec32); if (f5 < 0.0F) { f5 = 0.0F; } if (f5 > 0.0F) { float[] afloat = worldclient.provider.calcSunriseSunsetColors(worldclient.getCelestialAngle(p_78466_1_), p_78466_1_); if (afloat != null) { f5 *= afloat[3]; this.fogColorRed = this.fogColorRed * (1.0F - f5) + afloat[0] * f5; this.fogColorGreen = this.fogColorGreen * (1.0F - f5) + afloat[1] * f5; this.fogColorBlue = this.fogColorBlue * (1.0F - f5) + afloat[2] * f5; } } } this.fogColorRed += (f2 - this.fogColorRed) * f1; this.fogColorGreen += (f3 - this.fogColorGreen) * f1; this.fogColorBlue += (f4 - this.fogColorBlue) * f1; float f8 = worldclient.getRainStrength(p_78466_1_); float f9; if (f8 > 0.0F) { f5 = 1.0F - f8 * 0.5F; f9 = 1.0F - f8 * 0.4F; this.fogColorRed *= f5; this.fogColorGreen *= f5; this.fogColorBlue *= f9; } f5 = worldclient.getWeightedThunderStrength(p_78466_1_); if (f5 > 0.0F) { f9 = 1.0F - f5 * 0.5F; this.fogColorRed *= f9; this.fogColorGreen *= f9; this.fogColorBlue *= f9; } Block block = ActiveRenderInfo.getBlockAtEntityViewpoint(this.mc.theWorld, entitylivingbase, p_78466_1_); float f10; if (this.cloudFog) { Vec3 vec33 = worldclient.getCloudColour(p_78466_1_); this.fogColorRed = (float)vec33.xCoord; this.fogColorGreen = (float)vec33.yCoord; this.fogColorBlue = (float)vec33.zCoord; } else if (block.getMaterial() == Material.water) { f10 = (float)EnchantmentHelper.getRespiration(entitylivingbase) * 0.2F; this.fogColorRed = 0.02F + f10; this.fogColorGreen = 0.02F + f10; this.fogColorBlue = 0.2F + f10; } else if (block.getMaterial() == Material.lava) { this.fogColorRed = 0.6F; this.fogColorGreen = 0.1F; this.fogColorBlue = 0.0F; } f10 = this.fogColor2 + (this.fogColor1 - this.fogColor2) * p_78466_1_; this.fogColorRed *= f10; this.fogColorGreen *= f10; this.fogColorBlue *= f10; double d0 = (entitylivingbase.lastTickPosY + (entitylivingbase.posY - entitylivingbase.lastTickPosY) * (double)p_78466_1_) * worldclient.provider.getVoidFogYFactor(); if (entitylivingbase.isPotionActive(Potion.blindness)) { int i = entitylivingbase.getActivePotionEffect(Potion.blindness).getDuration(); if (i < 20) { d0 *= (double)(1.0F - (float)i / 20.0F); } else { d0 = 0.0D; } } if (d0 < 1.0D) { if (d0 < 0.0D) { d0 = 0.0D; } d0 *= d0; this.fogColorRed = (float)((double)this.fogColorRed * d0); this.fogColorGreen = (float)((double)this.fogColorGreen * d0); this.fogColorBlue = (float)((double)this.fogColorBlue * d0); } float f11; if (this.bossColorModifier > 0.0F) { f11 = this.bossColorModifierPrev + (this.bossColorModifier - this.bossColorModifierPrev) * p_78466_1_; this.fogColorRed = this.fogColorRed * (1.0F - f11) + this.fogColorRed * 0.7F * f11; this.fogColorGreen = this.fogColorGreen * (1.0F - f11) + this.fogColorGreen * 0.6F * f11; this.fogColorBlue = this.fogColorBlue * (1.0F - f11) + this.fogColorBlue * 0.6F * f11; } float f6; if (entitylivingbase.isPotionActive(Potion.nightVision)) { f11 = this.getNightVisionBrightness(this.mc.thePlayer, p_78466_1_); f6 = 1.0F / this.fogColorRed; if (f6 > 1.0F / this.fogColorGreen) { f6 = 1.0F / this.fogColorGreen; } if (f6 > 1.0F / this.fogColorBlue) { f6 = 1.0F / this.fogColorBlue; } this.fogColorRed = this.fogColorRed * (1.0F - f11) + this.fogColorRed * f6 * f11; this.fogColorGreen = this.fogColorGreen * (1.0F - f11) + this.fogColorGreen * f6 * f11; this.fogColorBlue = this.fogColorBlue * (1.0F - f11) + this.fogColorBlue * f6 * f11; } if (this.mc.gameSettings.anaglyph) { f11 = (this.fogColorRed * 30.0F + this.fogColorGreen * 59.0F + this.fogColorBlue * 11.0F) / 100.0F; f6 = (this.fogColorRed * 30.0F + this.fogColorGreen * 70.0F) / 100.0F; float f7 = (this.fogColorRed * 30.0F + this.fogColorBlue * 70.0F) / 100.0F; this.fogColorRed = f11; this.fogColorGreen = f6; this.fogColorBlue = f7; } net.minecraftforge.client.event.EntityViewRenderEvent.FogColors event = new net.minecraftforge.client.event.EntityViewRenderEvent.FogColors(this, entitylivingbase, block, p_78466_1_, this.fogColorRed, this.fogColorGreen, this.fogColorBlue); MinecraftForge.EVENT_BUS.post(event); this.fogColorRed = event.red; this.fogColorBlue = event.blue; this.fogColorGreen = event.green; GL11.glClearColor(this.fogColorRed, this.fogColorGreen, this.fogColorBlue, 0.0F); }:::
if (entitylivingbase.isPotionActive(Potion.blindness)) { f1 = 5.0F; int j = entitylivingbase.getActivePotionEffect(Potion.blindness).getDuration(); if (j < 20) { f1 = 5.0F + (this.farPlaneDistance - 5.0F) * (1.0F - (float)j / 20.0F); } GL11.glFogi(GL11.GL_FOG_MODE, GL11.GL_LINEAR); if (p_78468_1_ < 0) { GL11.glFogf(GL11.GL_FOG_START, 0.0F); GL11.glFogf(GL11.GL_FOG_END, f1 * 0.8F); } else { GL11.glFogf(GL11.GL_FOG_START, f1 * 0.25F); GL11.glFogf(GL11.GL_FOG_END, f1); } if (GLContext.getCapabilities().GL_NV_fog_distance) { GL11.glFogi(34138, 34139); } }Code semi complet:
:::private void setupFog(int p_78468_1_, float p_78468_2_) { EntityLivingBase entitylivingbase = this.mc.renderViewEntity; boolean flag = false; if (entitylivingbase instanceof EntityPlayer) { flag = ((EntityPlayer)entitylivingbase).capabilities.isCreativeMode; } if (p_78468_1_ == 999) { GL11.glFog(GL11.GL_FOG_COLOR, this.setFogColorBuffer(0.0F, 0.0F, 0.0F, 1.0F)); GL11.glFogi(GL11.GL_FOG_MODE, GL11.GL_LINEAR); GL11.glFogf(GL11.GL_FOG_START, 0.0F); GL11.glFogf(GL11.GL_FOG_END, 8.0F); if (GLContext.getCapabilities().GL_NV_fog_distance) { GL11.glFogi(34138, 34139); } GL11.glFogf(GL11.GL_FOG_START, 0.0F); } else { GL11.glFog(GL11.GL_FOG_COLOR, this.setFogColorBuffer(this.fogColorRed, this.fogColorGreen, this.fogColorBlue, 1.0F)); GL11.glNormal3f(0.0F, -1.0F, 0.0F); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); Block block = ActiveRenderInfo.getBlockAtEntityViewpoint(this.mc.theWorld, entitylivingbase, p_78468_2_); float f1; net.minecraftforge.client.event.EntityViewRenderEvent.FogDensity event = new net.minecraftforge.client.event.EntityViewRenderEvent.FogDensity(this, entitylivingbase, block, p_78468_2_, 0.1F); if (MinecraftForge.EVENT_BUS.post(event)) { GL11.glFogf(GL11.GL_FOG_DENSITY, event.density); } else if (entitylivingbase.isPotionActive(Potion.blindness)) { f1 = 5.0F; int j = entitylivingbase.getActivePotionEffect(Potion.blindness).getDuration(); if (j < 20) { f1 = 5.0F + (this.farPlaneDistance - 5.0F) * (1.0F - (float)j / 20.0F); } GL11.glFogi(GL11.GL_FOG_MODE, GL11.GL_LINEAR); if (p_78468_1_ < 0) { GL11.glFogf(GL11.GL_FOG_START, 0.0F); GL11.glFogf(GL11.GL_FOG_END, f1 * 0.8F); } else { GL11.glFogf(GL11.GL_FOG_START, f1 * 0.25F); GL11.glFogf(GL11.GL_FOG_END, f1); } if (GLContext.getCapabilities().GL_NV_fog_distance) { GL11.glFogi(34138, 34139); } } else if (this.cloudFog) { GL11.glFogi(GL11.GL_FOG_MODE, GL11.GL_EXP); GL11.glFogf(GL11.GL_FOG_DENSITY, 0.1F); } else if (block.getMaterial() == Material.water) { GL11.glFogi(GL11.GL_FOG_MODE, GL11.GL_EXP); if (entitylivingbase.isPotionActive(Potion.waterBreathing)) { GL11.glFogf(GL11.GL_FOG_DENSITY, 0.05F); } else { GL11.glFogf(GL11.GL_FOG_DENSITY, 0.1F - (float)EnchantmentHelper.getRespiration(entitylivingbase) * 0.03F); } } else if (block.getMaterial() == Material.lava) { GL11.glFogi(GL11.GL_FOG_MODE, GL11.GL_EXP); GL11.glFogf(GL11.GL_FOG_DENSITY, 2.0F); } else { f1 = this.farPlaneDistance; if (this.mc.theWorld.provider.getWorldHasVoidParticles() && !flag) { double d0 = (double)((entitylivingbase.getBrightnessForRender(p_78468_2_) & 15728640) >> 20) / 16.0D + (entitylivingbase.lastTickPosY + (entitylivingbase.posY - entitylivingbase.lastTickPosY) * (double)p_78468_2_ + 4.0D) / 32.0D; if (d0 < 1.0D) { if (d0 < 0.0D) { d0 = 0.0D; } d0 *= d0; float f2 = 100.0F * (float)d0; if (f2 < 5.0F) { f2 = 5.0F; } if (f1 > f2) { f1 = f2; } } } GL11.glFogi(GL11.GL_FOG_MODE, GL11.GL_LINEAR); if (p_78468_1_ < 0) { GL11.glFogf(GL11.GL_FOG_START, 0.0F); GL11.glFogf(GL11.GL_FOG_END, f1); } else { GL11.glFogf(GL11.GL_FOG_START, f1 * 0.75F); GL11.glFogf(GL11.GL_FOG_END, f1); } if (GLContext.getCapabilities().GL_NV_fog_distance) { GL11.glFogi(34138, 34139); } if (this.mc.theWorld.provider.doesXZShowFog((int)entitylivingbase.posX, (int)entitylivingbase.posZ)) { GL11.glFogf(GL11.GL_FOG_START, f1 * 0.05F); GL11.glFogf(GL11.GL_FOG_END, Math.min(f1, 192.0F) * 0.5F); } MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.EntityViewRenderEvent.RenderFogEvent(this, entitylivingbase, block, p_78468_2_, p_78468_1_, f1)); } GL11.glEnable(GL11.GL_COLOR_MATERIAL); GL11.glColorMaterial(GL11.GL_FRONT, GL11.GL_AMBIENT); } }:::
-
Visiblement forge a tout prévu, tu peux utiliser les event :
EntityViewRenderEvent.RenderFogEvent
EntityViewRenderEvent.FogColorsPour refaire la même chose.
-
Ah ok merci, je vais essayer de trouver les mêmes classes avec la slowness et faire mon effet
-
Salut, je n’arrive pas a reproduire l’effet blindness on peut m’aider ?
-
Envoie ton code actuel.
-
Mais en faite je ne sais pas comment adapter le code de la classe à mon utilisation …

Mon code:
@SubscribeEvent public void RenderFogEvent(EntityViewRenderEvent.RenderFogEvent event){ GL11.glFog(GL11.GL_FOG_COLOR, this.setFogColorBuffer(this.fogColorRed, this.fogColorGreen, this.fogColorBlue, 1.0F)); GL11.glNormal3f(0.0F, -1.0F, 0.0F); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); float f1; if (event.entity.isPotionActive(SomnolenceEffect.somnolenceEffectID)) { f1 = 5.0F; int j = event.entity.getActivePotionEffect(SomnolenceEffect.somnolenceEffect).getDuration(); if (j < 20) { f1 = 5.0F + (event.farPlaneDistance - 5.0F) * (1.0F - (float)j / 20.0F); } GL11.glFogi(GL11.GL_FOG_MODE, GL11.GL_LINEAR); if (event.fogMode < 0) { GL11.glFogf(GL11.GL_FOG_START, 0.0F); GL11.glFogf(GL11.GL_FOG_END, f1 * 0.8F); } else { GL11.glFogf(GL11.GL_FOG_START, f1 * 0.25F); GL11.glFogf(GL11.GL_FOG_END, f1); } if (GLContext.getCapabilities().GL_NV_fog_distance) { GL11.glFogi(34138, 34139); } } }J’arrive pas a adapter le
GL11.glFog(GL11.GL_FOG_COLOR, this.setFogColorBuffer(this.fogColorRed, this.fogColorGreen, this.fogColorBlue, 1.0F));(Tu peux deplacer ca dans le non resolu stp?)
-
Tu n’es pas très loin de la solution. En fait cette partie du code ne sert à rien. Il faut prendre seulement le code qui fait le brouillard. J’ai fait quelques tests de mon côté avec la potion de force (premier truc que j’ai trouvé). Voila ce que ça donne :
@SubscribeEvent @SideOnly(Side.CLIENT) public void onFogRender(EntityViewRenderEvent.RenderFogEvent event) { if(event.entity.isPotionActive(Potion.damageBoost.id)) { float f1 = 5.0F; int j = event.entity.getActivePotionEffect(Potion.damageBoost).getDuration(); if(j < 20) { f1 = 5.0F + (event.farPlaneDistance - 5.0F) * (1.0F - (float)j / 20.0F); } GL11.glFogi(GL11.GL_FOG_MODE, GL11.GL_LINEAR); if(event.fogMode < 0) { GL11.glFogf(GL11.GL_FOG_START, 0.0F); GL11.glFogf(GL11.GL_FOG_END, f1 * 0.8F); } else { GL11.glFogf(GL11.GL_FOG_START, f1 * 0.25F); GL11.glFogf(GL11.GL_FOG_END, f1); } if(GLContext.getCapabilities().GL_NV_fog_distance) { GL11.glFogi(34138, 34139); } } }Suffit juste de changer Potion.damageBoost par ta potion.
Par contre le brouillard sera tout blanc, donc il faut passer par un second event : @SubscribeEvent @SideOnly(Side.CLIENT) public void getFogColor(EntityViewRenderEvent.FogColors event) { if(event.entity.isPotionActive(Potion.damageBoost.id)) { double d0 = (event.entity.lastTickPosY + (event.entity.posY - event.entity.lastTickPosY) * (double)event.renderPartialTicks) * FMLClientHandler.instance().getWorldClient().provider.getVoidFogYFactor(); int i = event.entity.getActivePotionEffect(Potion.damageBoost).getDuration(); if(i < 20) { d0 *= (double)(1.0F - (float)i / 20.0F); } else { d0 = 0.0D; } if(d0 < 1.0D) { if(d0 < 0.0D) { d0 = 0.0D; } d0 *= d0; event.red = (float)((double)event.red * d0); event.green = (float)((double)event.green * d0); event.blue = (float)((double)event.blue * d0); } } }Après tu peux très bien lancer ton jeu en débug et faire mumuse avec les valeurs ^^ (genre que multiplier le rouge, ou que le bleu, etc …)
-
Ok merci, car j’avais trouvé qu’avec l’event “EntityViewRenderEvent.FogColors” ca marché mais comme on peut pas combiner 2 event ^^