Skip to content

Commit

Permalink
Fix flight (#34)
Browse files Browse the repository at this point in the history
* Fix flight
This line disables flight every time if a player is not wearing 2 armor witch air aspect. Other things that add flight don't work correctly and always bugging out.

* Fix flight
 1.If you are not wearing 2 air aspect armor, the armor disables all flying.
 2. If you remove the armor with air aspect while in flight, flying does not stop.

* spotlessApply

* replace "equals()" to "=="
  • Loading branch information
Zereff06 authored Dec 28, 2022
1 parent 7676a62 commit 6e59c60
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ buildscript {
}
maven {
// GTNH ForgeGradle and ASM Fork

name = "GTNH Maven"
url = "http://jenkins.usrv.eu:8081/nexus/content/groups/public/"
}
Expand All @@ -46,6 +47,7 @@ buildscript {
}
dependencies {
//Overwrite the current ASM version to fix shading newer than java 8 applicatations.

classpath 'org.ow2.asm:asm-debug-all-custom:5.0.3'
classpath 'net.minecraftforge.gradle:ForgeGradle:1.2.13'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,22 @@
import witchinggadgets.common.WGContent;
import witchinggadgets.common.items.tools.IPrimordialGear;

enum FlightStatus {
ON,
OFF
}

public class ItemPrimordialArmor extends ItemShadowFortressArmor
implements IActiveAbility, IPrimordialCrafting, IEventGear, IPrimordialGear, IRunicArmor {
IIcon rune;
byte tickcounter = 0;

private FlightStatus flightStatus;

public ItemPrimordialArmor(ArmorMaterial mat, int idx, int type) {
super(mat, idx, type);
this.setCreativeTab(WitchingGadgets.tabWG);
flightStatus = FlightStatus.OFF;
}

@Override
Expand Down Expand Up @@ -109,9 +117,6 @@ public void onLivingUpdateEvent(LivingUpdateEvent event) {

for (int i : modes) if (i == 1) ++modescounter;

if (amorcounter >= 2 && modescounter >= 2) player.capabilities.allowFlying = true;
else player.capabilities.allowFlying = false;

/*if(leggings && getAbility(player.getCurrentArmor(2))==3)
player.capabilities.setPlayerWalkSpeed(0.75F);
else
Expand Down Expand Up @@ -186,8 +191,15 @@ public void onArmorTick(World world, EntityPlayer player, ItemStack stack) {
player.addPotionEffect(new PotionEffect(Potion.fireResistance.id, 202, 0, true));
}

if (amorcounter >= 2 && modescounter[0] >= 2) player.capabilities.allowFlying = true;
else player.capabilities.allowFlying = false;
// turn flight off or on
if ((amorcounter >= 2 && modescounter[0] >= 2)) {
flightStatus = FlightStatus.ON;
player.capabilities.allowFlying = true;
} else if (flightStatus == FlightStatus.ON) {
flightStatus = FlightStatus.OFF;
player.capabilities.allowFlying = false;
player.capabilities.isFlying = false;
}

/*if (modes[2]==3) {
player.capabilities.setPlayerWalkSpeed(0.75F);
Expand Down

0 comments on commit 6e59c60

Please sign in to comment.