- 47
- 0
[1.7.2] Нужна помощь по блоку с моделью
Есть поворот модели. Но при пере заходе на карту поворот убирается. как сохранить его.
Есть поворот модели. Но при пере заходе на карту поворот убирается. как сохранить его.
Код:
package render;
import model.ModelMinersLampa;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.entity.Entity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import org.lwjgl.opengl.GL11;
public class RenderMinersLampa extends TileEntitySpecialRenderer {
//The model of your block
private final ModelMinersLampa model;
public RenderMinersLampa() {
model = new ModelMinersLampa();
}
@Override
public void renderTileEntityAt(TileEntity te, double x, double y, double z, float scale) {
EntityMinersLampa myTile = (EntityMinersLampa) te;
int direction = myTile.direction;
//The PushMatrix tells the renderer to "start" doing something.
GL11.glPushMatrix();
//This is setting the initial location.
GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F);
GL11.glRotatef(180, 0F, 0F, 1F);
GL11.glRotatef(direction * 90, 0F, 1F, 0F);
ResourceLocation textures = new ResourceLocation("minecrftgases", "textures/entity/minerslamp.png");
Minecraft.getMinecraft().renderEngine.bindTexture(textures);
//This rotation part is very important! Without it, your model will render upside-down! And for some reason you DO need PushMatrix again!
GL11.glPushMatrix();
//A reference to your Model file. Again, very important.
model.render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
//Tell it to stop rendering for both the PushMatrix's
GL11.glPopMatrix();
GL11.glPopMatrix();
}
//Set the lighting stuff, so it changes it's brightness properly.
private void adjustLightFixture(World world, int i, int j, int k, Block block) {
Tessellator tess = Tessellator.instance;
float brightness = block.getBlockHardness(world, i, j, k);
int skyLight = world.getLightBrightnessForSkyBlocks(i, j, k, 0);
int modulousModifier = skyLight % 65536;
int divModifier = skyLight / 65536;
tess.setColorOpaque_F(brightness, brightness, brightness);
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float) modulousModifier, divModifier);
}
}