- 4,045
- 63
- 645
В общем, есть сей код, пока что скопированный с ванили:
Однако игра крашит на моменте запуска и именно в тех местах, где я обращаюсь к объявленным выше переменным: mc, theWorld и renderEngine.
Что я делаю не так и как их объявить правильно?
Всё работает, если в эвент пишу это:
Но ванильные облака мне не нужны.
Спасибо за ответ )
Код:
private Minecraft mc = Minecraft.getMinecraft();
private final TextureManager renderEngine = mc.getTextureManager();
private WorldClient theWorld = mc.theWorld;
private static final ResourceLocation locationCloudsPng = new ResourceLocation("textures/environment/clouds.png");
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void renderEvent(RenderWorldLastEvent e) {
float p_72718_1_ = e.partialTicks;
IRenderHandler renderer = null;
if ((renderer = theWorld.provider.getCloudRenderer()) != null) //тут вылет
{
renderer.render(p_72718_1_, theWorld, mc);
return;
}
if (this.mc.theWorld.provider.isSurfaceWorld()) //или тут вылет
{
if (false)
{
//this.renderCloudsFancy(p_72718_1_);
}
else
{
GL11.glDisable(GL11.GL_CULL_FACE);
float f1 = (float)(this.mc.renderViewEntity.lastTickPosY + (this.mc.renderViewEntity.posY - this.mc.renderViewEntity.lastTickPosY) * (double)p_72718_1_);
byte b0 = 32;
int i = 256 / b0;
Tessellator tessellator = Tessellator.instance;
this.renderEngine.bindTexture(locationCloudsPng); //или даже тут вылет
GL11.glEnable(GL11.GL_BLEND);
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
Vec3 vec3 = this.theWorld.getCloudColour(p_72718_1_);
float f2 = (float)vec3.xCoord;
float f3 = (float)vec3.yCoord;
float f4 = (float)vec3.zCoord;
float f5;
if (this.mc.gameSettings.anaglyph)
{
f5 = (f2 * 30.0F + f3 * 59.0F + f4 * 11.0F) / 100.0F;
float f6 = (f2 * 30.0F + f3 * 70.0F) / 100.0F;
float f7 = (f2 * 30.0F + f4 * 70.0F) / 100.0F;
f2 = f5;
f3 = f6;
f4 = f7;
}
f5 = 4.8828125E-4F;
double d2 = (double)((float)/*this.cloudTickCounter*/50 + p_72718_1_);
double d0 = this.mc.renderViewEntity.prevPosX + (this.mc.renderViewEntity.posX - this.mc.renderViewEntity.prevPosX) * (double)p_72718_1_ + d2 * 0.029999999329447746D;
double d1 = this.mc.renderViewEntity.prevPosZ + (this.mc.renderViewEntity.posZ - this.mc.renderViewEntity.prevPosZ) * (double)p_72718_1_;
int j = MathHelper.floor_double(d0 / 2048.0D);
int k = MathHelper.floor_double(d1 / 2048.0D);
d0 -= (double)(j * 2048);
d1 -= (double)(k * 2048);
float f8 = this.theWorld.provider.getCloudHeight() - f1 + 0.33F;
float f9 = (float)(d0 * (double)f5);
float f10 = (float)(d1 * (double)f5);
tessellator.startDrawingQuads();
tessellator.setColorRGBA_F(f2, f3, f4, 0.8F);
for (int l = -b0 * i; l < b0 * i; l += b0)
{
for (int i1 = -b0 * i; i1 < b0 * i; i1 += b0)
{
tessellator.addVertexWithUV((double)(l + 0), (double)f8, (double)(i1 + b0), (double)((float)(l + 0) * f5 + f9), (double)((float)(i1 + b0) * f5 + f10));
tessellator.addVertexWithUV((double)(l + b0), (double)f8, (double)(i1 + b0), (double)((float)(l + b0) * f5 + f9), (double)((float)(i1 + b0) * f5 + f10));
tessellator.addVertexWithUV((double)(l + b0), (double)f8, (double)(i1 + 0), (double)((float)(l + b0) * f5 + f9), (double)((float)(i1 + 0) * f5 + f10));
tessellator.addVertexWithUV((double)(l + 0), (double)f8, (double)(i1 + 0), (double)((float)(l + 0) * f5 + f9), (double)((float)(i1 + 0) * f5 + f10));
}
}
tessellator.draw();
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glDisable(GL11.GL_BLEND);
GL11.glEnable(GL11.GL_CULL_FACE);
}
}
Однако игра крашит на моменте запуска и именно в тех местах, где я обращаюсь к объявленным выше переменным: mc, theWorld и renderEngine.
Что я делаю не так и как их объявить правильно?
Всё работает, если в эвент пишу это:
Код:
e.context.renderClouds(e.partialTicks);
Но ванильные облака мне не нужны.
Спасибо за ответ )