forked from HeChuQIU/MinecraftMod-Mindustry
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5fc44b4
commit 54a2282
Showing
4 changed files
with
48 additions
and
99 deletions.
There are no files selected for viewing
50 changes: 10 additions & 40 deletions
50
src/main/java/com/hechu/mindustry/world/effect/BurningMobEffect.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,37 @@ | ||
package com.hechu.mindustry.world.effect; | ||
|
||
import com.hechu.mindustry.kiwi.MobEffectModule; | ||
import net.minecraft.world.effect.MobEffect; | ||
import net.minecraft.world.effect.MobEffectCategory; | ||
import net.minecraft.world.effect.MobEffectInstance; | ||
import net.minecraft.world.entity.LivingEntity; | ||
import net.minecraft.world.entity.player.Player; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public class BurningMobEffect extends MindustryMobEffect { | ||
public static final double BASE_DAMAGE = 1f; | ||
|
||
public BurningMobEffect() { | ||
super(MobEffectCategory.HARMFUL, 16761940); | ||
super(MobEffectCategory.HARMFUL, 16761940, 20); | ||
} | ||
|
||
public static BurningMobEffect create() { | ||
return (BurningMobEffect) new BurningMobEffect() | ||
.reactive(MobEffectModule.WET.get(), params -> { | ||
MobEffectInstance wetEffect = params.livingEntity.getEffect(MobEffectModule.WET.get()); | ||
MobEffectInstance burningEffect = params.livingEntity.getEffect(MobEffectModule.BURNING.get()); | ||
if (wetEffect != null && burningEffect != null) { | ||
int t = burningEffect.getDuration() - wetEffect.getDuration(); | ||
// 不知道怎么缩减时间,所以这么处理 | ||
params.livingEntity.removeEffect(MobEffectModule.BURNING.get()); | ||
params.livingEntity.removeEffect(MobEffectModule.WET.get()); | ||
if (t > 0) { | ||
params.livingEntity.addEffect(new MobEffectInstance(MobEffectModule.BURNING.get(), t, burningEffect.getAmplifier())); | ||
} else { | ||
params.livingEntity.addEffect(new MobEffectInstance(MobEffectModule.WET.get(), -t, wetEffect.getAmplifier())); | ||
} | ||
} | ||
}); | ||
.reactive(MobEffectModule.WET, params -> | ||
reactiveHandler(params, MobEffectModule.BURNING.get(), MobEffectModule.WET.get())) | ||
.reactive(MobEffectModule.FREEZING, params -> | ||
reactiveHandler(params, MobEffectModule.FREEZING.get(), MobEffectModule.MELTING.get())); | ||
} | ||
|
||
public static final int BASE_DURATION = 20; | ||
public static final float BASE_DAMAGE = 1f; | ||
|
||
@Override | ||
public void applyEffectTick(@NotNull LivingEntity livingEntity, int amplifier) { | ||
super.applyEffectTick(livingEntity, amplifier); | ||
if (livingEntity instanceof Player player && player.isCreative()) | ||
return; | ||
float j = (float) (BASE_DURATION / Math.pow(2d, amplifier)); | ||
double j = applyTimeInterval / Math.pow(2d, amplifier); | ||
|
||
if (livingEntity.hasEffect(MobEffectModule.TARRED.get())) | ||
j += 4.0F; | ||
j += 4.0f; | ||
|
||
livingEntity.setRemainingFireTicks(j >= 1 ? (int) j : 1); | ||
livingEntity.hurt(livingEntity.damageSources().onFire(), j < 1f ? (BASE_DAMAGE / j) : BASE_DAMAGE); | ||
} | ||
|
||
/** | ||
* Checks whether the effect is ready to be applied this tick. | ||
* | ||
* @param duration | ||
* @param amplifier | ||
*/ | ||
@Override | ||
public boolean isDurationEffectTick(int duration, int amplifier) { | ||
int j = (int) (BASE_DURATION / Math.pow(2d, amplifier)); | ||
if (j > 0) { | ||
return duration % j == 0; | ||
} else { | ||
return true; | ||
} | ||
livingEntity.hurt(livingEntity.damageSources().onFire(), (float) (j < 1f ? (BASE_DAMAGE / j) : BASE_DAMAGE)); | ||
} | ||
} |
23 changes: 13 additions & 10 deletions
23
src/main/java/com/hechu/mindustry/world/effect/FreezingMobEffect.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,27 @@ | ||
package com.hechu.mindustry.world.effect; | ||
|
||
import net.minecraft.world.effect.MobEffect; | ||
import com.hechu.mindustry.kiwi.MobEffectModule; | ||
import net.minecraft.world.effect.MobEffectCategory; | ||
import net.minecraft.world.entity.LivingEntity; | ||
import net.minecraft.world.entity.ai.attributes.Attribute; | ||
import net.minecraft.world.entity.ai.attributes.AttributeMap; | ||
import net.minecraft.world.entity.ai.attributes.AttributeModifier; | ||
import net.minecraft.world.entity.ai.attributes.Attributes; | ||
import net.minecraft.world.entity.player.Player; | ||
|
||
public class FreezingMobEffect extends MobEffect { | ||
public class FreezingMobEffect extends MindustryMobEffect { | ||
public static final float BASE_SPEED_MULTIPLIER = 0.6f; | ||
public static final float BASE_HEALTH_MULTIPLIER = 0.8f; | ||
|
||
protected FreezingMobEffect() { | ||
super(MobEffectCategory.HARMFUL, 7063782); | ||
} | ||
|
||
public static FreezingMobEffect create() { | ||
return (FreezingMobEffect) new FreezingMobEffect().addAttributeModifier(Attributes.MOVEMENT_SPEED, | ||
"6069378B-E74B-4712-8BDC-401451175BC2", BASE_SPEED_MULTIPLIER - 1f, AttributeModifier.Operation.MULTIPLY_TOTAL); | ||
return (FreezingMobEffect) new FreezingMobEffect() | ||
.reactive(MobEffectModule.BURNING, params -> | ||
reactiveHandler(params, MobEffectModule.FREEZING.get(), MobEffectModule.BURNING.get())) | ||
.reactive(MobEffectModule.MELTING, params -> | ||
reactiveHandler(params, MobEffectModule.FREEZING.get(), MobEffectModule.MELTING.get())) | ||
.addAttributeModifier(Attributes.MOVEMENT_SPEED, "6069378B-E74B-4712-8BDC-401451175BC2", | ||
BASE_SPEED_MULTIPLIER - 1f, AttributeModifier.Operation.MULTIPLY_TOTAL); | ||
} | ||
|
||
public static final float BASE_SPEED_MULTIPLIER = 0.6f; | ||
public static final float BASE_HEALTH_MULTIPLIER = 0.8f;//TODO: 等待使用Mixin实现 | ||
//TODO: 等待使用Mixin实现 | ||
} |
57 changes: 14 additions & 43 deletions
57
src/main/java/com/hechu/mindustry/world/effect/MeltingMobEffect.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,70 +1,41 @@ | ||
package com.hechu.mindustry.world.effect; | ||
|
||
import com.hechu.mindustry.kiwi.MobEffectModule; | ||
import net.minecraft.world.effect.MobEffect; | ||
import net.minecraft.world.effect.MobEffectCategory; | ||
import net.minecraft.world.effect.MobEffectInstance; | ||
import net.minecraft.world.entity.LivingEntity; | ||
import net.minecraft.world.entity.ai.attributes.AttributeModifier; | ||
import net.minecraft.world.entity.ai.attributes.Attributes; | ||
import net.minecraft.world.entity.player.Player; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public class MeltingMobEffect extends MindustryMobEffect { | ||
public static final float BASE_SPEED_MULTIPLIER = 0.8f; | ||
public static final float BASE_HEALTH_MULTIPLIER = 0.8f; | ||
public static final float BASE_DAMAGE = 1.8f; | ||
|
||
protected MeltingMobEffect() { | ||
super(MobEffectCategory.HARMFUL, 16752742); | ||
super(MobEffectCategory.HARMFUL, 16752742, 20); | ||
} | ||
|
||
public static MeltingMobEffect create() { | ||
return (MeltingMobEffect) new MeltingMobEffect() | ||
.reactive(MobEffectModule.WET.get(), params -> { | ||
MobEffectInstance wetEffect = params.livingEntity.getEffect(MobEffectModule.WET.get()); | ||
MobEffectInstance meltingEffect = params.livingEntity.getEffect(MobEffectModule.MELTING.get()); | ||
if (wetEffect != null && meltingEffect != null) { | ||
int t = meltingEffect.getDuration() - wetEffect.getDuration(); | ||
// 不知道怎么缩减时间,所以这么处理 | ||
params.livingEntity.removeEffect(MobEffectModule.MELTING.get()); | ||
params.livingEntity.removeEffect(MobEffectModule.WET.get()); | ||
if (t > 0) { | ||
params.livingEntity.addEffect(new MobEffectInstance(MobEffectModule.MELTING.get(), t, meltingEffect.getAmplifier())); | ||
} else { | ||
params.livingEntity.addEffect(new MobEffectInstance(MobEffectModule.WET.get(), -t, wetEffect.getAmplifier())); | ||
} | ||
} | ||
}) | ||
.addAttributeModifier(Attributes.MOVEMENT_SPEED, | ||
"09C9E884-72C0-448B-944D-B19B3EA34FEB", BASE_SPEED_MULTIPLIER - 1f, AttributeModifier.Operation.MULTIPLY_TOTAL); | ||
.reactive(MobEffectModule.WET, params -> | ||
reactiveHandler(params, MobEffectModule.MELTING.get(), MobEffectModule.WET.get())) | ||
.reactive(MobEffectModule.FREEZING, params -> | ||
reactiveHandler(params, MobEffectModule.FREEZING.get(), MobEffectModule.BURNING.get())) | ||
.addAttributeModifier(Attributes.MOVEMENT_SPEED, "09C9E884-72C0-448B-944D-B19B3EA34FEB", | ||
BASE_SPEED_MULTIPLIER - 1f, AttributeModifier.Operation.MULTIPLY_TOTAL); | ||
} | ||
|
||
public static final float BASE_SPEED_MULTIPLIER = 0.8f; | ||
public static final float BASE_HEALTH_MULTIPLIER = 0.8f; | ||
|
||
public static final int BASE_DURATION = 20; | ||
public static final float BASE_DAMAGE = 1.8f; | ||
|
||
@Override | ||
public void applyEffectTick(@NotNull LivingEntity livingEntity, int amplifier) { | ||
super.applyEffectTick(livingEntity, amplifier); | ||
if (livingEntity instanceof Player player && player.isCreative()) | ||
return; | ||
float j = (float) (BASE_DURATION / Math.pow(2d, amplifier)); | ||
float j = (float) (applyTimeInterval / Math.pow(2d, amplifier)); | ||
if (livingEntity.hasEffect(MobEffectModule.TARRED.get())) | ||
j += 8; | ||
livingEntity.setRemainingFireTicks(j >= 1 ? (int) j : 1); | ||
livingEntity.hurt(livingEntity.damageSources().onFire(), j < 1f ? (BASE_DAMAGE / j) : BASE_DAMAGE); | ||
} | ||
|
||
/** | ||
* Checks whether the effect is ready to be applied this tick. | ||
* | ||
* @param duration | ||
* @param amplifier | ||
*/ | ||
@Override | ||
public boolean isDurationEffectTick(int duration, int amplifier) { | ||
int j = (int) (BASE_DURATION / Math.pow(2d, amplifier)); | ||
if (j > 0) { | ||
return duration % j == 0; | ||
} else { | ||
return true; | ||
} | ||
} | ||
} |
17 changes: 11 additions & 6 deletions
17
src/main/java/com/hechu/mindustry/world/effect/WetMobEffect.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,24 @@ | ||
package com.hechu.mindustry.world.effect; | ||
|
||
import net.minecraft.world.effect.MobEffect; | ||
import com.hechu.mindustry.kiwi.MobEffectModule; | ||
import net.minecraft.world.effect.MobEffectCategory; | ||
import net.minecraft.world.entity.ai.attributes.AttributeModifier; | ||
import net.minecraft.world.entity.ai.attributes.Attributes; | ||
|
||
public class WetMobEffect extends MobEffect { | ||
public class WetMobEffect extends MindustryMobEffect { | ||
public static final float BASE_SPEED_MULTIPLIER = 0.94f; | ||
|
||
protected WetMobEffect() { | ||
super(MobEffectCategory.NEUTRAL, 4286688); | ||
} | ||
|
||
public static WetMobEffect create() { | ||
return (WetMobEffect) new WetMobEffect().addAttributeModifier(Attributes.MOVEMENT_SPEED, | ||
"D59732C5-E09A-4952-8505-ED83BCF77402", BASE_SPEED_MULTIPLIER - 1f, AttributeModifier.Operation.MULTIPLY_TOTAL); | ||
return (WetMobEffect) new WetMobEffect() | ||
.reactive(MobEffectModule.BURNING, params -> | ||
reactiveHandler(params, MobEffectModule.BURNING.get(), MobEffectModule.WET.get())) | ||
.reactive(MobEffectModule.MELTING, params -> | ||
reactiveHandler(params, MobEffectModule.MELTING.get(), MobEffectModule.WET.get())) | ||
.addAttributeModifier(Attributes.MOVEMENT_SPEED, "D59732C5-E09A-4952-8505-ED83BCF77402", | ||
BASE_SPEED_MULTIPLIER - 1f, AttributeModifier.Operation.MULTIPLY_TOTAL); | ||
} | ||
|
||
public static final float BASE_SPEED_MULTIPLIER = 0.94f; | ||
} |