[TUTORIAL] Making a flying armor 2022.x - Forge 1.18.2 - Look at the comments for updates up to 2023.x 1.20.1

Started by __SK__ on

Topic category: User side tutorials

Last seen on 03:09, 28. Mar 2024
Joined May 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
[TUTORIAL] Making a flying armor 2022.x - Forge 1.18.2 - Look at the comments for updates up to 2023.x 1.20.1
Thu, 03/21/2024 - 20:08 (edited)

I tried to make it as simple as possible, it does require to lock the code.

  1. Create your default or custom 3d armor
  2. Modify the desired settings
  3. Save
  4. Now lock the code
  5. Copy the following and paste it right before the last "}" in the code

 

    

   @Override
   public boolean canElytraFly(ItemStack stack, net.minecraft.world.entity.LivingEntity entity) {
      return true;
   }

   @Override
   public boolean elytraFlightTick(ItemStack stack, net.minecraft.world.entity.LivingEntity entity, int flightTicks) {
      if (!entity.level.isClientSide) {
         int nextFlightTick = flightTicks + 1;
         if (nextFlightTick % 10 == 0) {
            if (nextFlightTick % 20 == 0) {
               stack.hurtAndBreak(1, entity, e -> e.broadcastBreakEvent(net.minecraft.world.entity.EquipmentSlot.CHEST));
            }
            entity.gameEvent(net.minecraft.world.level.gameevent.GameEvent.ELYTRA_FREE_FALL);
         }
      }
      return true;
   }

=============SPECIAL NOTE================

    If needed set stack.hurtAndBreak from 1 (default value - breakable) to 0 (unbreakable)

=============SPECIAL NOTE================

 

Congratulations, now your armor (chestplate) will act just like an elytra ... and still have armor properties.

If you still have doubts, watch the following ...

(right click and save for future reference)

Results ...

Take off

Landing

With some creativity you could add a tick to the chestplate ... adding an additional chestplate that will switch while in air for a winged model, making it cool and more enjoyable to watch.

 

I would gladly like to see screenshots of your creations.

Have fun

Edited by __SK__ on Thu, 03/21/2024 - 20:08
Last seen on 12:25, 31. Jan 2024
Joined Jun 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Great tutorial!
Sat, 08/27/2022 - 06:32

Great tutorial!

Last seen on 03:09, 28. Mar 2024
Joined May 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Thanks.  
Sat, 08/27/2022 - 15:51

Thanks.

 

Last seen on 07:30, 24. Sep 2022
Joined Mar 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Nice
Sat, 08/27/2022 - 20:20

Nice

Last seen on 06:22, 13. Mar 2023
Joined Feb 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
You're the goat I needed…
Tue, 08/30/2022 - 22:02

You're the goat I needed this exact thing for one of my mods and just happened across it rn.

Last seen on 03:09, 28. Mar 2024
Joined May 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Thanks.
Tue, 08/30/2022 - 23:34

Thanks.

Last seen on 03:02, 13. Nov 2022
Joined Oct 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
This was SO helpful, thanks!
Sat, 10/15/2022 - 13:38

This was SO helpful, thanks!

Last seen on 14:20, 4. Jan 2024
Joined Jan 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Doesn't work, but it might…
Sat, 10/22/2022 - 22:46

Doesn't work, but it might just be because its on the most recent snapshot.

Once copied and pasted in it shows up with this.


https://imgur.com/LVVKJIy

 

Last seen on 03:09, 28. Mar 2024
Joined May 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
The code slightly changed …
Sun, 10/23/2022 - 05:20

The code slightly changed ... the following goes before the last "}" in the code. 

For MCreator EAP 2022.3 b41417 ONLY

 

   @Override
   public boolean canElytraFly(ItemStack stack, net.minecraft.world.entity.LivingEntity entity) {
      return true;
   }

   @Override
   public boolean elytraFlightTick(ItemStack stack, net.minecraft.world.entity.LivingEntity entity, int flightTicks) {
      if (!entity.level.isClientSide) {
         int nextFlightTick = flightTicks + 1;
         if (nextFlightTick % 10 == 0) {
            if (nextFlightTick % 20 == 0) {
            //=============SPECIAL NOTE================
            
// If needed set stack.hurtAndBreak from 1 (default value - breakable) to 0 (unbreakable)
            
//=============SPECIAL NOTE================
               stack.hurtAndBreak(1, entity, e -> e.broadcastBreakEvent(net.minecraft.world.entity.EquipmentSlot.CHEST));
            }
         }
      }
      return true;
   }
 
Last seen on 15:08, 18. Dec 2022
Joined Aug 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Are how do I make an elytra…
Tue, 11/22/2022 - 12:47

Are how do I make an elytra item controller the firework for example? 

Last seen on 03:09, 28. Mar 2024
Joined May 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
@Zavgar4 Never tried it, but…
Tue, 11/22/2022 - 19:11

@Zavgar4

Never tried it, but it basically will require a YourCustomRocketEntity and YourCustomRocketItem classes extending FireworkRocketEntity and FireworkRocketItem classes.

Once created go inside YourCustomRocketItem (which needs to look for the entity), now you need to add the following lines pointing to your custom rocket which Overrides the default rocket.  

   /**
    * Called to trigger the item's "innate" right click behavior. 
    * What to change?
    * Change FireworkRocketEntity to your YourCustomRocketEntity
    */
   public InteractionResultHolder<ItemStack> use(Level pLevel, Player pPlayer, InteractionHand pHand) {
   			// IF PLAYER IS FALL FLYING-ELYTRA FLYING
      if (pPlayer.isFallFlying()) {
         ItemStack itemstack = pPlayer.getItemInHand(pHand);
         if (!pLevel.isClientSide) {
         	// HOLDING FIREWORK ROCKET OR CUSTOM ROCKET
            FireworkRocketEntity fireworkrocketentity = new FireworkRocketEntity(pLevel, itemstack, pPlayer);
            pLevel.addFreshEntity(fireworkrocketentity);
            if (!pPlayer.getAbilities().instabuild) {
               itemstack.shrink(1);
            }

            pPlayer.awardStat(Stats.ITEM_USED.get(this));
         }

         return InteractionResultHolder.sidedSuccess(pPlayer.getItemInHand(pHand), pLevel.isClientSide());
      } else {
         return InteractionResultHolder.pass(pPlayer.getItemInHand(pHand));
      }
   }

 

And inside the YourCustomRocketEntity 

 


/**
* Called to update the entity's position/logic.
*/
public void tick() {
super.tick();
if (this.isAttachedToEntity()) {
if (this.attachedToEntity == null) {
this.entityData.get(DATA_ATTACHED_TO_TARGET).ifPresent((p_37067_) -> {
Entity entity = this.level.getEntity(p_37067_);
if (entity instanceof LivingEntity) {
this.attachedToEntity = (LivingEntity)entity;
}

});
}

if (this.attachedToEntity != null) {
Vec3 vec3;
if (this.attachedToEntity.isFallFlying()) {
Vec3 vec31 = this.attachedToEntity.getLookAngle();
double d0 = 1.5D;
double d1 = 0.1D;
Vec3 vec32 = this.attachedToEntity.getDeltaMovement();
this.attachedToEntity.setDeltaMovement(vec32.add(vec31.x * 0.1D + (vec31.x * 1.5D - vec32.x) * 0.5D, vec31.y * 0.1D + (vec31.y * 1.5D - vec32.y) * 0.5D, vec31.z * 0.1D + (vec31.z * 1.5D - vec32.z) * 0.5D));
vec3 = this.attachedToEntity.getHandHoldingItemAngle(Items.FIREWORK_ROCKET);
} else {
vec3 = Vec3.ZERO;
}

this.setPos(this.attachedToEntity.getX() + vec3.x, this.attachedToEntity.getY() + vec3.y, this.attachedToEntity.getZ() + vec3.z);
this.setDeltaMovement(this.attachedToEntity.getDeltaMovement());
}
} else {
if (!this.isShotAtAngle()) {
double d2 = this.horizontalCollision ? 1.0D : 1.15D;
this.setDeltaMovement(this.getDeltaMovement().multiply(d2, 1.0D, d2).add(0.0D, 0.04D, 0.0D));
}

Vec3 vec33 = this.getDeltaMovement();
this.move(MoverType.SELF, vec33);
this.setDeltaMovement(vec33);
}

HitResult hitresult = ProjectileUtil.getHitResult(this, this::canHitEntity);
if (!this.noPhysics) {
this.onHit(hitresult);
this.hasImpulse = true;
}

this.updateRotation();
if (this.life == 0 && !this.isSilent()) {
this.level.playSound((Player)null, this.getX(), this.getY(), this.getZ(), SoundEvents.FIREWORK_ROCKET_LAUNCH, SoundSource.AMBIENT, 3.0F, 1.0F);
}

++this.life;
if (this.level.isClientSide && this.life % 2 < 2) {
this.level.addParticle(ParticleTypes.FIREWORK, this.getX(), this.getY(), this.getZ(), this.random.nextGaussian() * 0.05D, -this.getDeltaMovement().y * 0.5D, this.random.nextGaussian() * 0.05D);
}

if (!this.level.isClientSide && this.life > this.lifetime) {
this.explode();
}

}

The code requires a lot more, but these parts are needed for the fall flying/elytra flying. I am using IntelliJ to modify the code. It is possible, but complicated.

Last seen on 15:08, 18. Dec 2022
Joined Aug 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Are how I make a elytra…
Wed, 11/23/2022 - 07:54

Are how I make a elytra acceleration item for elytra example:firework

Last seen on 15:08, 18. Dec 2022
Joined Aug 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Thanks! But where I found…
Thu, 11/24/2022 - 07:58

Thanks! But where I found the model for vannila elytra? 

Last seen on 15:08, 18. Dec 2022
Joined Aug 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
And where I write this code?…
Thu, 11/24/2022 - 08:04

And where I write this code? Inside elytra item are make new item and entity and write this code?