-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* #feat: 添加了一些状态效果 * #feat: 添加了语言文件 * #feat: 完善状态效果
- Loading branch information
Showing
38 changed files
with
757 additions
and
2 deletions.
There are no files selected for viewing
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
25 changes: 25 additions & 0 deletions
25
src/main/java/com/hechu/mindustry/kiwi/MobEffectModule.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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.hechu.mindustry.kiwi; | ||
|
||
import com.hechu.mindustry.world.effect.*; | ||
import net.minecraft.world.effect.MobEffect; | ||
import snownee.kiwi.AbstractModule; | ||
import snownee.kiwi.KiwiGO; | ||
import snownee.kiwi.KiwiModule; | ||
|
||
@KiwiModule(value = "mob_effect") | ||
public class MobEffectModule extends AbstractModule { | ||
public static final KiwiGO<MobEffect> WET = go(WetMobEffect::create); | ||
public static final KiwiGO<MobEffect> BURNING = go(BurningMobEffect::create); | ||
public static final KiwiGO<MobEffect> FREEZING = go(FreezingMobEffect::create); | ||
public static final KiwiGO<MobEffect> UNMOVING = go(UnmovingMobEffect::create); | ||
public static final KiwiGO<MobEffect> MELTING = go(MeltingMobEffect::create); | ||
public static final KiwiGO<MobEffect> SAPPED = go(SappedMobEffect::create); | ||
public static final KiwiGO<MobEffect> ELECTRIFIED = go(ElectrifiedMobEffect::create); | ||
public static final KiwiGO<MobEffect> SPORE_SLOWED = go(SporeSlowedMobEffect::create); | ||
public static final KiwiGO<MobEffect> TARRED = go(TarredMobEffect::create); | ||
public static final KiwiGO<MobEffect> OVERDRIVE = go(OverdriveMobEffect::create); | ||
public static final KiwiGO<MobEffect> OVERCLOCK = go(OverclockMobEffect::create); | ||
public static final KiwiGO<MobEffect> BOSS = go(BossMobEffect::create); | ||
public static final KiwiGO<MobEffect> SHOCKED = go(ShockedMobEffect::create); | ||
public static final KiwiGO<MobEffect> BLASTED = go(BlastedMobEffect::create); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.hechu.mindustry.kiwi; | ||
|
||
import com.hechu.mindustry.world.effect.*; | ||
import net.minecraft.world.effect.MobEffect; | ||
import net.minecraft.world.effect.MobEffectInstance; | ||
import net.minecraft.world.item.alchemy.Potion; | ||
import snownee.kiwi.AbstractModule; | ||
import snownee.kiwi.KiwiGO; | ||
import snownee.kiwi.KiwiModule; | ||
|
||
@KiwiModule(value = "potion", dependencies = "mob_effect") | ||
public class PotionModule extends AbstractModule { | ||
public static final KiwiGO<Potion> BURNING = go(() -> new Potion(new MobEffectInstance(MobEffectModule.BURNING.get(),3600))); | ||
public static final KiwiGO<Potion> FREEZING = go(() -> new Potion(new MobEffectInstance(MobEffectModule.FREEZING.get(),3600))); | ||
public static final KiwiGO<Potion> UNMOVING = go(() -> new Potion(new MobEffectInstance(MobEffectModule.UNMOVING.get(),3600))); | ||
public static final KiwiGO<Potion> WET = go(() -> new Potion(new MobEffectInstance(MobEffectModule.WET.get(),3600))); | ||
public static final KiwiGO<Potion> MELTING = go(() -> new Potion(new MobEffectInstance(MobEffectModule.MELTING.get(),3600))); | ||
public static final KiwiGO<Potion> SAPPED = go(() -> new Potion(new MobEffectInstance(MobEffectModule.SAPPED.get(),3600))); | ||
public static final KiwiGO<Potion> ELECTRIFIED = go(() -> new Potion(new MobEffectInstance(MobEffectModule.ELECTRIFIED.get(),3600))); | ||
public static final KiwiGO<Potion> SPORE_SLOWED = go(() -> new Potion(new MobEffectInstance(MobEffectModule.SPORE_SLOWED.get(),3600))); | ||
public static final KiwiGO<Potion> TARRED = go(() -> new Potion(new MobEffectInstance(MobEffectModule.TARRED.get(),3600))); | ||
public static final KiwiGO<Potion> OVERDRIVE = go(() -> new Potion(new MobEffectInstance(MobEffectModule.OVERDRIVE.get(),3600))); | ||
public static final KiwiGO<Potion> OVERCLOCK = go(() -> new Potion(new MobEffectInstance(MobEffectModule.OVERCLOCK.get(),3600))); | ||
public static final KiwiGO<Potion> BOSS = go(() -> new Potion(new MobEffectInstance(MobEffectModule.BOSS.get(),3600))); | ||
public static final KiwiGO<Potion> SHOCKED = go(() -> new Potion(new MobEffectInstance(MobEffectModule.SHOCKED.get(),1))); | ||
public static final KiwiGO<Potion> BLASTED = go(() -> new Potion(new MobEffectInstance(MobEffectModule.BLASTED.get(),1))); | ||
} |
95 changes: 95 additions & 0 deletions
95
src/main/java/com/hechu/mindustry/mixin/MixinLivingEntity.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 |
---|---|---|
@@ -0,0 +1,95 @@ | ||
package com.hechu.mindustry.mixin; | ||
|
||
import com.hechu.mindustry.kiwi.MobEffectModule; | ||
import com.hechu.mindustry.world.effect.*; | ||
import net.minecraft.tags.DamageTypeTags; | ||
import net.minecraft.world.damagesource.DamageSource; | ||
import net.minecraft.world.effect.MobEffect; | ||
import net.minecraft.world.effect.MobEffectInstance; | ||
import net.minecraft.world.entity.Attackable; | ||
import net.minecraft.world.entity.Entity; | ||
import net.minecraft.world.entity.EntityType; | ||
import net.minecraft.world.entity.LivingEntity; | ||
import net.minecraft.world.level.Level; | ||
import net.minecraftforge.common.ForgeMod; | ||
import net.minecraftforge.fluids.FluidType; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
import javax.annotation.Nullable; | ||
|
||
@Mixin(LivingEntity.class) | ||
public abstract class MixinLivingEntity extends Entity implements Attackable, net.minecraftforge.common.extensions.IForgeLivingEntity { | ||
@Shadow | ||
public abstract boolean hasEffect(MobEffect pEffect); | ||
|
||
@Shadow | ||
@Nullable | ||
public abstract MobEffectInstance getEffect(MobEffect pEffect); | ||
|
||
@Shadow | ||
public abstract boolean removeEffect(MobEffect pEffect); | ||
|
||
@Shadow | ||
public abstract boolean addEffect(MobEffectInstance pEffectInstance); | ||
|
||
public MixinLivingEntity(EntityType<?> pEntityType, Level pLevel) { | ||
super(pEntityType, pLevel); | ||
} | ||
|
||
@Inject(method = "getDamageAfterMagicAbsorb", at = @At("RETURN"), cancellable = true) | ||
protected void onGetDamageAfterMagicAbsorb(DamageSource damageSource, float damageAmount, CallbackInfoReturnable<Float> cir) { | ||
float damage = cir.getReturnValue(); | ||
if (!damageSource.is(DamageTypeTags.BYPASSES_EFFECTS)) { | ||
if (this.hasEffect(MobEffectModule.FREEZING.get())) { | ||
MobEffectInstance effect = this.getEffect(MobEffectModule.FREEZING.get()); | ||
if (effect != null) { | ||
damage /= (float) Math.pow(FreezingMobEffect.BASE_HEALTH_MULTIPLIER, effect.getAmplifier() + 1); | ||
} | ||
} | ||
if (this.hasEffect(MobEffectModule.MELTING.get())) { | ||
MobEffectInstance effect = this.getEffect(MobEffectModule.MELTING.get()); | ||
if (effect != null) { | ||
damage /= (float) Math.pow(MeltingMobEffect.BASE_HEALTH_MULTIPLIER, effect.getAmplifier() + 1); | ||
} | ||
} | ||
if (this.hasEffect(MobEffectModule.SAPPED.get())) { | ||
MobEffectInstance effect = this.getEffect(MobEffectModule.SAPPED.get()); | ||
if (effect != null) { | ||
damage /= (float) Math.pow(SappedMobEffect.BASE_HEALTH_MULTIPLIER, effect.getAmplifier() + 1); | ||
} | ||
} | ||
if (this.hasEffect(MobEffectModule.OVERDRIVE.get())) { | ||
MobEffectInstance effect = this.getEffect(MobEffectModule.OVERDRIVE.get()); | ||
if (effect != null) { | ||
damage /= (float) Math.pow(OverdriveMobEffect.BASE_HEALTH_MULTIPLIER, effect.getAmplifier() + 1); | ||
} | ||
} | ||
if (this.hasEffect(MobEffectModule.BOSS.get())) { | ||
MobEffectInstance effect = this.getEffect(MobEffectModule.BOSS.get()); | ||
if (effect != null) { | ||
damage /= (float) Math.pow(BossMobEffect.BASE_HEALTH_MULTIPLIER, effect.getAmplifier() + 1); | ||
} | ||
} | ||
cir.setReturnValue(damage); | ||
} | ||
} | ||
|
||
@Inject(method = "baseTick", at = @At("HEAD"), cancellable = true) | ||
public void onBaseTick(CallbackInfo ci) { | ||
if (this.isAlive() && this.isInWaterRainOrBubble()) { | ||
if (!this.hasEffect(MobEffectModule.WET.get()) | ||
|| | ||
(this.hasEffect(MobEffectModule.WET.get()) | ||
&& this.getEffect(MobEffectModule.WET.get()).getAmplifier() <= 0 | ||
&& this.getEffect(MobEffectModule.WET.get()).getDuration() <= 15 * 20)) { | ||
this.removeEffect(MobEffectModule.WET.get()); | ||
this.addEffect(new MobEffectInstance(MobEffectModule.WET.get(), 15 * 20 + 1, 0)); | ||
} | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package com.hechu.mindustry.mixin; | ||
|
||
import org.objectweb.asm.tree.ClassNode; | ||
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin; | ||
import org.spongepowered.asm.mixin.extensibility.IMixinInfo; | ||
|
||
import java.util.List; | ||
import java.util.Set; | ||
|
||
public class MixinPlugin implements IMixinConfigPlugin { | ||
private boolean isFrameworkInstalled; | ||
@Override | ||
public void onLoad(String mixinPackage) { | ||
try { | ||
//这个字符串对应你的项目主类 | ||
Class.forName("com.hechu.mindustry.Mindustry", false, this.getClass().getClassLoader()); | ||
isFrameworkInstalled = true; | ||
} catch (Exception e) { | ||
isFrameworkInstalled = false; | ||
} | ||
} | ||
|
||
@Override | ||
public String getRefMapperConfig() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) { | ||
return isFrameworkInstalled; // this makes sure that forge's helpful mods not found screen shows up | ||
} | ||
|
||
@Override | ||
public void acceptTargets(Set<String> myTargets, Set<String> otherTargets) { | ||
|
||
} | ||
|
||
@Override | ||
public List<String> getMixins() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { | ||
|
||
} | ||
|
||
@Override | ||
public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { | ||
|
||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/com/hechu/mindustry/world/effect/BlastedMobEffect.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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.hechu.mindustry.world.effect; | ||
|
||
import com.hechu.mindustry.kiwi.MobEffectModule; | ||
import net.minecraft.world.effect.MobEffectCategory; | ||
|
||
public class BlastedMobEffect extends MindustryInstantenousMobEffect { | ||
protected BlastedMobEffect() { | ||
super(MobEffectCategory.HARMFUL, 16742494); | ||
} | ||
|
||
public static BlastedMobEffect create() { | ||
return (BlastedMobEffect) new BlastedMobEffect() | ||
.reactive(MobEffectModule.FREEZING.get(), params -> { | ||
float j = (float) (9.0F * Math.pow(2, params.amplifier)); | ||
params.livingEntity.hurt(params.livingEntity.damageSources().magic(), j); | ||
}); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/com/hechu/mindustry/world/effect/BossMobEffect.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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.hechu.mindustry.world.effect; | ||
|
||
import net.minecraft.world.effect.MobEffect; | ||
import net.minecraft.world.effect.MobEffectCategory; | ||
import net.minecraft.world.entity.ai.attributes.AttributeModifier; | ||
import net.minecraft.world.entity.ai.attributes.Attributes; | ||
|
||
public class BossMobEffect extends MobEffect { | ||
protected BossMobEffect() { | ||
super(MobEffectCategory.BENEFICIAL, 15750228); | ||
} | ||
|
||
public static BossMobEffect create() { | ||
return (BossMobEffect) new BossMobEffect() | ||
.addAttributeModifier(Attributes.ATTACK_DAMAGE, "125CA66E-C7B3-4E3C-8A60-80D974AFAEE6", | ||
BASE_ATTACK_DAMAGE_MULTIPLIER - 1f, AttributeModifier.Operation.MULTIPLY_TOTAL); | ||
} | ||
|
||
public static final float BASE_ATTACK_DAMAGE_MULTIPLIER = 1.3f; | ||
public static final float BASE_HEALTH_MULTIPLIER = 1.5f; | ||
} |
67 changes: 67 additions & 0 deletions
67
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 |
---|---|---|
@@ -0,0 +1,67 @@ | ||
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 BurningMobEffect() { | ||
super(MobEffectCategory.HARMFUL, 16761940); | ||
} | ||
|
||
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())); | ||
} | ||
} | ||
}); | ||
} | ||
|
||
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)); | ||
|
||
if (livingEntity.hasEffect(MobEffectModule.TARRED.get())) | ||
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; | ||
} | ||
} | ||
} |
Oops, something went wrong.