- 55
- 1
- 1
Привет, возникла проблема с OBJ бронёй, делал по гайду Тимахи. Но проблема в том, что когда игрок приседает, то есть нажимает на shift, то модель не реагирует. Код
Пытался сделать проверку на шифт, и двигать вниз, но возникала другая проблема.
Вот смещается, когда сидишь.
ArmorGasMaskModel:
@SideOnly(Side.CLIENT)
public class ArmorGasMaskModel extends ArmorCustomModel {
public static final IModelCustom model = AdvancedModelLoader.loadModel(new ResourceLocation(Info.modid, "model/obj/armor/gasmask.obj"));
public static final ResourceLocation texture = new ResourceLocation(Info.modid, "textures/obj/armor/gasmask.png");
private final int partType;
public ArmorGasMaskModel(int armorType) {
partType = armorType;
}
@Override
public void pre() {
}
@Override
public void post() {
}
@Override
public void partHead() {
if (partType == 0) {
GL11.glPushMatrix();
GL11.glTranslatef(0F, -1.745F, 0F);
GL11.glScalef(0.55f,0.55f,0.55f);
Minecraft.getMinecraft().renderEngine.bindTexture(texture);
model.renderPart("head");
GL11.glPopMatrix();
GL11.glPushMatrix();
GL11.glDepthMask(false);
GL11.glTranslatef(0F, -1.745F, 0F);
GL11.glScalef(0.55f,0.55f,0.55f);
Minecraft.getMinecraft().renderEngine.bindTexture(texture);
model.renderPart("screen");
GL11.glPopMatrix();
}
}
@Override
public void partBody() {
}
@Override
public void partRightArm() {
}
@Override
public void partLeftArm() {
}
@Override
public void partRightLeg() {
}
@Override
public void partLeftLeg() {
}
}
ArmorCustomModel:
@SideOnly(Side.CLIENT)
public abstract class ArmorCustomModel extends ModelBiped {
public int color = -1;//Раскраска брони в цвет.
public abstract void pre();//До всех частей.
public abstract void post();//После всех частей.
public abstract void partHead();//Часть: Голова.
public abstract void partBody();//Часть: Тело.
public abstract void partRightArm();//Часть: Правая рука.
public abstract void partLeftArm();//Часть: Левая рука.
public abstract void partRightLeg();//Часть: Правая нога.
public abstract void partLeftLeg();//Часть: Левая нога.
public void render(Entity entity, float x, float y, float z, float yaw, float pitch, float parTicks) {
super.render(entity, x, y, z, yaw, pitch, parTicks);
GL11.glPushMatrix();
if (color != -1) {
float red = (float)(color >> 16 & 255) / 255F;
float blue = (float)(color >> 8 & 255) / 255F;
float green = (float)(color & 255) / 255F;
GL11.glColor3f(red, blue, green);
}
pre();
float f6 = 2.0F;
{//partHead
GL11.glPushMatrix();
if (isChild) {
GL11.glScalef(1.5F / f6, 1.5F / f6, 1.5F / f6);
GL11.glTranslatef(0.0F, 16.0F * parTicks, 0.0F);
}
GL11.glTranslatef(bipedHead.rotationPointX * parTicks, bipedHead.rotationPointY * parTicks, bipedHead.rotationPointZ * parTicks);
GL11.glRotatef(bipedHead.rotateAngleZ * (180F / (float)Math.PI), 0F, 0F, 1F);
GL11.glRotatef(bipedHead.rotateAngleY * (180F / (float)Math.PI), 0F, 1F, 0F);
GL11.glRotatef(bipedHead.rotateAngleX * (180F / (float)Math.PI), 1F, 0F, 0F);
GL11.glRotatef(180F, 1F, 0F, 0F);
partHead();
GL11.glPopMatrix();
}
if (isChild) {
GL11.glPushMatrix();
GL11.glScalef(1.0F / f6, 1.0F / f6, 1.0F / f6);
GL11.glTranslatef(0.0F, 24.0F * parTicks, 0.0F);
}
{//partBody
GL11.glPushMatrix();
GL11.glTranslatef(bipedBody.rotationPointX * parTicks, bipedBody.rotationPointY * parTicks, bipedBody.rotationPointZ * parTicks);
GL11.glRotatef(bipedBody.rotateAngleZ * (180F / (float)Math.PI), 0F, 0F, 1F);
GL11.glRotatef(bipedBody.rotateAngleY * (180F / (float)Math.PI), 0F, 1F, 0F);
GL11.glRotatef(bipedBody.rotateAngleX * (180F / (float)Math.PI), 1F, 0F, 0F);
GL11.glRotatef(180F, 1F, 0F, 0F);
partBody();
GL11.glPopMatrix();
}
{//partRightArm
GL11.glPushMatrix();
GL11.glTranslatef(bipedRightArm.rotationPointX * parTicks, bipedRightArm.rotationPointY * parTicks, bipedRightArm.rotationPointZ * parTicks);
GL11.glRotatef(bipedRightArm.rotateAngleZ * (180F / (float)Math.PI), 0F, 0F, 1F);
GL11.glRotatef(bipedRightArm.rotateAngleY * (180F / (float)Math.PI), 0F, 1F, 0F);
GL11.glRotatef(bipedRightArm.rotateAngleX * (180F / (float)Math.PI), 1F, 0F, 0F);
GL11.glRotatef(180F, 1F, 0F, 0F);
partRightArm();
GL11.glPopMatrix();
}
{//partLeftArm
GL11.glPushMatrix();
GL11.glTranslatef(bipedLeftArm.rotationPointX * parTicks, bipedLeftArm.rotationPointY * parTicks, bipedLeftArm.rotationPointZ * parTicks);
GL11.glRotatef(bipedLeftArm.rotateAngleZ * (180F / (float)Math.PI), 0F, 0F, 1F);
GL11.glRotatef(bipedLeftArm.rotateAngleY * (180F / (float)Math.PI), 0F, 1F, 0F);
GL11.glRotatef(bipedLeftArm.rotateAngleX * (180F / (float)Math.PI), 1F, 0F, 0F);
GL11.glRotatef(180F, 1F, 0F, 0F);
partLeftArm();
GL11.glPopMatrix();
}
{//partRightLeg
GL11.glPushMatrix();
GL11.glTranslatef(bipedRightLeg.rotationPointX * parTicks, bipedRightLeg.rotationPointY * parTicks, bipedRightLeg.rotationPointZ * parTicks);
GL11.glRotatef(bipedRightLeg.rotateAngleZ * (180F / (float)Math.PI), 0F, 0F, 1F);
GL11.glRotatef(bipedRightLeg.rotateAngleY * (180F / (float)Math.PI), 0F, 1F, 0F);
GL11.glRotatef(bipedRightLeg.rotateAngleX * (180F / (float)Math.PI), 1F, 0F, 0F);
GL11.glRotatef(180F, 1F, 0F, 0F);
partRightLeg();
GL11.glPopMatrix();
}
{//partLeftLeg
GL11.glPushMatrix();
GL11.glTranslatef(bipedLeftLeg.rotationPointX * parTicks, bipedLeftLeg.rotationPointY * parTicks, bipedLeftLeg.rotationPointZ * parTicks);
GL11.glRotatef(bipedLeftLeg.rotateAngleZ * (180F / (float)Math.PI), 0F, 0F, 1F);
GL11.glRotatef(bipedLeftLeg.rotateAngleY * (180F / (float)Math.PI), 0F, 1F, 0F);
GL11.glRotatef(bipedLeftLeg.rotateAngleX * (180F / (float)Math.PI), 1F, 0F, 0F);
GL11.glRotatef(180F, 1F, 0F, 0F);
partLeftLeg();
GL11.glPopMatrix();
}
if (isChild) {
GL11.glPopMatrix();
}
post();
GL11.glColor3f(1F, 1F, 1F);
GL11.glPopMatrix();
}
}
ArmorGasMaskModel:
@Override
public void partHead() {
if (partType == 0) {
if(!isSneak)
{
GL11.glPushMatrix();
GL11.glTranslatef(0F, -1.745F, 0F);
GL11.glScalef(0.55f,0.55f,0.55f);
Minecraft.getMinecraft().renderEngine.bindTexture(texture);
model.renderPart("head");
GL11.glPopMatrix();
GL11.glPushMatrix();
GL11.glDepthMask(false);
GL11.glTranslatef(0F, -1.745F, 0F);
GL11.glScalef(0.55f,0.55f,0.55f);
Minecraft.getMinecraft().renderEngine.bindTexture(texture);
model.renderPart("screen");
GL11.glPopMatrix();
}
else
{
GL11.glPushMatrix();
GL11.glTranslatef(0F, -1.945F, 0F);
GL11.glScalef(0.55f,0.55f,0.55f);
Minecraft.getMinecraft().renderEngine.bindTexture(texture);
model.renderPart("head");
GL11.glPopMatrix();
GL11.glPushMatrix();
GL11.glDepthMask(false);
GL11.glTranslatef(0F, -1.945F, 0F);
GL11.glScalef(0.55f,0.55f,0.55f);
Minecraft.getMinecraft().renderEngine.bindTexture(texture);
model.renderPart("screen");
GL11.glPopMatrix();
}
}
}