Compare commits
No commits in common. "3521e8ab979ae6c9a2c7814bd46eede8a1b092cf" and "c5d76927421cf6432f1b63b7ba0fc6e985a67d4e" have entirely different histories.
3521e8ab97
...
c5d7692742
3 changed files with 13 additions and 24 deletions
|
@ -15,7 +15,7 @@ show_testing_output = false
|
||||||
|
|
||||||
# Mod Information
|
# Mod Information
|
||||||
# HIGHLY RECOMMEND complying with SemVer for mod_version: https://semver.org/
|
# 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
|
root_package = ru.octol1ttle
|
||||||
mod_id = knockdowns
|
mod_id = knockdowns
|
||||||
mod_name = Knockdowns (Legacy)
|
mod_name = Knockdowns (Legacy)
|
||||||
|
|
|
@ -5,6 +5,8 @@ import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.EntityLiving;
|
import net.minecraft.entity.EntityLiving;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.entity.player.EntityPlayerMP;
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
|
import net.minecraft.init.MobEffects;
|
||||||
|
import net.minecraft.potion.PotionEffect;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.util.DamageSource;
|
import net.minecraft.util.DamageSource;
|
||||||
import net.minecraft.util.EnumActionResult;
|
import net.minecraft.util.EnumActionResult;
|
||||||
|
@ -14,7 +16,6 @@ import net.minecraft.util.text.TextComponentTranslation;
|
||||||
import net.minecraftforge.event.AttachCapabilitiesEvent;
|
import net.minecraftforge.event.AttachCapabilitiesEvent;
|
||||||
import net.minecraftforge.event.RegistryEvent;
|
import net.minecraftforge.event.RegistryEvent;
|
||||||
import net.minecraftforge.event.entity.living.LivingDeathEvent;
|
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.living.LivingSetAttackTargetEvent;
|
||||||
import net.minecraftforge.event.entity.player.AttackEntityEvent;
|
import net.minecraftforge.event.entity.player.AttackEntityEvent;
|
||||||
import net.minecraftforge.event.entity.player.PlayerEvent;
|
import net.minecraftforge.event.entity.player.PlayerEvent;
|
||||||
|
@ -85,7 +86,6 @@ public class KnockdownsCommonEventListener {
|
||||||
knocked.clearElytraFlying();
|
knocked.clearElytraFlying();
|
||||||
|
|
||||||
if (allPlayersKnocked(server, knocked)) {
|
if (allPlayersKnocked(server, knocked)) {
|
||||||
data.setTicksKnocked((int) (KNOCKED_INVULNERABILITY_TICKS + 1));
|
|
||||||
knocked.attackEntityFrom(DamageSource.GENERIC, knocked.getMaxHealth());
|
knocked.attackEntityFrom(DamageSource.GENERIC, knocked.getMaxHealth());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -123,24 +123,17 @@ public class KnockdownsCommonEventListener {
|
||||||
|
|
||||||
int period = MathHelper.floor(KNOCKED_HURT_PERIOD * 20);
|
int period = MathHelper.floor(KNOCKED_HURT_PERIOD * 20);
|
||||||
if (data.getTicksKnocked() <= KNOCKED_INVULNERABILITY_TICKS) {
|
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) {
|
} else if (data.getTicksKnocked() % period == 0) {
|
||||||
|
knocked.setEntityInvulnerable(false);
|
||||||
knocked.attackEntityFrom(DamageSource.GENERIC, knocked.getMaxHealth() / (KNOCKED_TENACITY / KNOCKED_HURT_PERIOD));
|
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
|
@SubscribeEvent
|
||||||
public static void onPlayerDeath(LivingDeathEvent event) {
|
public static void onPlayerDeath(LivingDeathEvent event) {
|
||||||
if (!(event.getEntityLiving() instanceof EntityPlayerMP)) {
|
if (!(event.getEntityLiving() instanceof EntityPlayerMP)) {
|
||||||
|
@ -160,8 +153,11 @@ public class KnockdownsCommonEventListener {
|
||||||
player.setEntityInvulnerable(true);
|
player.setEntityInvulnerable(true);
|
||||||
player.setHealth(1.0f);
|
player.setHealth(1.0f);
|
||||||
player.setAbsorptionAmount(player.getMaxHealth() - 1.0f);
|
player.setAbsorptionAmount(player.getMaxHealth() - 1.0f);
|
||||||
|
player.extinguish();
|
||||||
|
player.setAir(300);
|
||||||
player.clearElytraFlying();
|
player.clearElytraFlying();
|
||||||
KnockdownsUtils.setKnockedInitialState(player);
|
KnockdownsUtils.clearBadPotionEffects(player);
|
||||||
|
player.addPotionEffect(new PotionEffect(MobEffects.SLOWNESS, Integer.MAX_VALUE, 3));
|
||||||
|
|
||||||
Entity trueSource = event.getSource().getTrueSource();
|
Entity trueSource = event.getSource().getTrueSource();
|
||||||
if (trueSource instanceof EntityLiving) {
|
if (trueSource instanceof EntityLiving) {
|
||||||
|
|
|
@ -18,13 +18,6 @@ public class KnockdownsUtils {
|
||||||
public static final float KNOCKED_HURT_PERIOD = 1.2f;
|
public static final float KNOCKED_HURT_PERIOD = 1.2f;
|
||||||
public static final float KNOCKED_TENACITY = 60.0f;
|
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) {
|
public static void clearBadPotionEffects(EntityPlayerMP player) {
|
||||||
List<Potion> removeList = new ArrayList<>();
|
List<Potion> removeList = new ArrayList<>();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue