# [1.7]Is there a way to make my own elytra with the code I have?

## Recommended Posts

As in the title... I want to make my own elytra. I found some code online for simulating the elytra but I don't know where to put it so it will work.

Here is the code I found for simulating the elytra:

```/**
* An accurate simulation of the elytra item as of Minecraft 15w41b
*/
public class ElytraModel
{
public int glideTime;
public int damageTaken;

public double posX;
public double posY;
public double posZ;

public double velX;
public double velY;
public double velZ;

/**
* Simulates a Minecraft tick (20 per second).
* The pitch and yaw are the look direction of the player.
*/
public void tick(boolean isCreative, double yaw, double pitch)
{
if (!isCreative && (this.glideTime + 1) % 20 == 0)
{
this.damageTaken++;
}

//I did some simplifing of the folowing to reduce the number of negatives and trig functions
double yawcos = Math.cos(-yaw - Math.PI);
double yawsin = Math.sin(-yaw - Math.PI);
double pitchcos = Math.cos(pitch);
double pitchsin = Math.sin(pitch);

double lookX = yawsin * -pitchcos;
double lookY = -pitchsin;
double lookZ = yawcos * -pitchcos;

double hvel = Math.sqrt(velX * velX + velZ * velZ);
double hlook = pitchcos; //Math.sqrt(lookX * lookX + lookZ * lookZ)
double sqrpitchcos = pitchcos * pitchcos; //In MC this is multiplied by Math.min(1.0, Math.sqrt(lookX * lookX + lookY * lookY + lookZ * lookZ) / 0.4), don't ask me why, it should always =1

//From here on, the code is identical to the code found in net.minecraft.entity.EntityLivingBase.moveEntityWithHeading(float, float) or rq.g(float, float) in obfuscated 15w41b
this.velY += -0.08 + sqrpitchcos * 0.06;

if (this.velY < 0 && hlook > 0)
{
double yacc = this.velY * -0.1 * sqrpitchcos;
this.velY += yacc;
this.velX += lookX * yacc / hlook;
this.velZ += lookZ * yacc / hlook;
}
if (pitch < 0)
{
double yacc = hvel * -pitchsin * 0.04;
this.velY += yacc * 3.5;
this.velX -= lookX * yacc / hlook;
this.velZ -= lookZ * yacc / hlook;
}
if (hlook > 0)
{
this.velX += (lookX / hlook * hvel - this.velX) * 0.1;
this.velZ += (lookZ / hlook * hvel - this.velZ) * 0.1;
}

this.velX *= 0.99;
this.velY *= 0.98;
this.velZ *= 0.99;

this.posX += this.velX;
this.posY += this.velY;
this.posZ += this.velZ;

this.glideTime++;
}

/**
* Checks if the player is currently in a gliding state.
* As you can see, if the player is in creative, they will remain gliding even if on the ground. They will stop gliding once they move (but that functionality is not shown here).
*/
public boolean isGliding(boolean isCreative, boolean isOnGround, float fallDistance)
{
if (isCreative)
{
return glideTime > 0;
}
else
{
return !isOnGround && fallDistance >= 1.0f;
}
}
}```

And then I have a model for it(Not my model... Just a model found in forge 1.9):

```package com.cubic_control.Models;

import com.sun.javafx.geom.Vec3d;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.entity.AbstractClientPlayer;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelBiped;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;

@SideOnly(Side.CLIENT)
public class ModelElytra extends ModelBiped
{
private ModelRenderer field_187060_a;
private ModelRenderer field_187061_b = new ModelRenderer(this, 22, 0);

public ModelElytra()
{
this.field_187061_b.addBox(-10.0F, 0.0F, 0.0F, 10, 20, 2, 1.0F);
this.field_187060_a = new ModelRenderer(this, 22, 0);
this.field_187060_a.mirror = true;
this.field_187060_a.addBox(0.0F, 0.0F, 0.0F, 10, 20, 2, 1.0F);
}

/**
* Sets the models various rotation angles then renders the model.
*/
public void render(Entity entityIn, float p_78088_2_, float limbSwing, float ageInTicks, float netHeadYaw, float headPitch, float scale)
{
this.field_187061_b.render(scale);
this.field_187060_a.render(scale);
}

/**
* Sets the model's various rotation angles. For bipeds, par1 and par2 are used for animating the movement of arms
* and legs, where par1 represents the time(so that arms and legs swing back and forth) and par2 represents how
* "far" arms and legs can swing at most.
*/
public void setRotationAngles(float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn)
{
float f = 0.2617994F;
float f1 = -0.2617994F;
float f2 = 0.0F;
float f3 = 0.0F;

if (entityIn.isSneaking())
{
f = ((float)Math.PI * 2F / 9F);
f1 = -((float)Math.PI / 4F);
f2 = 3.0F;
f3 = 0.08726646F;
}

this.field_187061_b.rotationPointX = 5.0F;
this.field_187061_b.rotationPointY = f2;

if (entityIn instanceof AbstractClientPlayer)
{
AbstractClientPlayer abstractclientplayer = (AbstractClientPlayer)entityIn;
}
else
{
this.field_187061_b.rotateAngleX = f;
this.field_187061_b.rotateAngleZ = f1;
this.field_187061_b.rotateAngleY = f3;
}

this.field_187060_a.rotationPointX = -this.field_187061_b.rotationPointX;
this.field_187060_a.rotateAngleY = -this.field_187061_b.rotateAngleY;
this.field_187060_a.rotationPointY = this.field_187061_b.rotationPointY;
this.field_187060_a.rotateAngleX = this.field_187061_b.rotateAngleX;
this.field_187060_a.rotateAngleZ = -this.field_187061_b.rotateAngleZ;
}

/**
* Used for easily adding entity-dependent animations. The second and third float params here are the same second
* and third as in the setRotationAngles method.
*/
public void setLivingAnimations(EntityLivingBase entitylivingbaseIn, float p_78086_2_, float p_78086_3_, float partialTickTime)
{
super.setLivingAnimations(entitylivingbaseIn, p_78086_2_, p_78086_3_, partialTickTime);
}
}```

Here is my Item class for the elytra:

```public class Ender_rite_elytra extends ItemArmor {

@SideOnly(Side.CLIENT)
private IIcon broken;

public Ender_rite_elytra() {
super(EnumHelper.addArmorMaterial("elytra", 27, new int[] { 0, 9, 0, 0 }, 0), 0, 1);
setMaxDamage(432);
setMaxStackSize(1);
setTextureName(RefStrings.MODID + ":Ender-rite_elytra");
setUnlocalizedName("Ender_rite_elytra");
setCreativeTab(MCreativeTabs.tabItems);
}
@Override
public boolean getIsRepairable(ItemStack stack, ItemStack material) {
return ArmorMaterial.CLOTH.func_151685_b() == material.getItem();
}

@Override
public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) {
return RefStrings.MODID + ":textures/mobs/elytra/Ender-rite_elytra.png";
}

@Override
@SideOnly(Side.CLIENT)
public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, int armorSlot) {
return new ModelElytra();
}

@Override
@SideOnly(Side.CLIENT)
public IIcon getIconFromDamage(int meta) {
return meta >= getMaxDamage() ? broken : super.getIconFromDamage(meta);
}

@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister reg) {
super.registerIcons(reg);
broken = reg.registerIcon(RefStrings.MODID + ":Ender-rite_elytra_broken");
}
}
```

I would just like to know how I could use this to make a working elytra... any help?

EDIT: Changed the ModelElytra to the one found in forge 1.9, still doesn't work.

##### Share on other sites

You need a way to make the player fly.  Probably by doing something every tick while the armor is worn.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

DO NOT PM ME WITH PROBLEMS. No help will be given.

##### Share on other sites

You need a way to make the player fly.  Probably by doing something every tick while the armor is worn.

That might be the case... I added this to my item code:

```@Override
public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack)
{

}```

Now I just need to figure out what to put in the {}, any thoughts?

##### Share on other sites

Perhaps the code in tick() in ElytraModel

If I helped please press the Thank You button.

Check out my mods at http://www.curse.com/users/The_Fireplace/projects

##### Share on other sites

Perhaps the code in tick() in ElytraModel

I put the code in but still nothing...

heres the code just in case:

```public void onArmorTick(boolean isCreative, double yaw, double pitch)
{
if (!isCreative && (ElytraModel.glideTime + 1) % 20 == 0)
{
ElytraModel.damageTaken++;
}

//I did some simplifing of the folowing to reduce the number of negatives and trig functions
double yawcos = Math.cos(-yaw - Math.PI);
double yawsin = Math.sin(-yaw - Math.PI);
double pitchcos = Math.cos(pitch);
double pitchsin = Math.sin(pitch);

double lookX = yawsin * -pitchcos;
double lookY = -pitchsin;
double lookZ = yawcos * -pitchcos;

double hvel = Math.sqrt(ElytraModel.velX * ElytraModel.velX + ElytraModel.velZ * ElytraModel.velZ);
double hlook = pitchcos; //Math.sqrt(lookX * lookX + lookZ * lookZ)
double sqrpitchcos = pitchcos * pitchcos; //In MC this is multiplied by Math.min(1.0, Math.sqrt(lookX * lookX + lookY * lookY + lookZ * lookZ) / 0.4), don't ask me why, it should always =1

//From here on, the code is identical to the code found in net.minecraft.entity.EntityLivingBase.moveEntityWithHeading(float, float) or rq.g(float, float) in obfuscated 15w41b
ElytraModel.velY += -0.08 + sqrpitchcos * 0.06;

if (ElytraModel.velY < 0 && hlook > 0)
{
double yacc = ElytraModel.velY * -0.1 * sqrpitchcos;
ElytraModel.velY += yacc;
ElytraModel.velX += lookX * yacc / hlook;
ElytraModel.velZ += lookZ * yacc / hlook;
}
if (pitch < 0)
{
double yacc = hvel * -pitchsin * 0.04;
ElytraModel.velY += yacc * 3.5;
ElytraModel.velX -= lookX * yacc / hlook;
ElytraModel.velZ -= lookZ * yacc / hlook;
}
if (hlook > 0)
{
ElytraModel.velX += (lookX / hlook * hvel - ElytraModel.velX) * 0.1;
ElytraModel.velZ += (lookZ / hlook * hvel - ElytraModel.velZ) * 0.1;
}

ElytraModel.velX *= 0.99;
ElytraModel.velY *= 0.98;
ElytraModel.velZ *= 0.99;

ElytraModel.posX += ElytraModel.velX;
ElytraModel.posY += ElytraModel.velY;
ElytraModel.posZ += ElytraModel.velZ;

ElytraModel.glideTime++;
}```

## 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.

Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.

×   Pasted as rich text.   Restore formatting

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

• ### Posts

• Remove Oculus from your server
• Crashed minecraft in server, help pls https://drive.google.com/file/d/1xC0s7Si3FDOYBGLzsIWbtoNcTzdxurY7/view?usp=sharing
• I have noticed recently that in the tags, beginner, intermediate and advanced are all missing. Is there a reason for this?
• Could some fixed code be given for the item? I am still not sure what to do regarding the weapon.  (Sorry if it is a bit much to ask for).
• The Minecraft Launcher refuses to open. I click the icon on my taskbar, nothing loads. I have used Task Manager and the launcher is running, but the window just won't open. Does anyone have any suggestions on how to fix it?  NOTE: The legacy launcher works completely fine, it is just the "new" launcher that has an issue.

• ### Who's Online (See full list)

×

• #### Activity

×
• Create New...