diff --git a/gradle.properties b/gradle.properties index e7c025e..b5ab346 100644 --- a/gradle.properties +++ b/gradle.properties @@ -15,7 +15,7 @@ show_testing_output = false # Mod Information # HIGHLY RECOMMEND complying with SemVer for mod_version: https://semver.org/ -mod_version=1.1.2 +mod_version=1.1.1 root_package = ru.octol1ttle mod_id = knockdowns mod_name = Knockdowns (Legacy) diff --git a/src/main/java/ru/octol1ttle/knockdowns/common/KnockdownsCommonEventListener.java b/src/main/java/ru/octol1ttle/knockdowns/common/KnockdownsCommonEventListener.java index cf4b2f0..a5348af 100644 --- a/src/main/java/ru/octol1ttle/knockdowns/common/KnockdownsCommonEventListener.java +++ b/src/main/java/ru/octol1ttle/knockdowns/common/KnockdownsCommonEventListener.java @@ -5,6 +5,8 @@ import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.init.MobEffects; +import net.minecraft.potion.PotionEffect; import net.minecraft.server.MinecraftServer; import net.minecraft.util.DamageSource; import net.minecraft.util.EnumActionResult; @@ -14,7 +16,6 @@ import net.minecraft.util.text.TextComponentTranslation; import net.minecraftforge.event.AttachCapabilitiesEvent; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.event.entity.living.LivingDeathEvent; -import net.minecraftforge.event.entity.living.LivingHurtEvent; import net.minecraftforge.event.entity.living.LivingSetAttackTargetEvent; import net.minecraftforge.event.entity.player.AttackEntityEvent; import net.minecraftforge.event.entity.player.PlayerEvent; @@ -85,7 +86,6 @@ public class KnockdownsCommonEventListener { knocked.clearElytraFlying(); if (allPlayersKnocked(server, knocked)) { - data.setTicksKnocked((int) (KNOCKED_INVULNERABILITY_TICKS + 1)); knocked.attackEntityFrom(DamageSource.GENERIC, knocked.getMaxHealth()); return; } @@ -123,24 +123,17 @@ public class KnockdownsCommonEventListener { int period = MathHelper.floor(KNOCKED_HURT_PERIOD * 20); if (data.getTicksKnocked() <= KNOCKED_INVULNERABILITY_TICKS) { - KnockdownsUtils.setKnockedInitialState(knocked); + knocked.setEntityInvulnerable(true); + knocked.extinguish(); + knocked.setAir(300); + KnockdownsUtils.clearBadPotionEffects(knocked); + knocked.addPotionEffect(new PotionEffect(MobEffects.SLOWNESS, Integer.MAX_VALUE, 3)); } else if (data.getTicksKnocked() % period == 0) { + knocked.setEntityInvulnerable(false); knocked.attackEntityFrom(DamageSource.GENERIC, knocked.getMaxHealth() / (KNOCKED_TENACITY / KNOCKED_HURT_PERIOD)); } } - @SubscribeEvent - public static void onPlayerHurt(LivingHurtEvent event) { - if (event.getEntityLiving() instanceof EntityPlayerMP) { - EntityPlayerMP knocked = (EntityPlayerMP) event.getEntityLiving(); - IKnockdownsPlayerData data = IKnockdownsPlayerData.get(knocked); - if (data.isKnockedDown() && data.getTicksKnocked() <= KNOCKED_INVULNERABILITY_TICKS) { - KnockdownsUtils.setKnockedInitialState(knocked); - event.setCanceled(true); - } - } - } - @SubscribeEvent public static void onPlayerDeath(LivingDeathEvent event) { if (!(event.getEntityLiving() instanceof EntityPlayerMP)) { @@ -160,8 +153,11 @@ public class KnockdownsCommonEventListener { player.setEntityInvulnerable(true); player.setHealth(1.0f); player.setAbsorptionAmount(player.getMaxHealth() - 1.0f); + player.extinguish(); + player.setAir(300); player.clearElytraFlying(); - KnockdownsUtils.setKnockedInitialState(player); + KnockdownsUtils.clearBadPotionEffects(player); + player.addPotionEffect(new PotionEffect(MobEffects.SLOWNESS, Integer.MAX_VALUE, 3)); Entity trueSource = event.getSource().getTrueSource(); if (trueSource instanceof EntityLiving) { diff --git a/src/main/java/ru/octol1ttle/knockdowns/common/KnockdownsUtils.java b/src/main/java/ru/octol1ttle/knockdowns/common/KnockdownsUtils.java index b605f9a..2c32768 100644 --- a/src/main/java/ru/octol1ttle/knockdowns/common/KnockdownsUtils.java +++ b/src/main/java/ru/octol1ttle/knockdowns/common/KnockdownsUtils.java @@ -18,13 +18,6 @@ public class KnockdownsUtils { public static final float KNOCKED_HURT_PERIOD = 1.2f; public static final float KNOCKED_TENACITY = 60.0f; - public static void setKnockedInitialState(EntityPlayerMP player) { - player.extinguish(); - player.setAir(300); - KnockdownsUtils.clearBadPotionEffects(player); - player.addPotionEffect(new PotionEffect(MobEffects.SLOWNESS, Integer.MAX_VALUE, 3)); - } - public static void clearBadPotionEffects(EntityPlayerMP player) { List removeList = new ArrayList<>();