Jump to content

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


cubic_control

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)
    {
        super.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scaleFactor, 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.

Link to comment
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.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

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

Link to comment
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?

Link to comment
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++;
    }

Link to comment
Share on other sites

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.

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

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

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

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • For crash 1, set max-tick-time to -1 in your server.properties Crash 2 shows a conflict or incompatibility between LuckPerms and the mod boh-0.0.6.1-forge-1.20.1_2.jar
    • Add the crash-report or latest.log (logs-folder) with sites like https://mclo.gs/ and paste the link to it here  
    • so my minecraft crashes when opening my world, i played without any troubles for about 5 days and today it started tweaking.. pls help me
    • Hi guys! I am having some issues with the server crashing over and over and I was hoping to get some guidance.  Thanks in advance! Crash 1: java.lang.Error: ServerHangWatchdog detected that a single server tick took 60.00 seconds (should be max 0.05)     at net.minecraft.server.dedicated.ServerWatchdog.run(ServerWatchdog.java:43) ~[server-1.20.1-20230612.114412-srg.jar%23217!/:?] {re:classloading}     at java.lang.Thread.run(Thread.java:840) ~[?:?] { Crash 2: java.lang.IllegalStateException: Capability missing for eeb7f026-34b4-42f5-9164-e7736461df83     at me.lucko.luckperms.forge.capabilities.UserCapabilityImpl.lambda$get$0(UserCapabilityImpl.java:66) ~[?:?] {re:classloading,re:classloading,re:classloading}     at net.minecraftforge.common.util.LazyOptional.orElseThrow(LazyOptional.java:261) ~[forge-1.20.1-47.3.10-universal.jar%23222!/:?] {re:mixin,re:classloading}     at me.lucko.luckperms.forge.capabilities.UserCapabilityImpl.get(UserCapabilityImpl.java:66) ~[?:?] {re:classloading,re:classloading,re:classloading}     at me.lucko.luckperms.forge.util.BrigadierInjector$InjectedPermissionRequirement.test(BrigadierInjector.java:143) ~[?:?] {}     at me.lucko.luckperms.forge.util.BrigadierInjector$InjectedPermissionRequirement.test(BrigadierInjector.java:129) ~[?:?] {}     at com.mojang.brigadier.tree.CommandNode.canUse(CommandNode.java:65) ~[brigadier-1.1.8.jar%2376!/:?] {}     at com.mojang.brigadier.CommandDispatcher.parseNodes(CommandDispatcher.java:359) ~[brigadier-1.1.8.jar%2376!/:?] {}     at com.mojang.brigadier.CommandDispatcher.parse(CommandDispatcher.java:349) ~[brigadier-1.1.8.jar%2376!/:?] {}     at com.mojang.brigadier.CommandDispatcher.parse(CommandDispatcher.java:317) ~[brigadier-1.1.8.jar%2376!/:?] {}     at net.minecraft.commands.Commands.m_230957_(Commands.java:237) ~[server-1.20.1-20230612.114412-srg.jar%23217!/:?] {re:classloading}     at net.mcreator.boh.procedures.TeleportbenProcedure.lambda$execute$2(TeleportbenProcedure.java:65) ~[boh-0.0.6.1-forge-1.20.1_2.jar%23165!/:?] {re:classloading}     at net.mcreator.boh.BohMod.lambda$tick$2(BohMod.java:96) ~[boh-0.0.6.1-forge-1.20.1_2.jar%23165!/:?] {re:classloading}     at java.util.ArrayList.forEach(ArrayList.java:1511) ~[?:?] {re:mixin}     at net.mcreator.boh.BohMod.tick(BohMod.java:96) ~[boh-0.0.6.1-forge-1.20.1_2.jar%23165!/:?] {re:classloading}     at net.mcreator.boh.__BohMod_tick_ServerTickEvent.invoke(.dynamic) ~[boh-0.0.6.1-forge-1.20.1_2.jar%23165!/:?] {re:classloading,pl:eventbus:B}     at net.minecraftforge.eventbus.ASMEventHandler.invoke(ASMEventHandler.java:73) ~[eventbus-6.0.5.jar%2352!/:?] {}     at net.minecraftforge.eventbus.EventBus.post(EventBus.java:315) ~[eventbus-6.0.5.jar%2352!/:?] {}     at net.minecraftforge.eventbus.EventBus.post(EventBus.java:296) ~[eventbus-6.0.5.jar%2352!/:?] {}     at net.minecraftforge.event.ForgeEventFactory.onPostServerTick(ForgeEventFactory.java:950) ~[forge-1.20.1-47.3.10-universal.jar%23222!/:?] {re:classloading}     at net.minecraft.server.MinecraftServer.m_5705_(MinecraftServer.java:835) ~[server-1.20.1-20230612.114412-srg.jar%23217!/:?] {re:mixin,pl:accesstransformer:B,xf:fml:xaerominimap:xaero_minecraftserver,re:classloading,pl:accesstransformer:B,xf:fml:xaerominimap:xaero_minecraftserver,pl:mixin:A}     at net.minecraft.server.MinecraftServer.m_130011_(MinecraftServer.java:661) ~[server-1.20.1-20230612.114412-srg.jar%23217!/:?] {re:mixin,pl:accesstransformer:B,xf:fml:xaerominimap:xaero_minecraftserver,re:classloading,pl:accesstransformer:B,xf:fml:xaerominimap:xaero_minecraftserver,pl:mixin:A}     at net.minecraft.server.MinecraftServer.m_206580_(MinecraftServer.java:251) ~[server-1.20.1-20230612.114412-srg.jar%23217!/:?] {re:mixin,pl:accesstransformer:B,xf:fml:xaerominimap:xaero_minecraftserver,re:classloading,pl:accesstransformer:B,xf:fml:xaerominimap:xaero_minecraftserver,pl:mixin:A}     at java.lang.Thread.run(Thread.java:840) ~[?:?] {}
    • Hello there! I am trying to make custom dimensions for a modpack I am making in an older minecraft version, 1.16.5. I like that version and it has a few other mods that have not been updated that I would still like to use. Anyway, I am having a terrible time with getting my dimension to work and have tried using code from other peoples projects to at least figure out what I'm supposed to be doing but it has not been as helpful as I would have liked. If anyone could help that would be greatly appreciated! Here is my github with all the code as I am using it: https://github.com/BladeColdsteel/InvigoratedDimensionsMod I have also included the last log, https://pastebin.com/zX9vsDSq, I had when I tried to load up a world, let me know if there is anything else I should send though, thank you!
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.