-
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.
* #fix: 优化扳手的行为逻辑,修复扳手工具提示错误 * #feat: DataGen添加战利品表提供器,为可挖掘方块添加战利品表(钻头等多方块结构暂未添加),现在他们可以在挖掘后掉落自身了 * #feat: 添加了AssesstransFormer,可以修改可见性 * #feat: 将状态效果互斥抽象为函数,提高复用性 * #fix: 修复效果互斥不对等问题 * #fix: 修复accesstransformer文件名错误
- Loading branch information
1 parent
1b46b33
commit b29ccdc
Showing
19 changed files
with
177 additions
and
174 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
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
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
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
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
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)); | ||
} | ||
} |
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
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; | ||
} | ||
} | ||
} |
Oops, something went wrong.