Compare commits
3 commits
c5d7692742
...
3521e8ab97
Author | SHA1 | Date | |
---|---|---|---|
3521e8ab97 | |||
6fc1e412f7 | |||
7efc2d9af1 |
3 changed files with 24 additions and 13 deletions
|
@ -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.1
|
||||
mod_version=1.1.2
|
||||
root_package = ru.octol1ttle
|
||||
mod_id = knockdowns
|
||||
mod_name = Knockdowns (Legacy)
|
||||
|
|
|
@ -5,8 +5,6 @@ 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;
|
||||
|
@ -16,6 +14,7 @@ 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;
|
||||
|
@ -86,6 +85,7 @@ public class KnockdownsCommonEventListener {
|
|||
knocked.clearElytraFlying();
|
||||
|
||||
if (allPlayersKnocked(server, knocked)) {
|
||||
data.setTicksKnocked((int) (KNOCKED_INVULNERABILITY_TICKS + 1));
|
||||
knocked.attackEntityFrom(DamageSource.GENERIC, knocked.getMaxHealth());
|
||||
return;
|
||||
}
|
||||
|
@ -123,17 +123,24 @@ public class KnockdownsCommonEventListener {
|
|||
|
||||
int period = MathHelper.floor(KNOCKED_HURT_PERIOD * 20);
|
||||
if (data.getTicksKnocked() <= KNOCKED_INVULNERABILITY_TICKS) {
|
||||
knocked.setEntityInvulnerable(true);
|
||||
knocked.extinguish();
|
||||
knocked.setAir(300);
|
||||
KnockdownsUtils.clearBadPotionEffects(knocked);
|
||||
knocked.addPotionEffect(new PotionEffect(MobEffects.SLOWNESS, Integer.MAX_VALUE, 3));
|
||||
KnockdownsUtils.setKnockedInitialState(knocked);
|
||||
} 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)) {
|
||||
|
@ -153,11 +160,8 @@ public class KnockdownsCommonEventListener {
|
|||
player.setEntityInvulnerable(true);
|
||||
player.setHealth(1.0f);
|
||||
player.setAbsorptionAmount(player.getMaxHealth() - 1.0f);
|
||||
player.extinguish();
|
||||
player.setAir(300);
|
||||
player.clearElytraFlying();
|
||||
KnockdownsUtils.clearBadPotionEffects(player);
|
||||
player.addPotionEffect(new PotionEffect(MobEffects.SLOWNESS, Integer.MAX_VALUE, 3));
|
||||
KnockdownsUtils.setKnockedInitialState(player);
|
||||
|
||||
Entity trueSource = event.getSource().getTrueSource();
|
||||
if (trueSource instanceof EntityLiving) {
|
||||
|
|
|
@ -18,6 +18,13 @@ 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<Potion> removeList = new ArrayList<>();
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue