v1.5.0
This commit is contained in:
1 parent
7979201df4
commit
68716f3211
55 files changed
+3733
-562
No files matched your search
@@ -6,12 +6,9 @@ import com.lzxnone.terraria.creative_mode_tab.ModCreativeModeTabs;
|
||||
import com.lzxnone.terraria.effect.ModEffects;
|
||||
import com.lzxnone.terraria.entity.ModEntities;
|
||||
import com.lzxnone.terraria.entity.summon.BeeSummon;
|
||||
import com.lzxnone.terraria.entity.summon.StaticSummon;
|
||||
import com.lzxnone.terraria.item.ModItems;
|
||||
import com.lzxnone.terraria.particle.ModParticles;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.neoforged.neoforge.event.entity.EntityAttributeCreationEvent;
|
||||
import net.neoforged.neoforge.registries.RegisterEvent;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import com.mojang.logging.LogUtils;
|
||||
@@ -47,4 +44,4 @@ public class LzxnoneTerraria {
|
||||
public void onEntityAttributeCreation(EntityAttributeCreationEvent event) {
|
||||
event.put(ModEntities.BEE_SUMMON.get(), BeeSummon.createAttributes().build());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.lzxnone.terraria;
|
||||
|
||||
import com.lzxnone.terraria.ui.config.ConfigScreen;
|
||||
import com.lzxnone.terraria.entity.ModEntities;
|
||||
import com.lzxnone.terraria.entity.beam.SwordBeamRenderer;
|
||||
import com.lzxnone.terraria.entity.projectile.StaticProjectileRenderer;
|
||||
@@ -12,13 +13,12 @@ import net.neoforged.fml.ModContainer;
|
||||
import net.neoforged.fml.common.Mod;
|
||||
import net.neoforged.neoforge.client.event.EntityRenderersEvent;
|
||||
import net.neoforged.neoforge.client.event.RegisterParticleProvidersEvent;
|
||||
import net.neoforged.neoforge.client.gui.ConfigurationScreen;
|
||||
import net.neoforged.neoforge.client.gui.IConfigScreenFactory;
|
||||
|
||||
@Mod(value = LzxnoneTerraria.MODID, dist = Dist.CLIENT)
|
||||
public class LzxnoneTerrariaClient {
|
||||
public LzxnoneTerrariaClient(ModContainer container, IEventBus modEventBus) {
|
||||
container.registerExtensionPoint(IConfigScreenFactory.class, ConfigurationScreen::new);
|
||||
container.registerExtensionPoint(IConfigScreenFactory.class, (modContainer, parent) -> ConfigScreen.create(parent));
|
||||
|
||||
//Entity渲染
|
||||
modEventBus.addListener(EntityRenderersEvent.RegisterRenderers.class, event -> {
|
||||
|
||||
@@ -83,4 +83,12 @@ public class ModSounds {
|
||||
SOUND_EVENTS.register("demon_sword_kill_mode",
|
||||
() -> SoundEvent.createVariableRangeEvent(
|
||||
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "demon_sword_kill_mode")));
|
||||
public static final Supplier<SoundEvent> DEMON_SWORD_KILL_MODE_OFF_COOLDOWN =
|
||||
SOUND_EVENTS.register("demon_sword_kill_mode_off_cooldown",
|
||||
() -> SoundEvent.createVariableRangeEvent(
|
||||
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "demon_sword_kill_mode_off_cooldown")));
|
||||
public static final Supplier<SoundEvent> DEMON_SWORD_FINAL_STRIKE =
|
||||
SOUND_EVENTS.register("demon_sword_final_strike",
|
||||
() -> SoundEvent.createVariableRangeEvent(
|
||||
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "demon_sword_final_strike")));
|
||||
}
|
||||
@@ -1,9 +1,15 @@
|
||||
package com.lzxnone.terraria.effect;
|
||||
|
||||
import com.lzxnone.terraria.Config;
|
||||
import com.lzxnone.terraria.LzxnoneTerraria;
|
||||
import com.lzxnone.terraria.particle.ModParticles;
|
||||
import com.lzxnone.terraria.ui.config.ConfigFactory;
|
||||
import com.lzxnone.terraria.ui.config.ConfigListItem;
|
||||
import com.lzxnone.terraria.ui.config.ConfigUtil;
|
||||
import com.lzxnone.terraria.ui.config.IConfigData;
|
||||
import com.lzxnone.terraria.utils.MathUtil;
|
||||
import com.lzxnone.terraria.utils.ParticleUtil;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.effect.MobEffect;
|
||||
import net.minecraft.world.effect.MobEffectCategory;
|
||||
@@ -13,10 +19,43 @@ import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
public class BloodButcheredEffect extends MobEffect {
|
||||
private static final String CONFIG_TRANSLATION_PREFIX = "lzxnoneterraria.configuration.";
|
||||
|
||||
public static final String DAMAGE_PER_LEVEL_PATH = "effect.blood_butchered.damage_per_level";
|
||||
public static final double DAMAGE_PER_LEVEL_DEFAULT = 0.5;
|
||||
public static final double DAMAGE_PER_LEVEL_MIN = 0.0;
|
||||
public static final double DAMAGE_PER_LEVEL_MAX = 8388600.0;
|
||||
|
||||
public BloodButcheredEffect() {
|
||||
super(MobEffectCategory.HARMFUL, 0xFF0000);
|
||||
}
|
||||
|
||||
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
||||
@Override
|
||||
public void onConfigLoad() {
|
||||
ConfigFactory.loadDoubleConfig(DAMAGE_PER_LEVEL_PATH, configText("blood_butcherer_damage_per_level"), configTooltip("blood_butcherer_damage_per_level"), DAMAGE_PER_LEVEL_DEFAULT, DAMAGE_PER_LEVEL_MIN, DAMAGE_PER_LEVEL_MAX);
|
||||
}
|
||||
};
|
||||
|
||||
private static Component configText(String key) {
|
||||
return Component.translatable(CONFIG_TRANSLATION_PREFIX + key);
|
||||
}
|
||||
|
||||
private static Component configTooltip(String key) {
|
||||
return Component.translatable(CONFIG_TRANSLATION_PREFIX + key + ".tooltip");
|
||||
}
|
||||
|
||||
public static double getDamagePerLevel() {
|
||||
return Math.clamp(ConfigUtil.readDouble(DAMAGE_PER_LEVEL_PATH, DAMAGE_PER_LEVEL_DEFAULT), DAMAGE_PER_LEVEL_MIN, DAMAGE_PER_LEVEL_MAX);
|
||||
}
|
||||
|
||||
public static final ConfigListItem CONFIG_LIST_ITEM = new ConfigListItem(
|
||||
"blood_butchered",
|
||||
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/mob_effect/blood_butchered.png"),
|
||||
Component.translatable("effect.lzxnoneterraria.blood_butchered"),
|
||||
CONFIG_DATA
|
||||
);
|
||||
|
||||
@Override
|
||||
public boolean shouldApplyEffectTickThisTick(int duration, int amplifier) {
|
||||
return true;
|
||||
@@ -28,7 +67,7 @@ public class BloodButcheredEffect extends MobEffect {
|
||||
MobEffectInstance instance = entity.getEffect(ModEffects.BLOOD_BUTCHERED);
|
||||
if(instance != null) {
|
||||
if(instance.getDuration() % 20 == 0) {
|
||||
entity.hurt(entity.damageSources().magic(), (float) Config.bloodButchererDamagePerLevel * (amplifier + 1));
|
||||
entity.hurt(entity.damageSources().magic(), (float) getDamagePerLevel() * (amplifier + 1));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
package com.lzxnone.terraria.effect;
|
||||
|
||||
import com.lzxnone.terraria.Config;
|
||||
import com.lzxnone.terraria.LzxnoneTerraria;
|
||||
import com.lzxnone.terraria.particle.CircleParticleOptions;
|
||||
import com.lzxnone.terraria.ui.config.ConfigFactory;
|
||||
import com.lzxnone.terraria.ui.config.ConfigListItem;
|
||||
import com.lzxnone.terraria.ui.config.ConfigUtil;
|
||||
import com.lzxnone.terraria.ui.config.IConfigData;
|
||||
import com.lzxnone.terraria.utils.ParticleUtil;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.effect.MobEffect;
|
||||
import net.minecraft.world.effect.MobEffectCategory;
|
||||
@@ -13,10 +18,43 @@ import net.minecraft.world.phys.Vec3;
|
||||
import org.joml.Vector3f;
|
||||
|
||||
public class DemonicFlamesEffect extends MobEffect {
|
||||
private static final String CONFIG_TRANSLATION_PREFIX = "lzxnoneterraria.configuration.";
|
||||
|
||||
public static final String DAMAGE_PER_LEVEL_PATH = "effect.demonic_flames.damage_per_level";
|
||||
public static final double DAMAGE_PER_LEVEL_DEFAULT = 2.5;
|
||||
public static final double DAMAGE_PER_LEVEL_MIN = 0.0;
|
||||
public static final double DAMAGE_PER_LEVEL_MAX = 8388600.0;
|
||||
|
||||
public DemonicFlamesEffect() {
|
||||
super(MobEffectCategory.HARMFUL, 0xCC2DC7);
|
||||
}
|
||||
|
||||
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
||||
@Override
|
||||
public void onConfigLoad() {
|
||||
ConfigFactory.loadDoubleConfig(DAMAGE_PER_LEVEL_PATH, configText("demonic_flames_damage_per_level"), configTooltip("demonic_flames_damage_per_level"), DAMAGE_PER_LEVEL_DEFAULT, DAMAGE_PER_LEVEL_MIN, DAMAGE_PER_LEVEL_MAX);
|
||||
}
|
||||
};
|
||||
|
||||
private static Component configText(String key) {
|
||||
return Component.translatable(CONFIG_TRANSLATION_PREFIX + key);
|
||||
}
|
||||
|
||||
private static Component configTooltip(String key) {
|
||||
return Component.translatable(CONFIG_TRANSLATION_PREFIX + key + ".tooltip");
|
||||
}
|
||||
|
||||
public static double getDamagePerLevel() {
|
||||
return Math.clamp(ConfigUtil.readDouble(DAMAGE_PER_LEVEL_PATH, DAMAGE_PER_LEVEL_DEFAULT), DAMAGE_PER_LEVEL_MIN, DAMAGE_PER_LEVEL_MAX);
|
||||
}
|
||||
|
||||
public static final ConfigListItem CONFIG_LIST_ITEM = new ConfigListItem(
|
||||
"demonic_flames",
|
||||
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/mob_effect/demonic_flames.png"),
|
||||
Component.translatable("effect.lzxnoneterraria.demonic_flames"),
|
||||
CONFIG_DATA
|
||||
);
|
||||
|
||||
public static final CircleParticleOptions PARTICLE = new CircleParticleOptions(0.075f, 20, new Vector3f(0.8f, 0.176f, 0.78f));
|
||||
|
||||
@Override
|
||||
@@ -31,7 +69,7 @@ public class DemonicFlamesEffect extends MobEffect {
|
||||
if(instance != null) {
|
||||
if(entity.tickCount % 4 == 0) {
|
||||
entity.invulnerableTime = 5;
|
||||
entity.hurt(entity.damageSources().magic(), (float) Config.demonicFlamesDamagePerLevel * (amplifier + 1));
|
||||
entity.hurt(entity.damageSources().magic(), (float) getDamagePerLevel() * (amplifier + 1));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
package com.lzxnone.terraria.effect;
|
||||
|
||||
import com.lzxnone.terraria.Config;
|
||||
import com.lzxnone.terraria.LzxnoneTerraria;
|
||||
import com.lzxnone.terraria.ModSounds;
|
||||
import com.lzxnone.terraria.item.weapon.melee.DevilsDevastation;
|
||||
import com.lzxnone.terraria.utils.SoundUtil;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.network.protocol.game.ClientboundRemoveMobEffectPacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundUpdateMobEffectPacket;
|
||||
@@ -26,7 +27,7 @@ public class EffectLogicHandler {
|
||||
currentEffect = instance.getEffect();
|
||||
}
|
||||
if(checkEffect(currentEffect)) {
|
||||
if(!entity.level().isClientSide() && entity.level() instanceof ServerLevel serverLevel) {
|
||||
if(entity.level() instanceof ServerLevel serverLevel) {
|
||||
serverLevel.getChunkSource().broadcast(entity,
|
||||
new ClientboundUpdateMobEffectPacket(entity.getId(), instance, false));
|
||||
}
|
||||
@@ -41,15 +42,17 @@ public class EffectLogicHandler {
|
||||
if(instance != null) {
|
||||
currentEffect = instance.getEffect();
|
||||
}
|
||||
if(checkEffect(currentEffect) && !entity.level().isClientSide()) {
|
||||
if(checkEffect(currentEffect)) {
|
||||
if(entity.level() instanceof ServerLevel serverLevel) {
|
||||
if(event.getEffectInstance() != null) {
|
||||
serverLevel.getChunkSource().broadcast(entity,
|
||||
new ClientboundRemoveMobEffectPacket(entity.getId(), currentEffect));
|
||||
}
|
||||
if(currentEffect == ModEffects.KILL_MODE) {
|
||||
MobEffectInstance effectInstance = new MobEffectInstance(ModEffects.KILL_MODE_COOLDOWN, Config.devilsDevastationKillModeCooldownTime, 0);
|
||||
MobEffectInstance effectInstance = new MobEffectInstance(ModEffects.KILL_MODE_COOLDOWN, DevilsDevastation.getKillModeCooldownTime(), 0);
|
||||
entity.addEffect(effectInstance);
|
||||
}else if(currentEffect == ModEffects.KILL_MODE_COOLDOWN) {
|
||||
SoundUtil.playServerSound(entity, ModSounds.DEMON_SWORD_KILL_MODE_OFF_COOLDOWN.get(), 0.5f, 1.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -63,15 +66,17 @@ public class EffectLogicHandler {
|
||||
if(instance != null) {
|
||||
currentEffect = instance.getEffect();
|
||||
}
|
||||
if(checkEffect(currentEffect) && !entity.level().isClientSide()) {
|
||||
if(checkEffect(currentEffect)) {
|
||||
if(entity.level() instanceof ServerLevel serverLevel) {
|
||||
if(event.getEffectInstance() != null) {
|
||||
serverLevel.getChunkSource().broadcast(entity,
|
||||
new ClientboundRemoveMobEffectPacket(entity.getId(), currentEffect));
|
||||
}
|
||||
if(currentEffect == ModEffects.KILL_MODE) {
|
||||
MobEffectInstance effectInstance = new MobEffectInstance(ModEffects.KILL_MODE_COOLDOWN, Config.devilsDevastationKillModeCooldownTime, 0);
|
||||
MobEffectInstance effectInstance = new MobEffectInstance(ModEffects.KILL_MODE_COOLDOWN, DevilsDevastation.getKillModeCooldownTime(), 0);
|
||||
entity.addEffect(effectInstance);
|
||||
}else if(currentEffect == ModEffects.KILL_MODE_COOLDOWN) {
|
||||
SoundUtil.playServerSound(entity, ModSounds.DEMON_SWORD_KILL_MODE_OFF_COOLDOWN.get(), 0.5f, 1.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -81,6 +86,7 @@ public class EffectLogicHandler {
|
||||
if(effect == null) return false;
|
||||
return
|
||||
effect == ModEffects.CONFUSED
|
||||
|| effect == ModEffects.KILL_MODE;
|
||||
|| effect == ModEffects.KILL_MODE
|
||||
|| effect == ModEffects.KILL_MODE_COOLDOWN;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.lzxnone.terraria.effect;
|
||||
|
||||
import com.lzxnone.terraria.Config;
|
||||
import com.lzxnone.terraria.item.ModItems;
|
||||
import com.lzxnone.terraria.item.weapon.melee.DevilsDevastation;
|
||||
import com.lzxnone.terraria.particle.CircleParticleOptions;
|
||||
@@ -44,7 +43,7 @@ public class KillModeEffect extends MobEffect {
|
||||
);
|
||||
}
|
||||
}else {
|
||||
MobEffectInstance effectInstance = new MobEffectInstance(ModEffects.KILL_MODE_COOLDOWN, Config.devilsDevastationKillModeCooldownTime, 0);
|
||||
MobEffectInstance effectInstance = new MobEffectInstance(ModEffects.KILL_MODE_COOLDOWN, DevilsDevastation.getKillModeCooldownTime(), 0);
|
||||
entity.addEffect(effectInstance);
|
||||
|
||||
MobEffectInstance effectInstance2 = entity.getEffect(ModEffects.KILL_MODE);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.lzxnone.terraria.entity.summon;
|
||||
|
||||
import com.lzxnone.terraria.Config;
|
||||
import com.lzxnone.terraria.item.weapon.melee.BeeKeeper;
|
||||
import com.lzxnone.terraria.utils.DamageUtil;
|
||||
import com.lzxnone.terraria.utils.MathUtil;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
@@ -124,10 +124,10 @@ public class BeeSummon extends Bee {
|
||||
if(owner == null) return false;
|
||||
boolean isHurt;
|
||||
if(owner instanceof Player player) {
|
||||
isHurt = DamageUtil.attack(player, target, (float) Config.beeKeeperBeeDamage);
|
||||
isHurt = DamageUtil.attack(player, target, (float) BeeKeeper.getBeeDamage());
|
||||
}else {
|
||||
DamageSource damageSource = this.damageSources().mobAttack(owner);
|
||||
isHurt = target.hurt(damageSource, (float) Config.beeKeeperBeeDamage);
|
||||
isHurt = target.hurt(damageSource, (float) BeeKeeper.getBeeDamage());
|
||||
}
|
||||
|
||||
if(isHurt) {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.lzxnone.terraria.event;
|
||||
|
||||
import com.lzxnone.terraria.Config;
|
||||
import com.lzxnone.terraria.LzxnoneTerraria;
|
||||
import com.lzxnone.terraria.ModKeyBindings;
|
||||
import com.lzxnone.terraria.effect.ModEffects;
|
||||
@@ -46,18 +45,18 @@ public class InputHandler {
|
||||
double deltaDist = mainHand.getOrDefault(DataComponents.CUSTOM_DATA, CustomData.EMPTY)
|
||||
.copyTag().getDouble("deltaDist");
|
||||
|
||||
double finalDelta = deltaDist + scrollDelta * Config.zenithMouseSpeed;
|
||||
double finalDelta = deltaDist + scrollDelta * Zenith.getMouseSpeed();
|
||||
|
||||
if(Config.zenithDistanceMode) {
|
||||
if(finalDelta > Config.zenithMaxRange) finalDelta = Config.zenithMaxRange;
|
||||
else if(finalDelta < -Config.zenithMaxRange) finalDelta = -Config.zenithMaxRange;
|
||||
if(Zenith.isDistanceMode()) {
|
||||
if(finalDelta > Zenith.getMaxRange()) finalDelta = Zenith.getMaxRange();
|
||||
else if(finalDelta < -Zenith.getMaxRange()) finalDelta = -Zenith.getMaxRange();
|
||||
}else {
|
||||
if(finalDelta > Config.zenithMaxRange) finalDelta = Config.zenithMaxRange;
|
||||
if(finalDelta > Zenith.getMaxRange()) finalDelta = Zenith.getMaxRange();
|
||||
else if(finalDelta < 0) finalDelta = 0;
|
||||
}
|
||||
|
||||
MutableComponent displayText = Component.empty();
|
||||
displayText.append(Component.literal(String.format("%s", Config.zenithDistanceMode ? "相对距离: " : "绝对距离: ")).withStyle(ChatFormatting.WHITE))
|
||||
displayText.append(Component.literal(String.format("%s", Zenith.isDistanceMode() ? "相对距离: " : "绝对距离: ")).withStyle(ChatFormatting.WHITE))
|
||||
.append(Component.literal(String.format("%.1f", finalDelta)).withStyle(ChatFormatting.GREEN, ChatFormatting.BOLD));
|
||||
player.displayClientMessage(displayText, true);
|
||||
|
||||
@@ -72,17 +71,17 @@ public class InputHandler {
|
||||
double deltaDist = mainHand.getOrDefault(DataComponents.CUSTOM_DATA, CustomData.EMPTY)
|
||||
.copyTag().getDouble("deltaDist");
|
||||
|
||||
double finalDelta = deltaDist + scrollDelta * Config.firstFractalScrollSpeed;
|
||||
double finalDelta = deltaDist + scrollDelta * FirstFractal.getScrollSpeed();
|
||||
|
||||
if(Config.firstFractalDistanceMode) {
|
||||
if(finalDelta > Config.firstFractalMaxRange) finalDelta = Config.firstFractalMaxRange;
|
||||
else if(finalDelta < -Config.firstFractalMaxRange) finalDelta = -Config.firstFractalMaxRange;
|
||||
if(FirstFractal.isDistanceMode()) {
|
||||
if(finalDelta > FirstFractal.getMaxRange()) finalDelta = FirstFractal.getMaxRange();
|
||||
else if(finalDelta < -FirstFractal.getMaxRange()) finalDelta = -FirstFractal.getMaxRange();
|
||||
}else {
|
||||
if(finalDelta > Config.firstFractalMaxRange) finalDelta = Config.firstFractalMaxRange;
|
||||
if(finalDelta > FirstFractal.getMaxRange()) finalDelta = FirstFractal.getMaxRange();
|
||||
else if(finalDelta < 0) finalDelta = 0;
|
||||
}
|
||||
MutableComponent displayText = Component.empty();
|
||||
displayText.append(Component.literal(String.format("%s", Config.firstFractalDistanceMode ? "相对距离: " : "绝对距离: ")).withStyle(ChatFormatting.WHITE))
|
||||
displayText.append(Component.literal(String.format("%s", FirstFractal.isDistanceMode() ? "相对距离: " : "绝对距离: ")).withStyle(ChatFormatting.WHITE))
|
||||
.append(Component.literal(String.format("%.1f", finalDelta)).withStyle(ChatFormatting.GREEN, ChatFormatting.BOLD));
|
||||
player.displayClientMessage(displayText, true);
|
||||
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
package com.lzxnone.terraria.item.weapon.melee;
|
||||
|
||||
import com.lzxnone.terraria.Config;
|
||||
import com.lzxnone.terraria.LzxnoneTerraria;
|
||||
import com.lzxnone.terraria.effect.ModEffects;
|
||||
import com.lzxnone.terraria.entity.ModEntities;
|
||||
import com.lzxnone.terraria.entity.summon.BeeSummon;
|
||||
import com.lzxnone.terraria.item.IItemWaveBehavior;
|
||||
import com.lzxnone.terraria.ui.config.ConfigFactory;
|
||||
import com.lzxnone.terraria.ui.config.ConfigListItem;
|
||||
import com.lzxnone.terraria.ui.config.ConfigUtil;
|
||||
import com.lzxnone.terraria.ui.config.IConfigData;
|
||||
import com.lzxnone.terraria.utils.FilterUtil;
|
||||
import com.lzxnone.terraria.utils.MathUtil;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.effect.MobEffectInstance;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
@@ -25,6 +29,23 @@ import net.minecraft.world.phys.Vec3;
|
||||
import net.neoforged.neoforge.event.entity.player.AttackEntityEvent;
|
||||
|
||||
public class BeeKeeper extends SwordItem {
|
||||
private static final String CONFIG_TRANSLATION_PREFIX = "lzxnoneterraria.configuration.";
|
||||
|
||||
public static final String MAX_BEES_PATH = "weapon.bee_keeper.max_bees";
|
||||
public static final int MAX_BEES_DEFAULT = 3;
|
||||
public static final int MAX_BEES_MIN = 0;
|
||||
public static final int MAX_BEES_MAX = 10;
|
||||
|
||||
public static final String CONFUSION_DURATION_PATH = "weapon.bee_keeper.confusion_duration";
|
||||
public static final int CONFUSION_DURATION_DEFAULT = 40;
|
||||
public static final int CONFUSION_DURATION_MIN = 0;
|
||||
public static final int CONFUSION_DURATION_MAX = 1200;
|
||||
|
||||
public static final String BEE_DAMAGE_PATH = "weapon.bee_keeper.bee_damage";
|
||||
public static final double BEE_DAMAGE_DEFAULT = 2.0;
|
||||
public static final double BEE_DAMAGE_MIN = 0.0;
|
||||
public static final double BEE_DAMAGE_MAX = 2147483647.0;
|
||||
|
||||
public BeeKeeper() {
|
||||
super(Tiers.IRON, new Item.Properties().attributes(ItemAttributeModifiers.builder()
|
||||
.add(Attributes.ATTACK_DAMAGE,
|
||||
@@ -37,6 +58,42 @@ public class BeeKeeper extends SwordItem {
|
||||
));
|
||||
}
|
||||
|
||||
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
||||
@Override
|
||||
public void onConfigLoad() {
|
||||
ConfigFactory.loadIntConfig(MAX_BEES_PATH, configText("bee_keeper_max_bees"), configTooltip("bee_keeper_max_bees"), MAX_BEES_DEFAULT, MAX_BEES_MIN, MAX_BEES_MAX);
|
||||
ConfigFactory.loadIntConfig(CONFUSION_DURATION_PATH, configText("bee_keeper_confusion_duration"), configTooltip("bee_keeper_confusion_duration"), CONFUSION_DURATION_DEFAULT, CONFUSION_DURATION_MIN, CONFUSION_DURATION_MAX);
|
||||
ConfigFactory.loadDoubleConfig(BEE_DAMAGE_PATH, configText("bee_keeper_bee_damage"), configTooltip("bee_keeper_bee_damage"), BEE_DAMAGE_DEFAULT, BEE_DAMAGE_MIN, BEE_DAMAGE_MAX);
|
||||
}
|
||||
};
|
||||
|
||||
private static Component configText(String key) {
|
||||
return Component.translatable(CONFIG_TRANSLATION_PREFIX + key);
|
||||
}
|
||||
|
||||
private static Component configTooltip(String key) {
|
||||
return Component.translatable(CONFIG_TRANSLATION_PREFIX + key + ".tooltip");
|
||||
}
|
||||
|
||||
public static int getMaxBees() {
|
||||
return Math.clamp(ConfigUtil.readInt(MAX_BEES_PATH, MAX_BEES_DEFAULT), MAX_BEES_MIN, MAX_BEES_MAX);
|
||||
}
|
||||
|
||||
public static int getConfusionDuration() {
|
||||
return Math.clamp(ConfigUtil.readInt(CONFUSION_DURATION_PATH, CONFUSION_DURATION_DEFAULT), CONFUSION_DURATION_MIN, CONFUSION_DURATION_MAX);
|
||||
}
|
||||
|
||||
public static double getBeeDamage() {
|
||||
return Math.clamp(ConfigUtil.readDouble(BEE_DAMAGE_PATH, BEE_DAMAGE_DEFAULT), BEE_DAMAGE_MIN, BEE_DAMAGE_MAX);
|
||||
}
|
||||
|
||||
public static final ConfigListItem CONFIG_LIST_ITEM = new ConfigListItem(
|
||||
"bee_keeper",
|
||||
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/item/bee_keeper.png"),
|
||||
Component.translatable("item.lzxnoneterraria.bee_keeper"),
|
||||
CONFIG_DATA
|
||||
);
|
||||
|
||||
public static final IItemWaveBehavior ITEM_WAVE_BEHAVIOR = new IItemWaveBehavior() {
|
||||
@Override
|
||||
public void onAttackEntity(AttackEntityEvent event) {
|
||||
@@ -50,12 +107,13 @@ public class BeeKeeper extends SwordItem {
|
||||
if(target instanceof LivingEntity livingTarget && FilterUtil.createLivingTargetFilter(player).test(livingTarget)) {
|
||||
livingTarget.addEffect(new MobEffectInstance(
|
||||
ModEffects.CONFUSED,
|
||||
Config.beeKeeperConfusionDuration,
|
||||
getConfusionDuration(),
|
||||
0
|
||||
));
|
||||
}
|
||||
|
||||
int count = Config.beeKeeperMaxBees > 0 ? player.level().random.nextInt(Config.beeKeeperMaxBees) + 1 : 0;
|
||||
int maxBees = getMaxBees();
|
||||
int count = maxBees > 0 ? player.level().random.nextInt(maxBees) + 1 : 0;
|
||||
while(count-- > 0) {
|
||||
BeeSummon bee = ModEntities.BEE_SUMMON.get().create(player.level());
|
||||
if(bee != null) {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.lzxnone.terraria.item.weapon.melee;
|
||||
|
||||
import com.lzxnone.terraria.Config;
|
||||
import com.lzxnone.terraria.LzxnoneTerraria;
|
||||
import com.lzxnone.terraria.ModSounds;
|
||||
import com.lzxnone.terraria.effect.ModEffects;
|
||||
@@ -50,11 +49,109 @@ import net.minecraft.world.phys.EntityHitResult;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.joml.Matrix4f;
|
||||
import org.joml.Vector3f;
|
||||
import com.lzxnone.terraria.ui.config.ConfigFactory;
|
||||
import com.lzxnone.terraria.ui.config.ConfigListItem;
|
||||
import com.lzxnone.terraria.ui.config.ConfigUtil;
|
||||
import com.lzxnone.terraria.ui.config.IConfigData;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
public class BladeOfGrass extends SwordItem {
|
||||
private static final String CONFIG_TRANSLATION_PREFIX = "lzxnoneterraria.configuration.";
|
||||
|
||||
public static final String PROJECTILE_DAMAGE_PATH = "weapon.blade_of_grass.projectile_damage";
|
||||
public static final double PROJECTILE_DAMAGE_DEFAULT = 2.0;
|
||||
public static final double PROJECTILE_DAMAGE_MIN = 0.0;
|
||||
public static final double PROJECTILE_DAMAGE_MAX = 2147483647.0;
|
||||
|
||||
public static final String EFFECT_DURATION_PATH = "weapon.blade_of_grass.effect_duration";
|
||||
public static final int EFFECT_DURATION_DEFAULT = 140;
|
||||
public static final int EFFECT_DURATION_MIN = 0;
|
||||
public static final int EFFECT_DURATION_MAX = 72000;
|
||||
|
||||
public static final String TARGET_RANGE_PATH = "weapon.blade_of_grass.target_range";
|
||||
public static final double TARGET_RANGE_DEFAULT = 8.0;
|
||||
public static final double TARGET_RANGE_MIN = 1.0;
|
||||
public static final double TARGET_RANGE_MAX = 64.0;
|
||||
|
||||
public static final String PROJECTILE_LIFETIME_PATH = "weapon.blade_of_grass.projectile_lifetime";
|
||||
public static final int PROJECTILE_LIFETIME_DEFAULT = 60;
|
||||
public static final int PROJECTILE_LIFETIME_MIN = 1;
|
||||
public static final int PROJECTILE_LIFETIME_MAX = 600;
|
||||
|
||||
public static final String PROJECTILE_MAX_HIT_COUNT_PATH = "weapon.blade_of_grass.projectile_max_hit_count";
|
||||
public static final int PROJECTILE_MAX_HIT_COUNT_DEFAULT = 2;
|
||||
public static final int PROJECTILE_MAX_HIT_COUNT_MIN = 0;
|
||||
public static final int PROJECTILE_MAX_HIT_COUNT_MAX = 100;
|
||||
|
||||
public static final String RADIUS_GROWTH_PATH = "weapon.blade_of_grass.radius_growth";
|
||||
public static final double RADIUS_GROWTH_DEFAULT = 0.05;
|
||||
public static final double RADIUS_GROWTH_MIN = 0.0;
|
||||
public static final double RADIUS_GROWTH_MAX = 1.0;
|
||||
|
||||
public static final String ROTATION_SPEED_PATH = "weapon.blade_of_grass.rotation_speed";
|
||||
public static final double ROTATION_SPEED_DEFAULT = 0.2;
|
||||
public static final double ROTATION_SPEED_MIN = 0.0;
|
||||
public static final double ROTATION_SPEED_MAX = 1.0;
|
||||
|
||||
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
||||
@Override
|
||||
public void onConfigLoad() {
|
||||
ConfigFactory.loadDoubleConfig(PROJECTILE_DAMAGE_PATH, configText("blade_of_grass_projectile_damage"), configTooltip("blade_of_grass_projectile_damage"), PROJECTILE_DAMAGE_DEFAULT, PROJECTILE_DAMAGE_MIN, PROJECTILE_DAMAGE_MAX);
|
||||
ConfigFactory.loadIntConfig(EFFECT_DURATION_PATH, configText("blade_of_grass_effect_duration"), configTooltip("blade_of_grass_effect_duration"), EFFECT_DURATION_DEFAULT, EFFECT_DURATION_MIN, EFFECT_DURATION_MAX);
|
||||
ConfigFactory.loadDoubleConfig(TARGET_RANGE_PATH, configText("blade_of_grass_target_range"), configTooltip("blade_of_grass_target_range"), TARGET_RANGE_DEFAULT, TARGET_RANGE_MIN, TARGET_RANGE_MAX);
|
||||
ConfigFactory.loadIntConfig(PROJECTILE_LIFETIME_PATH, configText("blade_of_grass_projectile_lifetime"), configTooltip("blade_of_grass_projectile_lifetime"), PROJECTILE_LIFETIME_DEFAULT, PROJECTILE_LIFETIME_MIN, PROJECTILE_LIFETIME_MAX);
|
||||
ConfigFactory.loadIntConfig(PROJECTILE_MAX_HIT_COUNT_PATH, configText("blade_of_grass_projectile_max_hit_count"), configTooltip("blade_of_grass_projectile_max_hit_count"), PROJECTILE_MAX_HIT_COUNT_DEFAULT, PROJECTILE_MAX_HIT_COUNT_MIN, PROJECTILE_MAX_HIT_COUNT_MAX);
|
||||
ConfigFactory.loadDoubleConfig(RADIUS_GROWTH_PATH, configText("blade_of_grass_radius_growth"), configTooltip("blade_of_grass_radius_growth"), RADIUS_GROWTH_DEFAULT, RADIUS_GROWTH_MIN, RADIUS_GROWTH_MAX);
|
||||
ConfigFactory.loadDoubleConfig(ROTATION_SPEED_PATH, configText("blade_of_grass_rotation_speed"), configTooltip("blade_of_grass_rotation_speed"), ROTATION_SPEED_DEFAULT, ROTATION_SPEED_MIN, ROTATION_SPEED_MAX);
|
||||
}
|
||||
};
|
||||
|
||||
private static Component configText(String key) {
|
||||
return Component.translatable(CONFIG_TRANSLATION_PREFIX + key);
|
||||
}
|
||||
|
||||
private static Component configTooltip(String key) {
|
||||
return Component.translatable(CONFIG_TRANSLATION_PREFIX + key + ".tooltip");
|
||||
}
|
||||
|
||||
public static double getProjectileDamage() {
|
||||
return Math.clamp(ConfigUtil.readDouble(PROJECTILE_DAMAGE_PATH, PROJECTILE_DAMAGE_DEFAULT), PROJECTILE_DAMAGE_MIN, PROJECTILE_DAMAGE_MAX);
|
||||
}
|
||||
|
||||
public static int getEffectDuration() {
|
||||
return Math.clamp(ConfigUtil.readInt(EFFECT_DURATION_PATH, EFFECT_DURATION_DEFAULT), EFFECT_DURATION_MIN, EFFECT_DURATION_MAX);
|
||||
}
|
||||
|
||||
public static double getTargetRange() {
|
||||
return Math.clamp(ConfigUtil.readDouble(TARGET_RANGE_PATH, TARGET_RANGE_DEFAULT), TARGET_RANGE_MIN, TARGET_RANGE_MAX);
|
||||
}
|
||||
|
||||
public static int getProjectileLifetime() {
|
||||
return Math.clamp(ConfigUtil.readInt(PROJECTILE_LIFETIME_PATH, PROJECTILE_LIFETIME_DEFAULT), PROJECTILE_LIFETIME_MIN, PROJECTILE_LIFETIME_MAX);
|
||||
}
|
||||
|
||||
public static int getProjectileMaxHitCount() {
|
||||
return Math.clamp(ConfigUtil.readInt(PROJECTILE_MAX_HIT_COUNT_PATH, PROJECTILE_MAX_HIT_COUNT_DEFAULT), PROJECTILE_MAX_HIT_COUNT_MIN, PROJECTILE_MAX_HIT_COUNT_MAX);
|
||||
}
|
||||
|
||||
public static double getRadiusGrowth() {
|
||||
return Math.clamp(ConfigUtil.readDouble(RADIUS_GROWTH_PATH, RADIUS_GROWTH_DEFAULT), RADIUS_GROWTH_MIN, RADIUS_GROWTH_MAX);
|
||||
}
|
||||
|
||||
public static double getRotationSpeed() {
|
||||
return Math.clamp(ConfigUtil.readDouble(ROTATION_SPEED_PATH, ROTATION_SPEED_DEFAULT), ROTATION_SPEED_MIN, ROTATION_SPEED_MAX);
|
||||
}
|
||||
|
||||
public static final ConfigListItem CONFIG_LIST_ITEM = new ConfigListItem(
|
||||
"blade_of_grass",
|
||||
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/item/blade_of_grass.png"),
|
||||
Component.translatable("item.lzxnoneterraria.blade_of_grass"),
|
||||
CONFIG_DATA
|
||||
);
|
||||
|
||||
public BladeOfGrass() {
|
||||
super(Tiers.IRON, new Item.Properties().attributes(ItemAttributeModifiers.builder()
|
||||
.add(Attributes.ATTACK_DAMAGE,
|
||||
@@ -144,19 +241,19 @@ public class BladeOfGrass extends SwordItem {
|
||||
Entity owner = projectile.getOwner();
|
||||
if(owner == null) return;
|
||||
CompoundTag customData = projectile.getEntityData().get(StaticProjectile.CUSTOM_DATA);
|
||||
if(!customData.contains("hitCount") || customData.getInt("hitCount") >= Config.bladeOfGrassProjectileMaxHitCount) return;
|
||||
if(!customData.contains("hitCount") || customData.getInt("hitCount") >= getProjectileMaxHitCount()) return;
|
||||
if(!FilterUtil.createTargetFilter(owner).test(target) || !(owner instanceof Player player)) return;
|
||||
if(DamageUtil.attack(player, target, (float) Config.bladeOfGrassProjectileDamage)) {
|
||||
if(DamageUtil.attack(player, target, (float) getProjectileDamage())) {
|
||||
int count = customData.getInt("hitCount");
|
||||
count++;
|
||||
if(target instanceof LivingEntity livingEntity && projectile.getRandom().nextInt(4) == 0) {
|
||||
livingEntity.addEffect(new MobEffectInstance(
|
||||
MobEffects.POISON,
|
||||
Config.bladeOfGrassEffectDuration,
|
||||
getEffectDuration(),
|
||||
0
|
||||
));
|
||||
}
|
||||
if(count >= Config.bladeOfGrassProjectileMaxHitCount) onDied(projectile);
|
||||
if(count >= getProjectileMaxHitCount()) onDied(projectile);
|
||||
else customData.putInt("hitCount", count);
|
||||
}
|
||||
}
|
||||
@@ -182,7 +279,7 @@ public class BladeOfGrass extends SwordItem {
|
||||
if(!level.isClientSide()) {
|
||||
List<Monster> targets = player.level().getEntitiesOfClass(
|
||||
Monster.class,
|
||||
AABB.ofSize(player.getBoundingBox().getCenter(), Config.bladeOfGrassTargetRange * 2, Config.bladeOfGrassTargetRange * 2, Config.bladeOfGrassTargetRange * 2),
|
||||
AABB.ofSize(player.getBoundingBox().getCenter(), getTargetRange() * 2, getTargetRange() * 2, getTargetRange() * 2),
|
||||
FilterUtil.createMonsterFilter(player)
|
||||
);
|
||||
targets.sort(Comparator.comparingDouble(e -> e.distanceToSqr(player.position())));
|
||||
@@ -217,9 +314,9 @@ public class BladeOfGrass extends SwordItem {
|
||||
projectile.getEntityData().set(StaticProjectile.RXP, -90);
|
||||
projectile.getEntityData().set(StaticProjectile.RZP, -90);
|
||||
projectile.getEntityData().set(StaticProjectile.RYPS, 10);
|
||||
projectile.getEntityData().set(StaticProjectile.LIFETIME, Config.bladeOfGrassProjectileLifetime);
|
||||
projectile.getEntityData().set(StaticProjectile.EXPRESSION_Z, String.format("(%.3f+%.3f*t)*cos(%.3f*t+%.3f)", radius, Config.bladeOfGrassRadiusGrowth, Config.bladeOfGrassRotationSpeed, angleRad));
|
||||
projectile.getEntityData().set(StaticProjectile.EXPRESSION_Y, String.format("(%.3f+%.3f*t)*sin(%.3f*t+%.3f)", radius, Config.bladeOfGrassRadiusGrowth, Config.bladeOfGrassRotationSpeed, angleRad));
|
||||
projectile.getEntityData().set(StaticProjectile.LIFETIME, getProjectileLifetime());
|
||||
projectile.getEntityData().set(StaticProjectile.EXPRESSION_Z, String.format("(%.3f+%.3f*t)*cos(%.3f*t+%.3f)", radius, getRadiusGrowth(), getRotationSpeed(), angleRad));
|
||||
projectile.getEntityData().set(StaticProjectile.EXPRESSION_Y, String.format("(%.3f+%.3f*t)*sin(%.3f*t+%.3f)", radius, getRadiusGrowth(), getRotationSpeed(), angleRad));
|
||||
|
||||
CompoundTag customData = new CompoundTag();
|
||||
customData.putInt("hitCount", 0);
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
package com.lzxnone.terraria.item.weapon.melee;
|
||||
|
||||
import com.lzxnone.terraria.Config;
|
||||
import com.lzxnone.terraria.LzxnoneTerraria;
|
||||
import com.lzxnone.terraria.effect.ModEffects;
|
||||
import com.lzxnone.terraria.item.IItemWaveBehavior;
|
||||
import com.lzxnone.terraria.particle.ModParticles;
|
||||
import com.lzxnone.terraria.ui.config.ConfigFactory;
|
||||
import com.lzxnone.terraria.ui.config.ConfigListItem;
|
||||
import com.lzxnone.terraria.ui.config.ConfigUtil;
|
||||
import com.lzxnone.terraria.ui.config.IConfigData;
|
||||
import com.lzxnone.terraria.utils.FilterUtil;
|
||||
import com.lzxnone.terraria.utils.ParticleUtil;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.effect.MobEffectInstance;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
@@ -25,6 +29,18 @@ import net.neoforged.neoforge.event.entity.player.AttackEntityEvent;
|
||||
import net.neoforged.neoforge.event.entity.player.PlayerInteractEvent;
|
||||
|
||||
public class BloodButcherer extends SwordItem {
|
||||
private static final String CONFIG_TRANSLATION_PREFIX = "lzxnoneterraria.configuration.";
|
||||
|
||||
public static final String EFFECT_DURATION_PATH = "weapon.blood_butcherer.effect_duration";
|
||||
public static final int EFFECT_DURATION_DEFAULT = 180;
|
||||
public static final int EFFECT_DURATION_MIN = 0;
|
||||
public static final int EFFECT_DURATION_MAX = 72000;
|
||||
|
||||
public static final String MAX_LEVEL_PATH = "weapon.blood_butcherer.max_level";
|
||||
public static final int MAX_LEVEL_DEFAULT = 4;
|
||||
public static final int MAX_LEVEL_MIN = 0;
|
||||
public static final int MAX_LEVEL_MAX = 255;
|
||||
|
||||
public BloodButcherer() {
|
||||
super(Tiers.IRON, new Item.Properties().attributes(ItemAttributeModifiers.builder()
|
||||
.add(Attributes.ATTACK_DAMAGE,
|
||||
@@ -37,6 +53,37 @@ public class BloodButcherer extends SwordItem {
|
||||
));
|
||||
}
|
||||
|
||||
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
||||
@Override
|
||||
public void onConfigLoad() {
|
||||
ConfigFactory.loadIntConfig(EFFECT_DURATION_PATH, configText("blood_butcherer_effect_duration"), configTooltip("blood_butcherer_effect_duration"), EFFECT_DURATION_DEFAULT, EFFECT_DURATION_MIN, EFFECT_DURATION_MAX);
|
||||
ConfigFactory.loadIntConfig(MAX_LEVEL_PATH, configText("blood_butcherer_max_level"), configTooltip("blood_butcherer_max_level"), MAX_LEVEL_DEFAULT, MAX_LEVEL_MIN, MAX_LEVEL_MAX);
|
||||
}
|
||||
};
|
||||
|
||||
private static Component configText(String key) {
|
||||
return Component.translatable(CONFIG_TRANSLATION_PREFIX + key);
|
||||
}
|
||||
|
||||
private static Component configTooltip(String key) {
|
||||
return Component.translatable(CONFIG_TRANSLATION_PREFIX + key + ".tooltip");
|
||||
}
|
||||
|
||||
public static int getEffectDuration() {
|
||||
return Math.clamp(ConfigUtil.readInt(EFFECT_DURATION_PATH, EFFECT_DURATION_DEFAULT), EFFECT_DURATION_MIN, EFFECT_DURATION_MAX);
|
||||
}
|
||||
|
||||
public static int getMaxLevel() {
|
||||
return Math.clamp(ConfigUtil.readInt(MAX_LEVEL_PATH, MAX_LEVEL_DEFAULT), MAX_LEVEL_MIN, MAX_LEVEL_MAX);
|
||||
}
|
||||
|
||||
public static final ConfigListItem CONFIG_LIST_ITEM = new ConfigListItem(
|
||||
"blood_butcherer",
|
||||
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/item/blood_butcherer.png"),
|
||||
Component.translatable("item.lzxnoneterraria.blood_butcherer"),
|
||||
CONFIG_DATA
|
||||
);
|
||||
|
||||
public static final IItemWaveBehavior ITEM_WAVE_BEHAVIOR = new IItemWaveBehavior() {
|
||||
@Override
|
||||
public void onLeftClickAir(PlayerInteractEvent.LeftClickEmpty event) {
|
||||
@@ -92,12 +139,15 @@ public class BloodButcherer extends SwordItem {
|
||||
currentLevel = instance.getAmplifier();
|
||||
}
|
||||
}
|
||||
if(currentLevel >= Config.bloodButchererMaxLevel) currentLevel = Config.bloodButchererMaxLevel - 1;
|
||||
livingTarget.addEffect(new MobEffectInstance(
|
||||
ModEffects.BLOOD_BUTCHERED,
|
||||
Config.bloodButchererEffectDuration,
|
||||
currentLevel + 1
|
||||
));
|
||||
int maxLevel = getMaxLevel();
|
||||
if(maxLevel > 0) {
|
||||
if(currentLevel >= maxLevel) currentLevel = maxLevel - 1;
|
||||
livingTarget.addEffect(new MobEffectInstance(
|
||||
ModEffects.BLOOD_BUTCHERED,
|
||||
getEffectDuration(),
|
||||
currentLevel + 1
|
||||
));
|
||||
}
|
||||
}
|
||||
player.getCooldowns().addCooldown(item, 7);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.lzxnone.terraria.item.weapon.melee;
|
||||
|
||||
import com.lzxnone.terraria.Config;
|
||||
import com.lzxnone.terraria.LzxnoneTerraria;
|
||||
import com.lzxnone.terraria.ModSounds;
|
||||
import com.lzxnone.terraria.attachment.ModAttachments;
|
||||
@@ -57,12 +56,209 @@ import org.joml.Matrix4f;
|
||||
import org.joml.Quaternionf;
|
||||
import org.joml.Vector3f;
|
||||
import net.minecraft.client.Camera;
|
||||
import com.lzxnone.terraria.ui.config.ConfigFactory;
|
||||
import com.lzxnone.terraria.ui.config.ConfigListItem;
|
||||
import com.lzxnone.terraria.ui.config.ConfigUtil;
|
||||
import com.lzxnone.terraria.ui.config.IConfigData;
|
||||
|
||||
|
||||
import java.util.*;
|
||||
|
||||
|
||||
public class DevilsDevastation extends SwordItem {
|
||||
private static final String CONFIG_TRANSLATION_PREFIX = "lzxnoneterraria.configuration.";
|
||||
|
||||
public static final String KILL_MODE_TIME_PATH = "weapon.devils_devastation.kill_mode_time";
|
||||
public static final int KILL_MODE_TIME_DEFAULT = 100;
|
||||
public static final int KILL_MODE_TIME_MIN = 0;
|
||||
public static final int KILL_MODE_TIME_MAX = 72000;
|
||||
|
||||
public static final String KILL_MODE_COOLDOWN_TIME_PATH = "weapon.devils_devastation.kill_mode_cooldown_time";
|
||||
public static final int KILL_MODE_COOLDOWN_TIME_DEFAULT = 100;
|
||||
public static final int KILL_MODE_COOLDOWN_TIME_MIN = 0;
|
||||
public static final int KILL_MODE_COOLDOWN_TIME_MAX = 72000;
|
||||
|
||||
public static final String PROJECTILE_DAMAGE_PATH = "weapon.devils_devastation.projectile_damage";
|
||||
public static final double PROJECTILE_DAMAGE_DEFAULT = 30.0;
|
||||
public static final double PROJECTILE_DAMAGE_MIN = 0.0;
|
||||
public static final double PROJECTILE_DAMAGE_MAX = 2147483647.0;
|
||||
|
||||
public static final String PROJECTILE_LIFETIME_PATH = "weapon.devils_devastation.projectile_lifetime";
|
||||
public static final int PROJECTILE_LIFETIME_DEFAULT = 40;
|
||||
public static final int PROJECTILE_LIFETIME_MIN = 1;
|
||||
public static final int PROJECTILE_LIFETIME_MAX = 1200;
|
||||
|
||||
public static final String PROJECTILE_SPEED_PATH = "weapon.devils_devastation.projectile_speed";
|
||||
public static final double PROJECTILE_SPEED_DEFAULT = 3.0;
|
||||
public static final double PROJECTILE_SPEED_MIN = 0.0;
|
||||
public static final double PROJECTILE_SPEED_MAX = 10.0;
|
||||
|
||||
public static final String STUCK_PROJECTILE_DAMAGE_PATH = "weapon.devils_devastation.stuck_projectile_damage";
|
||||
public static final double STUCK_PROJECTILE_DAMAGE_DEFAULT = 30.0;
|
||||
public static final double STUCK_PROJECTILE_DAMAGE_MIN = 0.0;
|
||||
public static final double STUCK_PROJECTILE_DAMAGE_MAX = 2147483647.0;
|
||||
|
||||
public static final String STUCK_PROJECTILE_LIFETIME_PATH = "weapon.devils_devastation.stuck_projectile_lifetime";
|
||||
public static final int STUCK_PROJECTILE_LIFETIME_DEFAULT = 40;
|
||||
public static final int STUCK_PROJECTILE_LIFETIME_MIN = 1;
|
||||
public static final int STUCK_PROJECTILE_LIFETIME_MAX = 1200;
|
||||
|
||||
public static final String STUCK_PROJECTILE_SPEED_PATH = "weapon.devils_devastation.stuck_projectile_speed";
|
||||
public static final double STUCK_PROJECTILE_SPEED_DEFAULT = 3.0;
|
||||
public static final double STUCK_PROJECTILE_SPEED_MIN = 0.0;
|
||||
public static final double STUCK_PROJECTILE_SPEED_MAX = 10.0;
|
||||
|
||||
public static final String KILL_MODE_PROJECTILE_CYCLE_PATH = "weapon.devils_devastation.kill_mode_projectile_cycle";
|
||||
public static final int KILL_MODE_PROJECTILE_CYCLE_DEFAULT = 10;
|
||||
public static final int KILL_MODE_PROJECTILE_CYCLE_MIN = 1;
|
||||
public static final int KILL_MODE_PROJECTILE_CYCLE_MAX = 200;
|
||||
|
||||
public static final String KILL_MODE_PROJECTILE_DAMAGE_PATH = "weapon.devils_devastation.kill_mode_projectile_damage";
|
||||
public static final double KILL_MODE_PROJECTILE_DAMAGE_DEFAULT = 200.0;
|
||||
public static final double KILL_MODE_PROJECTILE_DAMAGE_MIN = 0.0;
|
||||
public static final double KILL_MODE_PROJECTILE_DAMAGE_MAX = 2147483647.0;
|
||||
|
||||
public static final String KILL_MODE_PROJECTILE_ROTATE_PATH = "weapon.devils_devastation.kill_mode_projectile_rotate";
|
||||
public static final int KILL_MODE_PROJECTILE_ROTATE_DEFAULT = 30;
|
||||
public static final int KILL_MODE_PROJECTILE_ROTATE_MIN = 0;
|
||||
public static final int KILL_MODE_PROJECTILE_ROTATE_MAX = 360;
|
||||
|
||||
public static final String STUCK_LIFETIME_PATH = "weapon.devils_devastation.stuck_lifetime";
|
||||
public static final int STUCK_LIFETIME_DEFAULT = 200;
|
||||
public static final int STUCK_LIFETIME_MIN = 1;
|
||||
public static final int STUCK_LIFETIME_MAX = 72000;
|
||||
|
||||
public static final String MAX_STUCK_COUNT_PATH = "weapon.devils_devastation.max_stuck_count";
|
||||
public static final int MAX_STUCK_COUNT_DEFAULT = 5;
|
||||
public static final int MAX_STUCK_COUNT_MIN = 1;
|
||||
public static final int MAX_STUCK_COUNT_MAX = 50;
|
||||
|
||||
public static final String MARK_LIGHTNING_DAMAGE_PATH = "weapon.devils_devastation.mark_lightning_damage";
|
||||
public static final double MARK_LIGHTNING_DAMAGE_DEFAULT = 100.0;
|
||||
public static final double MARK_LIGHTNING_DAMAGE_MIN = 0.0;
|
||||
public static final double MARK_LIGHTNING_DAMAGE_MAX = 2147483647.0;
|
||||
|
||||
public static final String PROJECTILE_EFFECT_DURATION_PATH = "weapon.devils_devastation.projectile_effect_duration";
|
||||
public static final int PROJECTILE_EFFECT_DURATION_DEFAULT = 40;
|
||||
public static final int PROJECTILE_EFFECT_DURATION_MIN = 0;
|
||||
public static final int PROJECTILE_EFFECT_DURATION_MAX = 72000;
|
||||
|
||||
public static final String STUCK_PROJECTILE_EFFECT_DURATION_PATH = "weapon.devils_devastation.stuck_projectile_effect_duration";
|
||||
public static final int STUCK_PROJECTILE_EFFECT_DURATION_DEFAULT = 60;
|
||||
public static final int STUCK_PROJECTILE_EFFECT_DURATION_MIN = 0;
|
||||
public static final int STUCK_PROJECTILE_EFFECT_DURATION_MAX = 72000;
|
||||
|
||||
public static final String KILL_MODE_PROJECTILE_EFFECT_DURATION_PATH = "weapon.devils_devastation.kill_mode_projectile_effect_duration";
|
||||
public static final int KILL_MODE_PROJECTILE_EFFECT_DURATION_DEFAULT = 70;
|
||||
public static final int KILL_MODE_PROJECTILE_EFFECT_DURATION_MIN = 0;
|
||||
public static final int KILL_MODE_PROJECTILE_EFFECT_DURATION_MAX = 72000;
|
||||
|
||||
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
||||
@Override
|
||||
public void onConfigLoad() {
|
||||
ConfigFactory.loadIntConfig(KILL_MODE_TIME_PATH, configText("devils_devastation_kill_mode_time"), configTooltip("devils_devastation_kill_mode_time"), KILL_MODE_TIME_DEFAULT, KILL_MODE_TIME_MIN, KILL_MODE_TIME_MAX);
|
||||
ConfigFactory.loadIntConfig(KILL_MODE_COOLDOWN_TIME_PATH, configText("devils_devastation_kill_mode_cooldown_time"), configTooltip("devils_devastation_kill_mode_cooldown_time"), KILL_MODE_COOLDOWN_TIME_DEFAULT, KILL_MODE_COOLDOWN_TIME_MIN, KILL_MODE_COOLDOWN_TIME_MAX);
|
||||
ConfigFactory.loadDoubleConfig(PROJECTILE_DAMAGE_PATH, configText("devils_devastation_projectile_damage"), configTooltip("devils_devastation_projectile_damage"), PROJECTILE_DAMAGE_DEFAULT, PROJECTILE_DAMAGE_MIN, PROJECTILE_DAMAGE_MAX);
|
||||
ConfigFactory.loadIntConfig(PROJECTILE_LIFETIME_PATH, configText("devils_devastation_projectile_lifetime"), configTooltip("devils_devastation_projectile_lifetime"), PROJECTILE_LIFETIME_DEFAULT, PROJECTILE_LIFETIME_MIN, PROJECTILE_LIFETIME_MAX);
|
||||
ConfigFactory.loadDoubleConfig(PROJECTILE_SPEED_PATH, configText("devils_devastation_projectile_speed"), configTooltip("devils_devastation_projectile_speed"), PROJECTILE_SPEED_DEFAULT, PROJECTILE_SPEED_MIN, PROJECTILE_SPEED_MAX);
|
||||
ConfigFactory.loadDoubleConfig(STUCK_PROJECTILE_DAMAGE_PATH, configText("devils_devastation_stuck_projectile_damage"), configTooltip("devils_devastation_stuck_projectile_damage"), STUCK_PROJECTILE_DAMAGE_DEFAULT, STUCK_PROJECTILE_DAMAGE_MIN, STUCK_PROJECTILE_DAMAGE_MAX);
|
||||
ConfigFactory.loadIntConfig(STUCK_PROJECTILE_LIFETIME_PATH, configText("devils_devastation_stuck_projectile_lifetime"), configTooltip("devils_devastation_stuck_projectile_lifetime"), STUCK_PROJECTILE_LIFETIME_DEFAULT, STUCK_PROJECTILE_LIFETIME_MIN, STUCK_PROJECTILE_LIFETIME_MAX);
|
||||
ConfigFactory.loadDoubleConfig(STUCK_PROJECTILE_SPEED_PATH, configText("devils_devastation_stuck_projectile_speed"), configTooltip("devils_devastation_stuck_projectile_speed"), STUCK_PROJECTILE_SPEED_DEFAULT, STUCK_PROJECTILE_SPEED_MIN, STUCK_PROJECTILE_SPEED_MAX);
|
||||
ConfigFactory.loadIntConfig(KILL_MODE_PROJECTILE_CYCLE_PATH, configText("devils_devastation_kill_mode_projectile_cycle"), configTooltip("devils_devastation_kill_mode_projectile_cycle"), KILL_MODE_PROJECTILE_CYCLE_DEFAULT, KILL_MODE_PROJECTILE_CYCLE_MIN, KILL_MODE_PROJECTILE_CYCLE_MAX);
|
||||
ConfigFactory.loadDoubleConfig(KILL_MODE_PROJECTILE_DAMAGE_PATH, configText("devils_devastation_kill_mode_projectile_damage"), configTooltip("devils_devastation_kill_mode_projectile_damage"), KILL_MODE_PROJECTILE_DAMAGE_DEFAULT, KILL_MODE_PROJECTILE_DAMAGE_MIN, KILL_MODE_PROJECTILE_DAMAGE_MAX);
|
||||
ConfigFactory.loadIntConfig(KILL_MODE_PROJECTILE_ROTATE_PATH, configText("devils_devastation_kill_mode_projectile_rotate"), configTooltip("devils_devastation_kill_mode_projectile_rotate"), KILL_MODE_PROJECTILE_ROTATE_DEFAULT, KILL_MODE_PROJECTILE_ROTATE_MIN, KILL_MODE_PROJECTILE_ROTATE_MAX);
|
||||
ConfigFactory.loadIntConfig(STUCK_LIFETIME_PATH, configText("devils_devastation_stuck_lifetime"), configTooltip("devils_devastation_stuck_lifetime"), STUCK_LIFETIME_DEFAULT, STUCK_LIFETIME_MIN, STUCK_LIFETIME_MAX);
|
||||
ConfigFactory.loadIntConfig(MAX_STUCK_COUNT_PATH, configText("devils_devastation_max_stuck_count"), configTooltip("devils_devastation_max_stuck_count"), MAX_STUCK_COUNT_DEFAULT, MAX_STUCK_COUNT_MIN, MAX_STUCK_COUNT_MAX);
|
||||
ConfigFactory.loadDoubleConfig(MARK_LIGHTNING_DAMAGE_PATH, configText("devils_devastation_mark_lightning_damage"), configTooltip("devils_devastation_mark_lightning_damage"), MARK_LIGHTNING_DAMAGE_DEFAULT, MARK_LIGHTNING_DAMAGE_MIN, MARK_LIGHTNING_DAMAGE_MAX);
|
||||
ConfigFactory.loadIntConfig(PROJECTILE_EFFECT_DURATION_PATH, configText("devils_devastation_projectile_effect_duration"), configTooltip("devils_devastation_projectile_effect_duration"), PROJECTILE_EFFECT_DURATION_DEFAULT, PROJECTILE_EFFECT_DURATION_MIN, PROJECTILE_EFFECT_DURATION_MAX);
|
||||
ConfigFactory.loadIntConfig(STUCK_PROJECTILE_EFFECT_DURATION_PATH, configText("devils_devastation_stuck_projectile_effect_duration"), configTooltip("devils_devastation_stuck_projectile_effect_duration"), STUCK_PROJECTILE_EFFECT_DURATION_DEFAULT, STUCK_PROJECTILE_EFFECT_DURATION_MIN, STUCK_PROJECTILE_EFFECT_DURATION_MAX);
|
||||
ConfigFactory.loadIntConfig(KILL_MODE_PROJECTILE_EFFECT_DURATION_PATH, configText("devils_devastation_kill_mode_projectile_effect_duration"), configTooltip("devils_devastation_kill_mode_projectile_effect_duration"), KILL_MODE_PROJECTILE_EFFECT_DURATION_DEFAULT, KILL_MODE_PROJECTILE_EFFECT_DURATION_MIN, KILL_MODE_PROJECTILE_EFFECT_DURATION_MAX);
|
||||
}
|
||||
};
|
||||
|
||||
private static Component configText(String key) {
|
||||
return Component.translatable(CONFIG_TRANSLATION_PREFIX + key);
|
||||
}
|
||||
|
||||
private static Component configTooltip(String key) {
|
||||
return Component.translatable(CONFIG_TRANSLATION_PREFIX + key + ".tooltip");
|
||||
}
|
||||
|
||||
public static int getKillModeTime() {
|
||||
return Math.clamp(ConfigUtil.readInt(KILL_MODE_TIME_PATH, KILL_MODE_TIME_DEFAULT), KILL_MODE_TIME_MIN, KILL_MODE_TIME_MAX);
|
||||
}
|
||||
|
||||
public static int getKillModeCooldownTime() {
|
||||
return Math.clamp(ConfigUtil.readInt(KILL_MODE_COOLDOWN_TIME_PATH, KILL_MODE_COOLDOWN_TIME_DEFAULT), KILL_MODE_COOLDOWN_TIME_MIN, KILL_MODE_COOLDOWN_TIME_MAX);
|
||||
}
|
||||
|
||||
public static double getProjectileDamage() {
|
||||
return Math.clamp(ConfigUtil.readDouble(PROJECTILE_DAMAGE_PATH, PROJECTILE_DAMAGE_DEFAULT), PROJECTILE_DAMAGE_MIN, PROJECTILE_DAMAGE_MAX);
|
||||
}
|
||||
|
||||
public static int getProjectileLifetime() {
|
||||
return Math.clamp(ConfigUtil.readInt(PROJECTILE_LIFETIME_PATH, PROJECTILE_LIFETIME_DEFAULT), PROJECTILE_LIFETIME_MIN, PROJECTILE_LIFETIME_MAX);
|
||||
}
|
||||
|
||||
public static double getProjectileSpeed() {
|
||||
return Math.clamp(ConfigUtil.readDouble(PROJECTILE_SPEED_PATH, PROJECTILE_SPEED_DEFAULT), PROJECTILE_SPEED_MIN, PROJECTILE_SPEED_MAX);
|
||||
}
|
||||
|
||||
public static double getStuckProjectileDamage() {
|
||||
return Math.clamp(ConfigUtil.readDouble(STUCK_PROJECTILE_DAMAGE_PATH, STUCK_PROJECTILE_DAMAGE_DEFAULT), STUCK_PROJECTILE_DAMAGE_MIN, STUCK_PROJECTILE_DAMAGE_MAX);
|
||||
}
|
||||
|
||||
public static int getStuckProjectileLifetime() {
|
||||
return Math.clamp(ConfigUtil.readInt(STUCK_PROJECTILE_LIFETIME_PATH, STUCK_PROJECTILE_LIFETIME_DEFAULT), STUCK_PROJECTILE_LIFETIME_MIN, STUCK_PROJECTILE_LIFETIME_MAX);
|
||||
}
|
||||
|
||||
public static double getStuckProjectileSpeed() {
|
||||
return Math.clamp(ConfigUtil.readDouble(STUCK_PROJECTILE_SPEED_PATH, STUCK_PROJECTILE_SPEED_DEFAULT), STUCK_PROJECTILE_SPEED_MIN, STUCK_PROJECTILE_SPEED_MAX);
|
||||
}
|
||||
|
||||
public static int getKillModeProjectileCycle() {
|
||||
return Math.clamp(ConfigUtil.readInt(KILL_MODE_PROJECTILE_CYCLE_PATH, KILL_MODE_PROJECTILE_CYCLE_DEFAULT), KILL_MODE_PROJECTILE_CYCLE_MIN, KILL_MODE_PROJECTILE_CYCLE_MAX);
|
||||
}
|
||||
|
||||
public static double getKillModeProjectileDamage() {
|
||||
return Math.clamp(ConfigUtil.readDouble(KILL_MODE_PROJECTILE_DAMAGE_PATH, KILL_MODE_PROJECTILE_DAMAGE_DEFAULT), KILL_MODE_PROJECTILE_DAMAGE_MIN, KILL_MODE_PROJECTILE_DAMAGE_MAX);
|
||||
}
|
||||
|
||||
public static int getKillModeProjectileRotate() {
|
||||
return Math.clamp(ConfigUtil.readInt(KILL_MODE_PROJECTILE_ROTATE_PATH, KILL_MODE_PROJECTILE_ROTATE_DEFAULT), KILL_MODE_PROJECTILE_ROTATE_MIN, KILL_MODE_PROJECTILE_ROTATE_MAX);
|
||||
}
|
||||
|
||||
public static int getStuckLifetime() {
|
||||
return Math.clamp(ConfigUtil.readInt(STUCK_LIFETIME_PATH, STUCK_LIFETIME_DEFAULT), STUCK_LIFETIME_MIN, STUCK_LIFETIME_MAX);
|
||||
}
|
||||
|
||||
public static int getMaxStuckCount() {
|
||||
return Math.clamp(ConfigUtil.readInt(MAX_STUCK_COUNT_PATH, MAX_STUCK_COUNT_DEFAULT), MAX_STUCK_COUNT_MIN, MAX_STUCK_COUNT_MAX);
|
||||
}
|
||||
|
||||
public static double getMarkLightningDamage() {
|
||||
return Math.clamp(ConfigUtil.readDouble(MARK_LIGHTNING_DAMAGE_PATH, MARK_LIGHTNING_DAMAGE_DEFAULT), MARK_LIGHTNING_DAMAGE_MIN, MARK_LIGHTNING_DAMAGE_MAX);
|
||||
}
|
||||
|
||||
public static int getProjectileEffectDuration() {
|
||||
return Math.clamp(ConfigUtil.readInt(PROJECTILE_EFFECT_DURATION_PATH, PROJECTILE_EFFECT_DURATION_DEFAULT), PROJECTILE_EFFECT_DURATION_MIN, PROJECTILE_EFFECT_DURATION_MAX);
|
||||
}
|
||||
|
||||
public static int getStuckProjectileEffectDuration() {
|
||||
return Math.clamp(ConfigUtil.readInt(STUCK_PROJECTILE_EFFECT_DURATION_PATH, STUCK_PROJECTILE_EFFECT_DURATION_DEFAULT), STUCK_PROJECTILE_EFFECT_DURATION_MIN, STUCK_PROJECTILE_EFFECT_DURATION_MAX);
|
||||
}
|
||||
|
||||
public static int getKillModeProjectileEffectDuration() {
|
||||
return Math.clamp(ConfigUtil.readInt(KILL_MODE_PROJECTILE_EFFECT_DURATION_PATH, KILL_MODE_PROJECTILE_EFFECT_DURATION_DEFAULT), KILL_MODE_PROJECTILE_EFFECT_DURATION_MIN, KILL_MODE_PROJECTILE_EFFECT_DURATION_MAX);
|
||||
}
|
||||
|
||||
public static final ConfigListItem CONFIG_LIST_ITEM = new ConfigListItem(
|
||||
"devils_devastation",
|
||||
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/item/devils_devastation.png"),
|
||||
Component.translatable("item.lzxnoneterraria.devils_devastation"),
|
||||
CONFIG_DATA
|
||||
);
|
||||
|
||||
public DevilsDevastation() {
|
||||
super(Tiers.NETHERITE, new Properties().attributes(ItemAttributeModifiers.builder()
|
||||
.add(Attributes.ATTACK_DAMAGE,
|
||||
@@ -99,6 +295,7 @@ public class DevilsDevastation extends SwordItem {
|
||||
//右键射出的弹射
|
||||
public static final int PROJECTILE_TRAIL_LENGTH = 10;
|
||||
public static final float PROJECTILE_TRAIL_RADIUS = 0.25F;
|
||||
public static final double PROJECTILE_BOUNDING_SIZE = 1;
|
||||
|
||||
//弹出的弹射
|
||||
public static final double STUCK_PROJECTILE_BOUNDING_SIZE = 3.0;
|
||||
@@ -150,7 +347,22 @@ public class DevilsDevastation extends SwordItem {
|
||||
projectile.trailPositions2.addFirst(projectile.position().add(right.scale(-PROJECTILE_TRAIL_RADIUS / 2 * 1.5f)));
|
||||
while(projectile.trailPositions.size() > PROJECTILE_TRAIL_LENGTH) projectile.trailPositions.removeLast();
|
||||
while(projectile.trailPositions2.size() > PROJECTILE_TRAIL_LENGTH) projectile.trailPositions2.removeLast();
|
||||
if(projectile.level().isClientSide()) {
|
||||
|
||||
projectile.setBoundingBox(new AABB(
|
||||
projectile.getX() - PROJECTILE_BOUNDING_SIZE, projectile.getY() - PROJECTILE_BOUNDING_SIZE, projectile.getZ() - PROJECTILE_BOUNDING_SIZE,
|
||||
projectile.getX() + PROJECTILE_BOUNDING_SIZE, projectile.getY() + PROJECTILE_BOUNDING_SIZE, projectile.getZ() + PROJECTILE_BOUNDING_SIZE
|
||||
));
|
||||
|
||||
if(!projectile.level().isClientSide()) {
|
||||
List<Entity> targets = projectile.level().getEntitiesOfClass(
|
||||
Entity.class,
|
||||
projectile.getBoundingBox(),
|
||||
FilterUtil.createTargetFilter(projectile, projectile.getOwner())
|
||||
);
|
||||
for(Entity target : targets) {
|
||||
this.onHitEntity(projectile, new EntityHitResult(target, target.position()));
|
||||
}
|
||||
}else {
|
||||
if(projectile.getRandom().nextInt(2) == 0) {
|
||||
ParticleUtil.addParticle(
|
||||
projectile.level(), ModParticles.DEVILS_DEVASTATION_RUNE_PARTICLE2.get(),
|
||||
@@ -168,9 +380,9 @@ public class DevilsDevastation extends SwordItem {
|
||||
Entity owner = projectile.getOwner();
|
||||
if(owner == null) return;
|
||||
if(!FilterUtil.createTargetFilter(owner).test(target) || !(owner instanceof Player player)) return;
|
||||
if(DamageUtil.attack(player, target, (float) Config.devilsDevastationProjectileDamage)) {
|
||||
if(DamageUtil.attack(player, target, (float) getProjectileDamage())) {
|
||||
if(target instanceof LivingEntity le) {
|
||||
MobEffectInstance effectInstance = new MobEffectInstance(ModEffects.DEMONIC_FLAMES, Config.devilsDevastationProjectileEffectDuration, 0);
|
||||
MobEffectInstance effectInstance = new MobEffectInstance(ModEffects.DEMONIC_FLAMES, getProjectileEffectDuration(), 0);
|
||||
le.addEffect(effectInstance);
|
||||
}
|
||||
target.invulnerableTime = 5;
|
||||
@@ -187,7 +399,7 @@ public class DevilsDevastation extends SwordItem {
|
||||
summon.getEntityData().set(StaticSummon.SCALE_Z, 4.0f);
|
||||
summon.getEntityData().set(StaticSummon.RXP, -90);
|
||||
summon.getEntityData().set(StaticSummon.RZP, -135);
|
||||
summon.getEntityData().set(StaticSummon.LIFETIME, Config.devilsDevastationStuckLifetime);
|
||||
summon.getEntityData().set(StaticSummon.LIFETIME, getStuckLifetime());
|
||||
summon.getEntityData().set(StaticSummon.GLOW, true);
|
||||
|
||||
CompoundTag customData = new CompoundTag();
|
||||
@@ -211,7 +423,7 @@ public class DevilsDevastation extends SwordItem {
|
||||
}
|
||||
if(target.isAlive()) {
|
||||
List<UUID> uuids = new ArrayList<>(target.getData(ModAttachments.STUCK_DEVILS_DEVASTATION_PROJECTILE));
|
||||
if (uuids.size() >= Config.devilsDevastationMaxStuckCount) {
|
||||
if (uuids.size() >= getMaxStuckCount()) {
|
||||
Entity stuckProjectile = ((ServerLevel) projectile.level()).getEntity(uuids.getFirst());
|
||||
if (stuckProjectile != null && stuckProjectile.isAlive() && stuckProjectile instanceof StaticSummon stuckStaticProjectile)
|
||||
summonStuckProjectile(stuckStaticProjectile);
|
||||
@@ -334,8 +546,8 @@ public class DevilsDevastation extends SwordItem {
|
||||
@Override
|
||||
public void onMoving(StaticProjectile projectile) {
|
||||
projectile.setBoundingBox(new AABB(
|
||||
projectile.getX() - STUCK_PROJECTILE_BOUNDING_SIZE, projectile.getY() - STUCK_PROJECTILE_BOUNDING_SIZE, projectile.getX() - STUCK_PROJECTILE_BOUNDING_SIZE,
|
||||
projectile.getX() + STUCK_PROJECTILE_BOUNDING_SIZE, projectile.getY() + STUCK_PROJECTILE_BOUNDING_SIZE, projectile.getX() + STUCK_PROJECTILE_BOUNDING_SIZE
|
||||
projectile.getX() - STUCK_PROJECTILE_BOUNDING_SIZE, projectile.getY() - STUCK_PROJECTILE_BOUNDING_SIZE, projectile.getZ() - STUCK_PROJECTILE_BOUNDING_SIZE,
|
||||
projectile.getX() + STUCK_PROJECTILE_BOUNDING_SIZE, projectile.getY() + STUCK_PROJECTILE_BOUNDING_SIZE, projectile.getZ() + STUCK_PROJECTILE_BOUNDING_SIZE
|
||||
));
|
||||
|
||||
if(!projectile.level().isClientSide()) {
|
||||
@@ -400,13 +612,11 @@ public class DevilsDevastation extends SwordItem {
|
||||
Entity owner = projectile.getOwner();
|
||||
if(owner == null) return;
|
||||
if(!FilterUtil.createTargetFilter(owner).test(target) || !(owner instanceof Player player)) return;
|
||||
if(DamageUtil.attack(player, target, (float) Config.devilsDevastationStuckProjectileDamage)) {
|
||||
if(DamageUtil.attack(player, target, (float) getStuckProjectileDamage())) {
|
||||
if(target instanceof LivingEntity le) {
|
||||
MobEffectInstance effectInstance = new MobEffectInstance(ModEffects.DEMONIC_FLAMES, Config.devilsDevastationStuckProjectileEffectDuration, 0);
|
||||
MobEffectInstance effectInstance = new MobEffectInstance(ModEffects.DEMONIC_FLAMES, getStuckProjectileEffectDuration(), 0);
|
||||
le.addEffect(effectInstance);
|
||||
}
|
||||
target.invulnerableTime = 5;
|
||||
onDied(projectile);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -415,7 +625,7 @@ public class DevilsDevastation extends SwordItem {
|
||||
public void onHitBlock(StaticProjectile projectile, BlockHitResult result) {}
|
||||
};
|
||||
|
||||
//鏉€鎴ā寮忕敓鎴愮殑寮瑰皠
|
||||
//杀戮模式弹射
|
||||
public static final IStaticProjectileBehavior PROJECTILE_BEHAVIOR3 = new IStaticProjectileBehavior() {
|
||||
@Override
|
||||
public void render(Entity entity, float entityYaw, float partialTick, PoseStack poseStack, MultiBufferSource bufferSource, int packedLight) {
|
||||
@@ -473,6 +683,7 @@ public class DevilsDevastation extends SwordItem {
|
||||
|
||||
Vector3f tipDir = dir.toVector3f().rotate(rotationUp);
|
||||
poseStack.translate(-tipDir.x * 2, -tipDir.y * 2, -tipDir.z * 2);
|
||||
poseStack.translate(-up.x * 0.5, -up.y * 0.5, -up.z * 0.5);
|
||||
poseStack.mulPose(rotationUp2);
|
||||
poseStack.mulPose(rotationDir);
|
||||
poseStack.mulPose(Axis.YP.rotationDegrees(-xyRot[1]));
|
||||
@@ -634,9 +845,9 @@ public class DevilsDevastation extends SwordItem {
|
||||
Entity target = result.getEntity();
|
||||
List<UUID> tempStuckList = target.getData(ModAttachments.STUCK_DEVILS_DEVASTATION_PROJECTILE);
|
||||
boolean valid = !tempStuckList.isEmpty();
|
||||
if(projectile.getOwner() instanceof Player player && DamageUtil.attack(player, target, (float) Config.devilsDevastationKillModeProjectileDamage)) {
|
||||
if(projectile.getOwner() instanceof Player player && DamageUtil.attack(player, target, (float) getKillModeProjectileDamage())) {
|
||||
if(target instanceof LivingEntity le) {
|
||||
MobEffectInstance effectInstance = new MobEffectInstance(ModEffects.DEMONIC_FLAMES, Config.devilsDevastationKillModeProjectileEffectDuration, 1);
|
||||
MobEffectInstance effectInstance = new MobEffectInstance(ModEffects.DEMONIC_FLAMES, getKillModeProjectileEffectDuration(), 1);
|
||||
le.addEffect(effectInstance);
|
||||
}
|
||||
|
||||
@@ -659,7 +870,7 @@ public class DevilsDevastation extends SwordItem {
|
||||
summon.setPos(pos);
|
||||
summon.getEntityData().set(StaticSummon.BEHAVIOR, StaticSummonBehaviors.DEVILS_DEVASTATION_MARK);
|
||||
summon.getEntityData().set(StaticSummon.RENDER_MODE, "custom");
|
||||
summon.getEntityData().set(StaticSummon.LIFETIME, Config.devilsDevastationKillModeTime);
|
||||
summon.getEntityData().set(StaticSummon.LIFETIME, getKillModeTime());
|
||||
summon.getEntityData().set(StaticSummon.GLOW, true);
|
||||
|
||||
CompoundTag summonCustomData = new CompoundTag();
|
||||
@@ -714,13 +925,13 @@ public class DevilsDevastation extends SwordItem {
|
||||
CompoundTag customData = projectile.getEntityData().get(StaticProjectile.CUSTOM_DATA);
|
||||
if(projectile.getOwner() instanceof LivingEntity livingEntity) {
|
||||
if(customData.contains("validHit")) {
|
||||
MobEffectInstance effectInstance = new MobEffectInstance(ModEffects.KILL_MODE, Config.devilsDevastationKillModeTime, 0);
|
||||
MobEffectInstance effectInstance = new MobEffectInstance(ModEffects.KILL_MODE, getKillModeTime(), 0);
|
||||
livingEntity.addEffect(effectInstance);
|
||||
|
||||
MobEffectInstance effectInstance2 = livingEntity.getEffect(ModEffects.KILL_MODE_COOLDOWN);
|
||||
if(effectInstance2 != null) livingEntity.removeEffect(effectInstance2.getEffect());
|
||||
}else {
|
||||
MobEffectInstance effectInstance = new MobEffectInstance(ModEffects.KILL_MODE_COOLDOWN, Config.devilsDevastationKillModeCooldownTime, 0);
|
||||
MobEffectInstance effectInstance = new MobEffectInstance(ModEffects.KILL_MODE_COOLDOWN, getKillModeCooldownTime(), 0);
|
||||
livingEntity.addEffect(effectInstance);
|
||||
|
||||
MobEffectInstance effectInstance2 = livingEntity.getEffect(ModEffects.KILL_MODE);
|
||||
@@ -869,6 +1080,15 @@ public class DevilsDevastation extends SwordItem {
|
||||
if(entity != null) {
|
||||
summon.setPos(entity.getBoundingBox().getCenter());
|
||||
}
|
||||
if(!summon.level().isClientSide()) {
|
||||
CompoundTag customData = summon.getEntityData().get(StaticSummon.CUSTOM_DATA);
|
||||
int left = summon.getEntityData().get(StaticSummon.LIFETIME) - summon.getEntityData().get(StaticSummon.AGE);
|
||||
if(left < 20 && !customData.contains("sound")) {
|
||||
customData.putBoolean("sound", true);
|
||||
summon.getEntityData().set(StaticSummon.CUSTOM_DATA, customData);
|
||||
SoundUtil.playServerSound(summon.level(), ModSounds.DEMON_SWORD_FINAL_STRIKE.get(), summon.position(),16.0f, 1.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -887,7 +1107,7 @@ public class DevilsDevastation extends SwordItem {
|
||||
UUID uuid = customData.getUUID("uuid");
|
||||
Entity entity = serverLevel.getEntity(uuid);
|
||||
if(entity instanceof Player player) {
|
||||
DamageUtil.attack(player, owner, (float) Config.devilsDevastationMarkLightningDamage);
|
||||
DamageUtil.attack(player, owner, (float) getMarkLightningDamage());
|
||||
StaticSummon newSummon = new StaticSummon(ModEntities.STATIC_SUMMON.get(), serverLevel);
|
||||
newSummon.setOwner(player);
|
||||
Vec3 pos = owner.getBoundingBox().getCenter();
|
||||
@@ -905,7 +1125,7 @@ public class DevilsDevastation extends SwordItem {
|
||||
}
|
||||
}
|
||||
}
|
||||
SoundUtil.playServerSound(summon.level(), ModSounds.DEMON_SWORD_INSANE_IMPACT.get(), summon.position(), 16.0f, 1.0f);
|
||||
//SoundUtil.playServerSound(summon.level(), ModSounds.DEMON_SWORD_INSANE_IMPACT.get(), summon.position(), 16.0f, 1.0f);
|
||||
summon.discard();
|
||||
}
|
||||
}
|
||||
@@ -999,9 +1219,9 @@ public class DevilsDevastation extends SwordItem {
|
||||
projectile.getEntityData().set(StaticProjectile.RIGHT, dirs[2]);
|
||||
projectile.getEntityData().set(StaticProjectile.ITEM, new ItemStack(ModItems.DEVILS_DEVASTATION.get()));
|
||||
projectile.getEntityData().set(StaticProjectile.RZP, rotate);
|
||||
projectile.getEntityData().set(StaticProjectile.LIFETIME, Config.devilsDevastationStuckProjectileLifetime);
|
||||
projectile.getEntityData().set(StaticProjectile.LIFETIME, getStuckProjectileLifetime());
|
||||
projectile.getEntityData().set(StaticProjectile.GLOW, true);
|
||||
projectile.getEntityData().set(StaticProjectile.EXPRESSION_Z, String.format("%.3f*t", Config.devilsDevastationStuckProjectileSpeed));
|
||||
projectile.getEntityData().set(StaticProjectile.EXPRESSION_Z, String.format("%.3f*t", getStuckProjectileSpeed()));
|
||||
projectile.setDeltaMovement(MathUtil.toVec3(dirs[0]));
|
||||
|
||||
serverLevel.addFreshEntity(projectile);
|
||||
@@ -1014,12 +1234,12 @@ public class DevilsDevastation extends SwordItem {
|
||||
ItemStack itemStack = player.getMainHandItem();
|
||||
if(!itemStack.is(ModItems.DEVILS_DEVASTATION.get())) return;
|
||||
if(player.getCooldowns().isOnCooldown(itemStack.getItem())) return;
|
||||
player.getCooldowns().addCooldown(itemStack.getItem(), Config.devilsDevastationKillModeProjectileCycle + 10);
|
||||
player.getCooldowns().addCooldown(itemStack.getItem(), getKillModeProjectileCycle() + 10);
|
||||
if(!player.level().isClientSide()) {
|
||||
float radius = 4.0f;
|
||||
float w = (float) Math.PI * 1.5f / Config.devilsDevastationKillModeProjectileCycle;
|
||||
float w = (float) Math.PI * 1.5f / getKillModeProjectileCycle();
|
||||
if(player.getRandom().nextInt(2) == 0) w = -w;
|
||||
int rotate = (int) ((Math.random() * 2 - 1) * Config.devilsDevastationKillModeProjectileRotate);
|
||||
int rotate = (int) ((Math.random() * 2 - 1) * getKillModeProjectileRotate());
|
||||
Vector3f[] dirs = MathUtil.computeCoordinateSystem(player);
|
||||
dirs = MathUtil.rotateCoordinateSystem(dirs[0], dirs[2], rotate);
|
||||
|
||||
@@ -1034,7 +1254,7 @@ public class DevilsDevastation extends SwordItem {
|
||||
projectile.getEntityData().set(StaticProjectile.UP, dirs[1]);
|
||||
projectile.getEntityData().set(StaticProjectile.RIGHT, dirs[2]);
|
||||
projectile.getEntityData().set(StaticProjectile.ITEM, new ItemStack(ModItems.DEVILS_DEVASTATION.get()));
|
||||
projectile.getEntityData().set(StaticProjectile.LIFETIME, Config.devilsDevastationKillModeProjectileCycle);
|
||||
projectile.getEntityData().set(StaticProjectile.LIFETIME, getKillModeProjectileCycle());
|
||||
projectile.getEntityData().set(StaticProjectile.GLOW, true);
|
||||
projectile.getEntityData().set(StaticProjectile.RZP, rotate);
|
||||
projectile.getEntityData().set(StaticProjectile.EXPRESSION_X, w > 0 ? String.format("%.3f*cos(%.3f*t - 0.25 * 3.1415926)", radius, w) : String.format("%.3f*cos(%.3f*t - 0.75 * 3.1415926)", radius, w));
|
||||
@@ -1244,7 +1464,7 @@ public class DevilsDevastation extends SwordItem {
|
||||
Matrix4f matrix = poseStack.last().pose();
|
||||
int time = entity.tickCount;
|
||||
|
||||
poseStack.translate(0, 2.5, 0.6);
|
||||
poseStack.translate(0, 1.4, 0.6);
|
||||
|
||||
float baseRadius = 1.0f;
|
||||
float speed = 0.25f;
|
||||
@@ -1362,9 +1582,9 @@ public class DevilsDevastation extends SwordItem {
|
||||
projectile.getEntityData().set(StaticProjectile.SCALE_Z, 4.0f);
|
||||
projectile.getEntityData().set(StaticProjectile.RXP, -90);
|
||||
projectile.getEntityData().set(StaticProjectile.RZP, -135);
|
||||
projectile.getEntityData().set(StaticProjectile.LIFETIME, Config.devilsDevastationProjectileLifetime);
|
||||
projectile.getEntityData().set(StaticProjectile.LIFETIME, getProjectileLifetime());
|
||||
projectile.getEntityData().set(StaticProjectile.GLOW, true);
|
||||
projectile.getEntityData().set(StaticProjectile.EXPRESSION_Z, String.format("%.3f*t", Config.devilsDevastationProjectileSpeed));
|
||||
projectile.getEntityData().set(StaticProjectile.EXPRESSION_Z, String.format("%.3f*t", getProjectileSpeed()));
|
||||
projectile.setDeltaMovement(MathUtil.toVec3(dirs[0]));
|
||||
level.addFreshEntity(projectile);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.lzxnone.terraria.item.weapon.melee;
|
||||
|
||||
import com.lzxnone.terraria.Config;
|
||||
import com.lzxnone.terraria.LzxnoneTerraria;
|
||||
import com.lzxnone.terraria.ModSounds;
|
||||
import com.lzxnone.terraria.entity.ModEntities;
|
||||
@@ -9,8 +8,13 @@ import com.lzxnone.terraria.entity.projectile.StaticProjectileBehaviors;
|
||||
import com.lzxnone.terraria.entity.projectile.StaticProjectile;
|
||||
import com.lzxnone.terraria.item.ModItems;
|
||||
import com.lzxnone.terraria.particle.ModParticles;
|
||||
import com.lzxnone.terraria.ui.config.ConfigFactory;
|
||||
import com.lzxnone.terraria.ui.config.ConfigListItem;
|
||||
import com.lzxnone.terraria.ui.config.ConfigUtil;
|
||||
import com.lzxnone.terraria.ui.config.IConfigData;
|
||||
import com.lzxnone.terraria.utils.*;
|
||||
import net.minecraft.core.component.DataComponents;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
@@ -36,6 +40,22 @@ import net.minecraft.world.phys.Vec3;
|
||||
import org.joml.Vector3f;
|
||||
|
||||
public class EnchantedSword extends SwordItem {
|
||||
private static final String CONFIG_TRANSLATION_PREFIX = "lzxnoneterraria.configuration.";
|
||||
|
||||
public static final String DAMAGE_PATH = "weapon.enchanted_sword.damage";
|
||||
public static final double DAMAGE_DEFAULT = 4.0;
|
||||
public static final double DAMAGE_MIN = 0.0;
|
||||
public static final double DAMAGE_MAX = 2147483647.0;
|
||||
|
||||
public static final String LIFETIME_PATH = "weapon.enchanted_sword.lifetime";
|
||||
public static final int LIFETIME_DEFAULT = 60;
|
||||
public static final int LIFETIME_MIN = 1;
|
||||
public static final int LIFETIME_MAX = 1200;
|
||||
|
||||
public static final String SPEED_PATH = "weapon.enchanted_sword.speed";
|
||||
public static final double SPEED_DEFAULT = 1.0;
|
||||
public static final double SPEED_MIN = 0.0;
|
||||
public static final double SPEED_MAX = 10.0;
|
||||
|
||||
public EnchantedSword() {
|
||||
super(Tiers.IRON, new Item.Properties().attributes(ItemAttributeModifiers.builder()
|
||||
@@ -51,6 +71,42 @@ public class EnchantedSword extends SwordItem {
|
||||
));
|
||||
}
|
||||
|
||||
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
||||
@Override
|
||||
public void onConfigLoad() {
|
||||
ConfigFactory.loadDoubleConfig(DAMAGE_PATH, configText("enchanted_sword_damage"), configTooltip("enchanted_sword_damage"), DAMAGE_DEFAULT, DAMAGE_MIN, DAMAGE_MAX);
|
||||
ConfigFactory.loadIntConfig(LIFETIME_PATH, configText("enchanted_sword_lifetime"), configTooltip("enchanted_sword_lifetime"), LIFETIME_DEFAULT, LIFETIME_MIN, LIFETIME_MAX);
|
||||
ConfigFactory.loadDoubleConfig(SPEED_PATH, configText("enchanted_sword_speed"), configTooltip("enchanted_sword_speed"), SPEED_DEFAULT, SPEED_MIN, SPEED_MAX);
|
||||
}
|
||||
};
|
||||
|
||||
private static Component configText(String key) {
|
||||
return Component.translatable(CONFIG_TRANSLATION_PREFIX + key);
|
||||
}
|
||||
|
||||
private static Component configTooltip(String key) {
|
||||
return Component.translatable(CONFIG_TRANSLATION_PREFIX + key + ".tooltip");
|
||||
}
|
||||
|
||||
public static double getDamage() {
|
||||
return Math.clamp(ConfigUtil.readDouble(DAMAGE_PATH, DAMAGE_DEFAULT), DAMAGE_MIN, DAMAGE_MAX);
|
||||
}
|
||||
|
||||
public static int getLifetime() {
|
||||
return Math.clamp(ConfigUtil.readInt(LIFETIME_PATH, LIFETIME_DEFAULT), LIFETIME_MIN, LIFETIME_MAX);
|
||||
}
|
||||
|
||||
public static double getSpeed() {
|
||||
return Math.clamp(ConfigUtil.readDouble(SPEED_PATH, SPEED_DEFAULT), SPEED_MIN, SPEED_MAX);
|
||||
}
|
||||
|
||||
public static final ConfigListItem CONFIG_LIST_ITEM = new ConfigListItem(
|
||||
"enchanted_sword",
|
||||
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/item/enchanted_sword.png"),
|
||||
Component.translatable("item.lzxnoneterraria.enchanted_sword"),
|
||||
CONFIG_DATA
|
||||
);
|
||||
|
||||
public static final IStaticProjectileBehavior PROJECTILE_BEHAVIOR = new IStaticProjectileBehavior() {
|
||||
@Override
|
||||
public void onMoving(StaticProjectile projectile) {
|
||||
@@ -67,7 +123,7 @@ public class EnchantedSword extends SwordItem {
|
||||
Entity owner = projectile.getOwner();
|
||||
if(owner == null) return;
|
||||
if(!FilterUtil.createTargetFilter(owner).test(target) || !(owner instanceof Player player)) return;
|
||||
if(DamageUtil.attack(player, target, (float) Config.enchantedSwordDamage)) {
|
||||
if(DamageUtil.attack(player, target, (float) getDamage())) {
|
||||
target.invulnerableTime = 5;
|
||||
ParticleUtil.addParticles(
|
||||
(ServerLevel) projectile.level(), ModParticles.COLORFUL_PARTICLE,
|
||||
@@ -110,8 +166,8 @@ public class EnchantedSword extends SwordItem {
|
||||
projectile.getEntityData().set(StaticProjectile.RZP, 45);
|
||||
projectile.getEntityData().set(StaticProjectile.RYPS, 10);
|
||||
projectile.getEntityData().set(StaticProjectile.GLOW, true);
|
||||
projectile.getEntityData().set(StaticProjectile.LIFETIME, Config.enchantedSwordLifetime);
|
||||
projectile.getEntityData().set(StaticProjectile.EXPRESSION_Z, String.format("%.3f*t", Config.enchantedSwordSpeed));
|
||||
projectile.getEntityData().set(StaticProjectile.LIFETIME, getLifetime());
|
||||
projectile.getEntityData().set(StaticProjectile.EXPRESSION_Z, String.format("%.3f*t", getSpeed()));
|
||||
|
||||
projectile.setDeltaMovement(MathUtil.toVec3(dirs[0]));
|
||||
level.addFreshEntity(projectile);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.lzxnone.terraria.item.weapon.melee;
|
||||
|
||||
import com.lzxnone.terraria.Config;
|
||||
import com.lzxnone.terraria.LzxnoneTerraria;
|
||||
import com.lzxnone.terraria.ModSounds;
|
||||
import com.lzxnone.terraria.entity.beam.ISwordBeamBehavior;
|
||||
@@ -34,8 +33,66 @@ import net.neoforged.neoforge.event.entity.player.AttackEntityEvent;
|
||||
import net.neoforged.neoforge.event.entity.player.PlayerInteractEvent;
|
||||
import net.neoforged.neoforge.network.PacketDistributor;
|
||||
import org.joml.Vector3f;
|
||||
import com.lzxnone.terraria.ui.config.ConfigFactory;
|
||||
import com.lzxnone.terraria.ui.config.ConfigListItem;
|
||||
import com.lzxnone.terraria.ui.config.ConfigUtil;
|
||||
import com.lzxnone.terraria.ui.config.IConfigData;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
||||
public class Excalibur extends SwordItem {
|
||||
private static final String CONFIG_TRANSLATION_PREFIX = "lzxnoneterraria.configuration.";
|
||||
|
||||
public static final String ROTATE_RANGE_PATH = "weapon.excalibur.rotate_range";
|
||||
public static final int ROTATE_RANGE_DEFAULT = 45;
|
||||
public static final int ROTATE_RANGE_MIN = 0;
|
||||
public static final int ROTATE_RANGE_MAX = 90;
|
||||
|
||||
public static final String MAX_HIT_COUNT_PATH = "weapon.excalibur.max_hit_count";
|
||||
public static final int MAX_HIT_COUNT_DEFAULT = 3;
|
||||
public static final int MAX_HIT_COUNT_MIN = 0;
|
||||
public static final int MAX_HIT_COUNT_MAX = 100;
|
||||
|
||||
public static final String DAMAGE_PATH = "weapon.excalibur.damage";
|
||||
public static final double DAMAGE_DEFAULT = 8.0;
|
||||
public static final double DAMAGE_MIN = 0.0;
|
||||
public static final double DAMAGE_MAX = 2147483647.0;
|
||||
|
||||
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
||||
@Override
|
||||
public void onConfigLoad() {
|
||||
ConfigFactory.loadIntConfig(ROTATE_RANGE_PATH, configText("excalibur_rotate_range"), configTooltip("excalibur_rotate_range"), ROTATE_RANGE_DEFAULT, ROTATE_RANGE_MIN, ROTATE_RANGE_MAX);
|
||||
ConfigFactory.loadIntConfig(MAX_HIT_COUNT_PATH, configText("excalibur_max_hit_count"), configTooltip("excalibur_max_hit_count"), MAX_HIT_COUNT_DEFAULT, MAX_HIT_COUNT_MIN, MAX_HIT_COUNT_MAX);
|
||||
ConfigFactory.loadDoubleConfig(DAMAGE_PATH, configText("excalibur_damage"), configTooltip("excalibur_damage"), DAMAGE_DEFAULT, DAMAGE_MIN, DAMAGE_MAX);
|
||||
}
|
||||
};
|
||||
|
||||
private static Component configText(String key) {
|
||||
return Component.translatable(CONFIG_TRANSLATION_PREFIX + key);
|
||||
}
|
||||
|
||||
private static Component configTooltip(String key) {
|
||||
return Component.translatable(CONFIG_TRANSLATION_PREFIX + key + ".tooltip");
|
||||
}
|
||||
|
||||
public static int getRotateRange() {
|
||||
return Math.clamp(ConfigUtil.readInt(ROTATE_RANGE_PATH, ROTATE_RANGE_DEFAULT), ROTATE_RANGE_MIN, ROTATE_RANGE_MAX);
|
||||
}
|
||||
|
||||
public static int getMaxHitCount() {
|
||||
return Math.clamp(ConfigUtil.readInt(MAX_HIT_COUNT_PATH, MAX_HIT_COUNT_DEFAULT), MAX_HIT_COUNT_MIN, MAX_HIT_COUNT_MAX);
|
||||
}
|
||||
|
||||
public static double getDamage() {
|
||||
return Math.clamp(ConfigUtil.readDouble(DAMAGE_PATH, DAMAGE_DEFAULT), DAMAGE_MIN, DAMAGE_MAX);
|
||||
}
|
||||
|
||||
public static final ConfigListItem CONFIG_LIST_ITEM = new ConfigListItem(
|
||||
"excalibur",
|
||||
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/item/excalibur.png"),
|
||||
Component.translatable("item.lzxnoneterraria.excalibur"),
|
||||
CONFIG_DATA
|
||||
);
|
||||
|
||||
public Excalibur() {
|
||||
super(Tiers.IRON, new Item.Properties().attributes(ItemAttributeModifiers.builder()
|
||||
.add(Attributes.ATTACK_DAMAGE,
|
||||
@@ -93,8 +150,8 @@ public class Excalibur extends SwordItem {
|
||||
CompoundTag custom_data = beam.getEntityData().get(SwordBeam.CUSTOM_DATA);
|
||||
if(custom_data.contains("hitEntityCount")) {
|
||||
int count = custom_data.getInt("hitEntityCount");
|
||||
if(count < Config.excaliburMaxHitCount) {
|
||||
if(DamageUtil.attack(player, target, (float) Config.excaliburDamage)) {
|
||||
if(count < getMaxHitCount()) {
|
||||
if(DamageUtil.attack(player, target, (float) getDamage())) {
|
||||
target.invulnerableTime = 20;
|
||||
count++;
|
||||
custom_data.putInt("hitEntityCount", count);
|
||||
@@ -113,7 +170,7 @@ public class Excalibur extends SwordItem {
|
||||
|
||||
@Override
|
||||
public void generate(Entity entity, CompoundTag beamData) {
|
||||
beamData.putInt("rotate", (int) (Config.excaliburRotateRange * (Math.random() * 2 - 1)));
|
||||
beamData.putInt("rotate", (int) (getRotateRange() * (Math.random() * 2 - 1)));
|
||||
ISwordBeamBehavior.super.generate(entity, beamData);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.lzxnone.terraria.item.weapon.melee;
|
||||
|
||||
import com.lzxnone.terraria.Config;
|
||||
import com.lzxnone.terraria.LzxnoneTerraria;
|
||||
import com.lzxnone.terraria.ModSounds;
|
||||
import com.lzxnone.terraria.entity.ModEntities;
|
||||
@@ -43,11 +42,117 @@ import net.minecraft.world.phys.Vec3;
|
||||
import org.joml.Matrix4f;
|
||||
import org.joml.Vector3f;
|
||||
import org.jspecify.annotations.NonNull;
|
||||
import com.lzxnone.terraria.ui.config.ConfigFactory;
|
||||
import com.lzxnone.terraria.ui.config.ConfigListItem;
|
||||
import com.lzxnone.terraria.ui.config.ConfigUtil;
|
||||
import com.lzxnone.terraria.ui.config.IConfigData;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class FirstFractal extends SwordItem {
|
||||
private static final String CONFIG_TRANSLATION_PREFIX = "lzxnoneterraria.configuration.";
|
||||
|
||||
public static final String PROJECTILE_DAMAGE_PATH = "weapon.first_fractal.projectile_damage";
|
||||
public static final double PROJECTILE_DAMAGE_DEFAULT = 10.0;
|
||||
public static final double PROJECTILE_DAMAGE_MIN = 0.0;
|
||||
public static final double PROJECTILE_DAMAGE_MAX = 2147483647.0;
|
||||
|
||||
public static final String BOUNDING_BOX_SIZE_PATH = "weapon.first_fractal.bounding_box_size";
|
||||
public static final double BOUNDING_BOX_SIZE_DEFAULT = 1.5;
|
||||
public static final double BOUNDING_BOX_SIZE_MIN = 0.5;
|
||||
public static final double BOUNDING_BOX_SIZE_MAX = 10.0;
|
||||
|
||||
public static final String PROJECTILE_SPEED_PATH = "weapon.first_fractal.projectile_speed";
|
||||
public static final double PROJECTILE_SPEED_DEFAULT = 1.5;
|
||||
public static final double PROJECTILE_SPEED_MIN = 0.0;
|
||||
public static final double PROJECTILE_SPEED_MAX = 10.0;
|
||||
|
||||
public static final String PROJECTILE_LIFETIME_PATH = "weapon.first_fractal.projectile_lifetime";
|
||||
public static final int PROJECTILE_LIFETIME_DEFAULT = 30;
|
||||
public static final int PROJECTILE_LIFETIME_MIN = 1;
|
||||
public static final int PROJECTILE_LIFETIME_MAX = 1200;
|
||||
|
||||
public static final String DISTANCE_MODE_PATH = "weapon.first_fractal.distance_mode";
|
||||
public static final boolean DISTANCE_MODE_DEFAULT = true;
|
||||
|
||||
public static final String SCROLL_SPEED_PATH = "weapon.first_fractal.scroll_speed";
|
||||
public static final int SCROLL_SPEED_DEFAULT = 4;
|
||||
public static final int SCROLL_SPEED_MIN = 0;
|
||||
public static final int SCROLL_SPEED_MAX = 128;
|
||||
|
||||
public static final String MAX_RANGE_PATH = "weapon.first_fractal.max_range";
|
||||
public static final double MAX_RANGE_DEFAULT = 64.0;
|
||||
public static final double MAX_RANGE_MIN = 1.0;
|
||||
public static final double MAX_RANGE_MAX = 1024.0;
|
||||
|
||||
public static final String SPAWN_RANGE_PATH = "weapon.first_fractal.spawn_range";
|
||||
public static final double SPAWN_RANGE_DEFAULT = 16.0;
|
||||
public static final double SPAWN_RANGE_MIN = 1.0;
|
||||
public static final double SPAWN_RANGE_MAX = 64.0;
|
||||
|
||||
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
||||
@Override
|
||||
public void onConfigLoad() {
|
||||
ConfigFactory.loadDoubleConfig(PROJECTILE_DAMAGE_PATH, configText("first_fractal_projectile_damage"), configTooltip("first_fractal_projectile_damage"), PROJECTILE_DAMAGE_DEFAULT, PROJECTILE_DAMAGE_MIN, PROJECTILE_DAMAGE_MAX);
|
||||
ConfigFactory.loadDoubleConfig(BOUNDING_BOX_SIZE_PATH, configText("first_fractal_bounding_box_size"), configTooltip("first_fractal_bounding_box_size"), BOUNDING_BOX_SIZE_DEFAULT, BOUNDING_BOX_SIZE_MIN, BOUNDING_BOX_SIZE_MAX);
|
||||
ConfigFactory.loadDoubleConfig(PROJECTILE_SPEED_PATH, configText("first_fractal_projectile_speed"), configTooltip("first_fractal_projectile_speed"), PROJECTILE_SPEED_DEFAULT, PROJECTILE_SPEED_MIN, PROJECTILE_SPEED_MAX);
|
||||
ConfigFactory.loadIntConfig(PROJECTILE_LIFETIME_PATH, configText("first_fractal_projectile_lifetime"), configTooltip("first_fractal_projectile_lifetime"), PROJECTILE_LIFETIME_DEFAULT, PROJECTILE_LIFETIME_MIN, PROJECTILE_LIFETIME_MAX);
|
||||
ConfigFactory.loadBooleanConfig(DISTANCE_MODE_PATH, configText("first_fractal_distance_mode"), configTooltip("first_fractal_distance_mode"), DISTANCE_MODE_DEFAULT);
|
||||
ConfigFactory.loadIntConfig(SCROLL_SPEED_PATH, configText("first_fractal_scroll_speed"), configTooltip("first_fractal_scroll_speed"), SCROLL_SPEED_DEFAULT, SCROLL_SPEED_MIN, SCROLL_SPEED_MAX);
|
||||
ConfigFactory.loadDoubleConfig(MAX_RANGE_PATH, configText("first_fractal_max_range"), configTooltip("first_fractal_max_range"), MAX_RANGE_DEFAULT, MAX_RANGE_MIN, MAX_RANGE_MAX);
|
||||
ConfigFactory.loadDoubleConfig(SPAWN_RANGE_PATH, configText("first_fractal_spawn_range"), configTooltip("first_fractal_spawn_range"), SPAWN_RANGE_DEFAULT, SPAWN_RANGE_MIN, SPAWN_RANGE_MAX);
|
||||
}
|
||||
};
|
||||
|
||||
private static Component configText(String key) {
|
||||
return Component.translatable(CONFIG_TRANSLATION_PREFIX + key);
|
||||
}
|
||||
|
||||
private static Component configTooltip(String key) {
|
||||
return Component.translatable(CONFIG_TRANSLATION_PREFIX + key + ".tooltip");
|
||||
}
|
||||
|
||||
public static double getProjectileDamage() {
|
||||
return Math.clamp(ConfigUtil.readDouble(PROJECTILE_DAMAGE_PATH, PROJECTILE_DAMAGE_DEFAULT), PROJECTILE_DAMAGE_MIN, PROJECTILE_DAMAGE_MAX);
|
||||
}
|
||||
|
||||
public static double getBoundingBoxSize() {
|
||||
return Math.clamp(ConfigUtil.readDouble(BOUNDING_BOX_SIZE_PATH, BOUNDING_BOX_SIZE_DEFAULT), BOUNDING_BOX_SIZE_MIN, BOUNDING_BOX_SIZE_MAX);
|
||||
}
|
||||
|
||||
public static double getProjectileSpeed() {
|
||||
return Math.clamp(ConfigUtil.readDouble(PROJECTILE_SPEED_PATH, PROJECTILE_SPEED_DEFAULT), PROJECTILE_SPEED_MIN, PROJECTILE_SPEED_MAX);
|
||||
}
|
||||
|
||||
public static int getProjectileLifetime() {
|
||||
return Math.clamp(ConfigUtil.readInt(PROJECTILE_LIFETIME_PATH, PROJECTILE_LIFETIME_DEFAULT), PROJECTILE_LIFETIME_MIN, PROJECTILE_LIFETIME_MAX);
|
||||
}
|
||||
|
||||
public static boolean isDistanceMode() {
|
||||
return ConfigUtil.readBoolean(DISTANCE_MODE_PATH, DISTANCE_MODE_DEFAULT);
|
||||
}
|
||||
|
||||
public static int getScrollSpeed() {
|
||||
return Math.clamp(ConfigUtil.readInt(SCROLL_SPEED_PATH, SCROLL_SPEED_DEFAULT), SCROLL_SPEED_MIN, SCROLL_SPEED_MAX);
|
||||
}
|
||||
|
||||
public static double getMaxRange() {
|
||||
return Math.clamp(ConfigUtil.readDouble(MAX_RANGE_PATH, MAX_RANGE_DEFAULT), MAX_RANGE_MIN, MAX_RANGE_MAX);
|
||||
}
|
||||
|
||||
public static double getSpawnRange() {
|
||||
return Math.clamp(ConfigUtil.readDouble(SPAWN_RANGE_PATH, SPAWN_RANGE_DEFAULT), SPAWN_RANGE_MIN, SPAWN_RANGE_MAX);
|
||||
}
|
||||
|
||||
public static final ConfigListItem CONFIG_LIST_ITEM = new ConfigListItem(
|
||||
"first_fractal",
|
||||
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/item/first_fractal.png"),
|
||||
Component.translatable("item.lzxnoneterraria.first_fractal"),
|
||||
CONFIG_DATA
|
||||
);
|
||||
|
||||
public FirstFractal() {
|
||||
super(Tiers.NETHERITE, new Item.Properties().attributes(ItemAttributeModifiers.builder()
|
||||
.add(Attributes.ATTACK_DAMAGE,
|
||||
@@ -291,11 +396,11 @@ public class FirstFractal extends SwordItem {
|
||||
@Override
|
||||
public void tick(StaticSummon summon) {
|
||||
this.checkBeforeTick(summon);
|
||||
summon.setDeltaMovement(summon.getLookAngle().normalize().scale(Config.firstFractalProjectileSpeed));
|
||||
summon.setDeltaMovement(summon.getLookAngle().normalize().scale(getProjectileSpeed()));
|
||||
|
||||
summon.setBoundingBox(new AABB(
|
||||
summon.getX() - Config.firstFractalBoundingBoxSize, summon.getY() - Config.firstFractalBoundingBoxSize, summon.getZ() - Config.firstFractalBoundingBoxSize,
|
||||
summon.getX() + Config.firstFractalBoundingBoxSize, summon.getY() + Config.firstFractalBoundingBoxSize, summon.getZ() + Config.firstFractalBoundingBoxSize
|
||||
summon.getX() - getBoundingBoxSize(), summon.getY() - getBoundingBoxSize(), summon.getZ() - getBoundingBoxSize(),
|
||||
summon.getX() + getBoundingBoxSize(), summon.getY() + getBoundingBoxSize(), summon.getZ() + getBoundingBoxSize()
|
||||
));
|
||||
|
||||
if(!summon.level().isClientSide()) {
|
||||
@@ -306,7 +411,7 @@ public class FirstFractal extends SwordItem {
|
||||
FilterUtil.createTargetFilter(summon, summon.getOwner())
|
||||
);
|
||||
for(Entity target : targets) {
|
||||
if(DamageUtil.attack(player, target, (float) Config.firstFractalProjectileDamage)) {
|
||||
if(DamageUtil.attack(player, target, (float) getProjectileDamage())) {
|
||||
target.invulnerableTime = 10;
|
||||
}
|
||||
}
|
||||
@@ -320,7 +425,7 @@ public class FirstFractal extends SwordItem {
|
||||
Vector3f[] dirs = MathUtil.computeCoordinateSystem(summon.getLookAngle().toVector3f(), 0);
|
||||
ZenithTrailParticleOptions options = new ZenithTrailParticleOptions(0.05f, 40, true, color, dirs[1], dirs[2], 90);
|
||||
Vec3 pos = MathUtil.toVec3(dirs[1]).scale(Math.random() * 2).add(summon.position());
|
||||
Vec3 speed = MathUtil.toVec3(dirs[0]).scale(Config.firstFractalProjectileSpeed);
|
||||
Vec3 speed = MathUtil.toVec3(dirs[0]).scale(getProjectileSpeed());
|
||||
ParticleUtil.addParticle(
|
||||
summon.level(), options,
|
||||
pos, 0,
|
||||
@@ -333,19 +438,19 @@ public class FirstFractal extends SwordItem {
|
||||
public static void summon(Player player, double deltaDist) {
|
||||
if(!player.level().isClientSide()) {
|
||||
Vec3 targetPos;
|
||||
if(Config.firstFractalDistanceMode) {
|
||||
Vec3 origin = MathUtil.getCrosshairPos(player, player.level(), Config.firstFractalMaxRange);
|
||||
if(isDistanceMode()) {
|
||||
Vec3 origin = MathUtil.getCrosshairPos(player, player.level(), getMaxRange());
|
||||
double dist = origin.subtract(player.getEyePosition()).length();
|
||||
double maxScale = Config.firstFractalMaxRange - dist;
|
||||
double maxScale = getMaxRange() - dist;
|
||||
double minScale = -dist;
|
||||
double scale = Math.min(deltaDist, maxScale);
|
||||
if(deltaDist < minScale) scale = -minScale;
|
||||
targetPos = origin.add(player.getLookAngle().normalize().scale(scale));
|
||||
}else {
|
||||
targetPos = player.getEyePosition().add(player.getLookAngle().normalize().scale(Math.min(deltaDist, Config.firstFractalMaxRange)));
|
||||
targetPos = player.getEyePosition().add(player.getLookAngle().normalize().scale(Math.min(deltaDist, getMaxRange())));
|
||||
}
|
||||
|
||||
Vec3 summonPos = MathUtil.getRandomPosInRadius(targetPos, Config.firstFractalSpawnRange);
|
||||
Vec3 summonPos = MathUtil.getRandomPosInRadius(targetPos, getSpawnRange());
|
||||
Vector3f color = COLORS[player.getRandom().nextInt(COLORS.length)];
|
||||
|
||||
StaticSummon summon = new StaticSummon(ModEntities.STATIC_SUMMON.get(), player.level());
|
||||
@@ -358,7 +463,7 @@ public class FirstFractal extends SwordItem {
|
||||
summon.getEntityData().set(StaticSummon.COLOR_G, color.y);
|
||||
summon.getEntityData().set(StaticSummon.COLOR_B, color.z);
|
||||
summon.getEntityData().set(StaticSummon.GLOW, true);
|
||||
summon.getEntityData().set(StaticSummon.LIFETIME, Config.firstFractalProjectileLifetime);
|
||||
summon.getEntityData().set(StaticSummon.LIFETIME, getProjectileLifetime());
|
||||
|
||||
Vector3f[] dirs = MathUtil.computeCoordinateSystem(targetPos.subtract(summonPos).toVector3f(), 0);
|
||||
float[] xyRot = MathUtil.computeXYRot(dirs[0], dirs[1]);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.lzxnone.terraria.item.weapon.melee;
|
||||
|
||||
import com.lzxnone.terraria.Config;
|
||||
import com.lzxnone.terraria.LzxnoneTerraria;
|
||||
import com.lzxnone.terraria.ModSounds;
|
||||
import com.lzxnone.terraria.entity.ModEntities;
|
||||
@@ -36,12 +35,90 @@ import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.phys.*;
|
||||
import net.objecthunter.exp4j.ExpressionBuilder;
|
||||
import org.joml.Vector3f;
|
||||
import com.lzxnone.terraria.ui.config.ConfigFactory;
|
||||
import com.lzxnone.terraria.ui.config.ConfigListItem;
|
||||
import com.lzxnone.terraria.ui.config.ConfigUtil;
|
||||
import com.lzxnone.terraria.ui.config.IConfigData;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public class InfluxWaver extends SwordItem {
|
||||
private static final String CONFIG_TRANSLATION_PREFIX = "lzxnoneterraria.configuration.";
|
||||
|
||||
public static final String DAMAGE_PATH = "weapon.influx_waver.damage";
|
||||
public static final double DAMAGE_DEFAULT = 12.0;
|
||||
public static final double DAMAGE_MIN = 0.0;
|
||||
public static final double DAMAGE_MAX = 2147483647.0;
|
||||
|
||||
public static final String MAX_COUNT_PATH = "weapon.influx_waver.max_count";
|
||||
public static final int MAX_COUNT_DEFAULT = 2;
|
||||
public static final int MAX_COUNT_MIN = 0;
|
||||
public static final int MAX_COUNT_MAX = 10;
|
||||
|
||||
public static final String SPEED_PATH = "weapon.influx_waver.speed";
|
||||
public static final double SPEED_DEFAULT = 1.0;
|
||||
public static final double SPEED_MIN = 0.0;
|
||||
public static final double SPEED_MAX = 10.0;
|
||||
|
||||
public static final String SPAWN_RANGE_PATH = "weapon.influx_waver.spawn_range";
|
||||
public static final double SPAWN_RANGE_DEFAULT = 8.0;
|
||||
public static final double SPAWN_RANGE_MIN = 1.0;
|
||||
public static final double SPAWN_RANGE_MAX = 64.0;
|
||||
|
||||
public static final String TARGET_RANGE_PATH = "weapon.influx_waver.target_range";
|
||||
public static final double TARGET_RANGE_DEFAULT = 24.0;
|
||||
public static final double TARGET_RANGE_MIN = 1.0;
|
||||
public static final double TARGET_RANGE_MAX = 64.0;
|
||||
|
||||
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
||||
@Override
|
||||
public void onConfigLoad() {
|
||||
ConfigFactory.loadDoubleConfig(DAMAGE_PATH, configText("influx_waver_damage"), configTooltip("influx_waver_damage"), DAMAGE_DEFAULT, DAMAGE_MIN, DAMAGE_MAX);
|
||||
ConfigFactory.loadIntConfig(MAX_COUNT_PATH, configText("influx_waver_max_count"), configTooltip("influx_waver_max_count"), MAX_COUNT_DEFAULT, MAX_COUNT_MIN, MAX_COUNT_MAX);
|
||||
ConfigFactory.loadDoubleConfig(SPEED_PATH, configText("influx_waver_speed"), configTooltip("influx_waver_speed"), SPEED_DEFAULT, SPEED_MIN, SPEED_MAX);
|
||||
ConfigFactory.loadDoubleConfig(SPAWN_RANGE_PATH, configText("influx_waver_spawn_range"), configTooltip("influx_waver_spawn_range"), SPAWN_RANGE_DEFAULT, SPAWN_RANGE_MIN, SPAWN_RANGE_MAX);
|
||||
ConfigFactory.loadDoubleConfig(TARGET_RANGE_PATH, configText("influx_waver_target_range"), configTooltip("influx_waver_target_range"), TARGET_RANGE_DEFAULT, TARGET_RANGE_MIN, TARGET_RANGE_MAX);
|
||||
}
|
||||
};
|
||||
|
||||
private static Component configText(String key) {
|
||||
return Component.translatable(CONFIG_TRANSLATION_PREFIX + key);
|
||||
}
|
||||
|
||||
private static Component configTooltip(String key) {
|
||||
return Component.translatable(CONFIG_TRANSLATION_PREFIX + key + ".tooltip");
|
||||
}
|
||||
|
||||
public static double getDamage() {
|
||||
return Math.clamp(ConfigUtil.readDouble(DAMAGE_PATH, DAMAGE_DEFAULT), DAMAGE_MIN, DAMAGE_MAX);
|
||||
}
|
||||
|
||||
public static int getMaxCount() {
|
||||
return Math.clamp(ConfigUtil.readInt(MAX_COUNT_PATH, MAX_COUNT_DEFAULT), MAX_COUNT_MIN, MAX_COUNT_MAX);
|
||||
}
|
||||
|
||||
public static double getSpeed() {
|
||||
return Math.clamp(ConfigUtil.readDouble(SPEED_PATH, SPEED_DEFAULT), SPEED_MIN, SPEED_MAX);
|
||||
}
|
||||
|
||||
public static double getSpawnRange() {
|
||||
return Math.clamp(ConfigUtil.readDouble(SPAWN_RANGE_PATH, SPAWN_RANGE_DEFAULT), SPAWN_RANGE_MIN, SPAWN_RANGE_MAX);
|
||||
}
|
||||
|
||||
public static double getTargetRange() {
|
||||
return Math.clamp(ConfigUtil.readDouble(TARGET_RANGE_PATH, TARGET_RANGE_DEFAULT), TARGET_RANGE_MIN, TARGET_RANGE_MAX);
|
||||
}
|
||||
|
||||
public static final ConfigListItem CONFIG_LIST_ITEM = new ConfigListItem(
|
||||
"influx_waver",
|
||||
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/item/influx_waver.png"),
|
||||
Component.translatable("item.lzxnoneterraria.influx_waver"),
|
||||
CONFIG_DATA
|
||||
);
|
||||
|
||||
public InfluxWaver() {
|
||||
super(Tiers.DIAMOND, new Item.Properties().attributes(ItemAttributeModifiers.builder()
|
||||
.add(Attributes.ATTACK_DAMAGE,
|
||||
@@ -101,23 +178,23 @@ public class InfluxWaver extends SwordItem {
|
||||
checkEntity = false;
|
||||
}else {
|
||||
if(idx == 0) {
|
||||
summon.setDeltaMovement(summon.getLookAngle().normalize().scale(Config.influxWaverSpeed));
|
||||
summon.setDeltaMovement(summon.getLookAngle().normalize().scale(getSpeed()));
|
||||
}else {
|
||||
checkBlock = false;
|
||||
if(customData.contains("target")) {
|
||||
Entity target = summon.level().getEntity(customData.getInt("target"));
|
||||
if(target == null || !target.isAlive()) {
|
||||
//summon.setDeltaMovement(summon.getLookAngle().normalize().scale(Config.influxWaverSpeed));
|
||||
//summon.setDeltaMovement(summon.getLookAngle().normalize().scale(getSpeed()));
|
||||
checkEntity = false;
|
||||
}else {
|
||||
//Vec3 targetPos = new Vec3(target.getX(), target.getY() + target.getBbHeight() / 2, target.getZ());
|
||||
//summon.setDeltaMovement(targetPos.subtract(summon.position()).normalize().scale(Config.influxWaverSpeed));
|
||||
//summon.setDeltaMovement(targetPos.subtract(summon.position()).normalize().scale(getSpeed()));
|
||||
}
|
||||
}else {
|
||||
//summon.setDeltaMovement(summon.getLookAngle().normalize().scale(Config.influxWaverSpeed));
|
||||
//summon.setDeltaMovement(summon.getLookAngle().normalize().scale(getSpeed()));
|
||||
checkEntity = false;
|
||||
}
|
||||
summon.setDeltaMovement(summon.getLookAngle().normalize().scale(Config.influxWaverSpeed));
|
||||
summon.setDeltaMovement(summon.getLookAngle().normalize().scale(getSpeed()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,7 +224,7 @@ public class InfluxWaver extends SwordItem {
|
||||
Entity target = customData.contains("target") ? summon.level().getEntity(customData.getInt("target")) : null;
|
||||
if(target != null && !hitTarget.getUUID().equals(target.getUUID())) return;
|
||||
if(summon.getOwner() instanceof Player player && FilterUtil.createTargetFilter(player).test(hitTarget)) {
|
||||
if(DamageUtil.attack(player, hitTarget, (float) Config.influxWaverDamage)) {
|
||||
if(DamageUtil.attack(player, hitTarget, (float) getDamage())) {
|
||||
hitTarget.invulnerableTime = 2;
|
||||
}
|
||||
customData.putBoolean("dead", false);
|
||||
@@ -163,12 +240,12 @@ public class InfluxWaver extends SwordItem {
|
||||
public void onDied(StaticSummon summon) {
|
||||
if(!summon.level().isClientSide()) {
|
||||
CompoundTag customData = summon.getEntityData().get(StaticSummon.CUSTOM_DATA);
|
||||
if(customData.contains("dead") && !customData.getBoolean("dead") && customData.contains("idx") && customData.getInt("idx") < Config.influxWaverMaxCount) {
|
||||
if(customData.contains("dead") && !customData.getBoolean("dead") && customData.contains("idx") && customData.getInt("idx") < getMaxCount()) {
|
||||
if(summon.getOwner() instanceof Player player) {
|
||||
Entity target = InfluxWaver.search(player, summon.position());
|
||||
if(target != null) {
|
||||
Vec3 targetPos = new Vec3(target.getX(), target.getY() + target.getBbHeight() / 2, target.getZ());
|
||||
Vec3 summonPos = MathUtil.getRandomPosOnRadius(targetPos, Config.influxWaverSpawnRange);
|
||||
Vec3 summonPos = MathUtil.getRandomPosOnRadius(targetPos, getSpawnRange());
|
||||
InfluxWaver.summon(player, summonPos, targetPos.subtract(summonPos).normalize(), target, customData.getInt("idx") + 1);
|
||||
}
|
||||
}
|
||||
@@ -214,8 +291,8 @@ public class InfluxWaver extends SwordItem {
|
||||
|
||||
public static Entity search(Player player, Vec3 pos) {
|
||||
AABB searchBox = new AABB(
|
||||
pos.x - Config.influxWaverTargetRange, pos.y - Config.influxWaverTargetRange, pos.z - Config.influxWaverTargetRange,
|
||||
pos.x + Config.influxWaverTargetRange, pos.y + Config.influxWaverTargetRange, pos.z + Config.influxWaverTargetRange
|
||||
pos.x - getTargetRange(), pos.y - getTargetRange(), pos.z - getTargetRange(),
|
||||
pos.x + getTargetRange(), pos.y + getTargetRange(), pos.z + getTargetRange()
|
||||
);
|
||||
List<Monster> entities = player.level().getEntitiesOfClass(
|
||||
Monster.class,
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.lzxnone.terraria.item.weapon.melee;
|
||||
|
||||
import com.lzxnone.terraria.Config;
|
||||
import com.lzxnone.terraria.LzxnoneTerraria;
|
||||
import com.lzxnone.terraria.entity.ModEntities;
|
||||
import com.lzxnone.terraria.entity.ModRenderTypes;
|
||||
@@ -11,6 +10,10 @@ import com.lzxnone.terraria.entity.summon.StaticSummon;
|
||||
import com.lzxnone.terraria.entity.summon.StaticSummonBehaviors;
|
||||
import com.lzxnone.terraria.item.IItemWaveBehavior;
|
||||
import com.lzxnone.terraria.particle.DustParticleOptions;
|
||||
import com.lzxnone.terraria.ui.config.ConfigFactory;
|
||||
import com.lzxnone.terraria.ui.config.ConfigListItem;
|
||||
import com.lzxnone.terraria.ui.config.ConfigUtil;
|
||||
import com.lzxnone.terraria.ui.config.IConfigData;
|
||||
import com.lzxnone.terraria.utils.DamageUtil;
|
||||
import com.lzxnone.terraria.utils.FilterUtil;
|
||||
import com.lzxnone.terraria.utils.ParticleUtil;
|
||||
@@ -23,6 +26,7 @@ import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.texture.OverlayTexture;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EquipmentSlotGroup;
|
||||
@@ -47,6 +51,23 @@ import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
public class LightsBane extends SwordItem {
|
||||
private static final String CONFIG_TRANSLATION_PREFIX = "lzxnoneterraria.configuration.";
|
||||
|
||||
public static final String BIG_DAMAGE_PATH = "weapon.lights_bane.big_damage";
|
||||
public static final double BIG_DAMAGE_DEFAULT = 4.0;
|
||||
public static final double BIG_DAMAGE_MIN = 0.0;
|
||||
public static final double BIG_DAMAGE_MAX = 2147483647.0;
|
||||
|
||||
public static final String SMALL_DAMAGE_PATH = "weapon.lights_bane.small_damage";
|
||||
public static final double SMALL_DAMAGE_DEFAULT = 2.0;
|
||||
public static final double SMALL_DAMAGE_MIN = 0.0;
|
||||
public static final double SMALL_DAMAGE_MAX = 2147483647.0;
|
||||
|
||||
public static final String TARGET_RANGE_PATH = "weapon.lights_bane.target_range";
|
||||
public static final double TARGET_RANGE_DEFAULT = 2.0;
|
||||
public static final double TARGET_RANGE_MIN = 1.0;
|
||||
public static final double TARGET_RANGE_MAX = 64.0;
|
||||
|
||||
public LightsBane() {
|
||||
super(Tiers.IRON, new Item.Properties().attributes(ItemAttributeModifiers.builder()
|
||||
.add(Attributes.ATTACK_DAMAGE,
|
||||
@@ -59,6 +80,42 @@ public class LightsBane extends SwordItem {
|
||||
));
|
||||
}
|
||||
|
||||
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
||||
@Override
|
||||
public void onConfigLoad() {
|
||||
ConfigFactory.loadDoubleConfig(BIG_DAMAGE_PATH, configText("lights_bane_big_damage"), configTooltip("lights_bane_big_damage"), BIG_DAMAGE_DEFAULT, BIG_DAMAGE_MIN, BIG_DAMAGE_MAX);
|
||||
ConfigFactory.loadDoubleConfig(SMALL_DAMAGE_PATH, configText("lights_bane_small_damage"), configTooltip("lights_bane_small_damage"), SMALL_DAMAGE_DEFAULT, SMALL_DAMAGE_MIN, SMALL_DAMAGE_MAX);
|
||||
ConfigFactory.loadDoubleConfig(TARGET_RANGE_PATH, configText("lights_bane_target_range"), configTooltip("lights_bane_target_range"), TARGET_RANGE_DEFAULT, TARGET_RANGE_MIN, TARGET_RANGE_MAX);
|
||||
}
|
||||
};
|
||||
|
||||
private static Component configText(String key) {
|
||||
return Component.translatable(CONFIG_TRANSLATION_PREFIX + key);
|
||||
}
|
||||
|
||||
private static Component configTooltip(String key) {
|
||||
return Component.translatable(CONFIG_TRANSLATION_PREFIX + key + ".tooltip");
|
||||
}
|
||||
|
||||
public static double getBigDamage() {
|
||||
return Math.clamp(ConfigUtil.readDouble(BIG_DAMAGE_PATH, BIG_DAMAGE_DEFAULT), BIG_DAMAGE_MIN, BIG_DAMAGE_MAX);
|
||||
}
|
||||
|
||||
public static double getSmallDamage() {
|
||||
return Math.clamp(ConfigUtil.readDouble(SMALL_DAMAGE_PATH, SMALL_DAMAGE_DEFAULT), SMALL_DAMAGE_MIN, SMALL_DAMAGE_MAX);
|
||||
}
|
||||
|
||||
public static double getTargetRange() {
|
||||
return Math.clamp(ConfigUtil.readDouble(TARGET_RANGE_PATH, TARGET_RANGE_DEFAULT), TARGET_RANGE_MIN, TARGET_RANGE_MAX);
|
||||
}
|
||||
|
||||
public static final ConfigListItem CONFIG_LIST_ITEM = new ConfigListItem(
|
||||
"lights_bane",
|
||||
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/item/lights_bane.png"),
|
||||
Component.translatable("item.lzxnoneterraria.lights_bane"),
|
||||
CONFIG_DATA
|
||||
);
|
||||
|
||||
public static final DustParticleOptions PARTICLE = new DustParticleOptions(
|
||||
0.075f, 0.5f, 40, true, new Vector3f[]{
|
||||
new Vector3f(0.463F, 0.196F, 0.918F),
|
||||
@@ -146,7 +203,7 @@ public class LightsBane extends SwordItem {
|
||||
if(!summon.level().isClientSide() && summon.getOwner() instanceof Player player) {
|
||||
List<Entity> targets = summon.level().getEntitiesOfClass(Entity.class, summon.getBoundingBox(), FilterUtil.createTargetFilter(summon, summon.getOwner()));
|
||||
for(Entity target : targets) {
|
||||
float damage = customData.contains("big") && customData.getBoolean("big") ? (float) Config.lightsBaneBigDamage : (float) Config.lightsBaneSmallDamage;
|
||||
float damage = customData.contains("big") && customData.getBoolean("big") ? (float) getBigDamage() : (float) getSmallDamage();
|
||||
if(DamageUtil.attack(player, target, damage)) {
|
||||
|
||||
}
|
||||
@@ -167,9 +224,10 @@ public class LightsBane extends SwordItem {
|
||||
if(!player.getCooldowns().isOnCooldown(item)) {
|
||||
Entity target = event.getTarget();
|
||||
Vec3 pos = target.position();
|
||||
double targetRange = getTargetRange();
|
||||
AABB searchBox = new AABB(
|
||||
pos.x - Config.lightsBaneTargetRange, pos.y - Config.lightsBaneTargetRange, pos.z - Config.lightsBaneTargetRange,
|
||||
pos.x + Config.lightsBaneTargetRange, pos.y + Config.lightsBaneTargetRange, pos.z + Config.lightsBaneTargetRange
|
||||
pos.x - targetRange, pos.y - targetRange, pos.z - targetRange,
|
||||
pos.x + targetRange, pos.y + targetRange, pos.z + targetRange
|
||||
);
|
||||
List<Monster> entities = target.level().getEntitiesOfClass(
|
||||
Monster.class,
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.lzxnone.terraria.item.weapon.melee;
|
||||
|
||||
import com.lzxnone.terraria.Config;
|
||||
import com.lzxnone.terraria.LzxnoneTerraria;
|
||||
import com.lzxnone.terraria.ModSounds;
|
||||
import com.lzxnone.terraria.entity.ModEntities;
|
||||
@@ -42,10 +41,88 @@ import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.*;
|
||||
import org.joml.Vector3f;
|
||||
import org.jspecify.annotations.NonNull;
|
||||
import com.lzxnone.terraria.ui.config.ConfigFactory;
|
||||
import com.lzxnone.terraria.ui.config.ConfigListItem;
|
||||
import com.lzxnone.terraria.ui.config.ConfigUtil;
|
||||
import com.lzxnone.terraria.ui.config.IConfigData;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Mace extends SwordItem {
|
||||
private static final String CONFIG_TRANSLATION_PREFIX = "lzxnoneterraria.configuration.";
|
||||
|
||||
public static final String PROJECTILE_SPEED_PATH = "weapon.mace.projectile_speed";
|
||||
public static final double PROJECTILE_SPEED_DEFAULT = 2.0;
|
||||
public static final double PROJECTILE_SPEED_MIN = 0.0;
|
||||
public static final double PROJECTILE_SPEED_MAX = 10.0;
|
||||
|
||||
public static final String GRAVITY_PATH = "weapon.mace.gravity";
|
||||
public static final double GRAVITY_DEFAULT = 0.75;
|
||||
public static final double GRAVITY_MIN = 0.0;
|
||||
public static final double GRAVITY_MAX = 5.0;
|
||||
|
||||
public static final String DAMAGE_PATH = "weapon.mace.damage";
|
||||
public static final double DAMAGE_DEFAULT = 4.0;
|
||||
public static final double DAMAGE_MIN = 0.0;
|
||||
public static final double DAMAGE_MAX = 2147483647.0;
|
||||
|
||||
public static final String FLY_TIME_PATH = "weapon.mace.fly_time";
|
||||
public static final int FLY_TIME_DEFAULT = 10;
|
||||
public static final int FLY_TIME_MIN = 1;
|
||||
public static final int FLY_TIME_MAX = 100;
|
||||
|
||||
public static final String MAX_RANGE_PATH = "weapon.mace.max_range";
|
||||
public static final double MAX_RANGE_DEFAULT = 32.0;
|
||||
public static final double MAX_RANGE_MIN = 1.0;
|
||||
public static final double MAX_RANGE_MAX = 512.0;
|
||||
|
||||
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
||||
@Override
|
||||
public void onConfigLoad() {
|
||||
ConfigFactory.loadDoubleConfig(PROJECTILE_SPEED_PATH, configText("mace_projectile_speed"), configTooltip("mace_projectile_speed"), PROJECTILE_SPEED_DEFAULT, PROJECTILE_SPEED_MIN, PROJECTILE_SPEED_MAX);
|
||||
ConfigFactory.loadDoubleConfig(GRAVITY_PATH, configText("mace_gravity"), configTooltip("mace_gravity"), GRAVITY_DEFAULT, GRAVITY_MIN, GRAVITY_MAX);
|
||||
ConfigFactory.loadDoubleConfig(DAMAGE_PATH, configText("mace_damage"), configTooltip("mace_damage"), DAMAGE_DEFAULT, DAMAGE_MIN, DAMAGE_MAX);
|
||||
ConfigFactory.loadIntConfig(FLY_TIME_PATH, configText("mace_fly_time"), configTooltip("mace_fly_time"), FLY_TIME_DEFAULT, FLY_TIME_MIN, FLY_TIME_MAX);
|
||||
ConfigFactory.loadDoubleConfig(MAX_RANGE_PATH, configText("mace_max_range"), configTooltip("mace_max_range"), MAX_RANGE_DEFAULT, MAX_RANGE_MIN, MAX_RANGE_MAX);
|
||||
}
|
||||
};
|
||||
|
||||
private static Component configText(String key) {
|
||||
return Component.translatable(CONFIG_TRANSLATION_PREFIX + key);
|
||||
}
|
||||
|
||||
private static Component configTooltip(String key) {
|
||||
return Component.translatable(CONFIG_TRANSLATION_PREFIX + key + ".tooltip");
|
||||
}
|
||||
|
||||
public static double getProjectileSpeed() {
|
||||
return Math.clamp(ConfigUtil.readDouble(PROJECTILE_SPEED_PATH, PROJECTILE_SPEED_DEFAULT), PROJECTILE_SPEED_MIN, PROJECTILE_SPEED_MAX);
|
||||
}
|
||||
|
||||
public static double getGravity() {
|
||||
return Math.clamp(ConfigUtil.readDouble(GRAVITY_PATH, GRAVITY_DEFAULT), GRAVITY_MIN, GRAVITY_MAX);
|
||||
}
|
||||
|
||||
public static double getDamage() {
|
||||
return Math.clamp(ConfigUtil.readDouble(DAMAGE_PATH, DAMAGE_DEFAULT), DAMAGE_MIN, DAMAGE_MAX);
|
||||
}
|
||||
|
||||
public static int getFlyTime() {
|
||||
return Math.clamp(ConfigUtil.readInt(FLY_TIME_PATH, FLY_TIME_DEFAULT), FLY_TIME_MIN, FLY_TIME_MAX);
|
||||
}
|
||||
|
||||
public static double getMaxRange() {
|
||||
return Math.clamp(ConfigUtil.readDouble(MAX_RANGE_PATH, MAX_RANGE_DEFAULT), MAX_RANGE_MIN, MAX_RANGE_MAX);
|
||||
}
|
||||
|
||||
public static final ConfigListItem CONFIG_LIST_ITEM = new ConfigListItem(
|
||||
"mace",
|
||||
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/item/mace.png"),
|
||||
Component.translatable("item.lzxnoneterraria.mace"),
|
||||
CONFIG_DATA
|
||||
);
|
||||
|
||||
public Mace() {
|
||||
super(Tiers.IRON, new Item.Properties().attributes(ItemAttributeModifiers.builder()
|
||||
.add(Attributes.ATTACK_DAMAGE,
|
||||
@@ -217,7 +294,7 @@ public class Mace extends SwordItem {
|
||||
FilterUtil.createTargetFilter(projectile, player)
|
||||
);
|
||||
for(Entity target : targets) {
|
||||
if(DamageUtil.attack(player, target, (float) Config.maceDamage)) {
|
||||
if(DamageUtil.attack(player, target, (float) getDamage())) {
|
||||
target.invulnerableTime = 15;
|
||||
}
|
||||
}
|
||||
@@ -378,7 +455,7 @@ public class Mace extends SwordItem {
|
||||
int flyTime = customData.contains("flyTime") ? customData.getInt("flyTime") : 0;
|
||||
int age = summon.getEntityData().get(StaticSummon.AGE);
|
||||
if(age < flyTime) {
|
||||
summon.setDeltaMovement(summon.getLookAngle().normalize().scale(Config.maceProjectileSpeed));
|
||||
summon.setDeltaMovement(summon.getLookAngle().normalize().scale(getProjectileSpeed()));
|
||||
BlockHitResult blockHitResult = CollisionUtil.checkBlockHit(summon, summon.position().add(summon.getDeltaMovement()));
|
||||
if(blockHitResult.getType() != HitResult.Type.MISS) {
|
||||
summon.getEntityData().set(StaticSummon.AGE, flyTime);
|
||||
@@ -395,7 +472,7 @@ public class Mace extends SwordItem {
|
||||
}else {
|
||||
Vec3 moveDir = player.getEyePosition().subtract(summon.position());
|
||||
double dist = moveDir.length();
|
||||
summon.setDeltaMovement(moveDir.normalize().scale(Config.maceProjectileSpeed));
|
||||
summon.setDeltaMovement(moveDir.normalize().scale(getProjectileSpeed()));
|
||||
if(dist < 2.0f) {
|
||||
onDied(summon);
|
||||
return;
|
||||
@@ -423,7 +500,7 @@ public class Mace extends SwordItem {
|
||||
}
|
||||
}
|
||||
double dist = summon.position().subtract(player.position()).length();
|
||||
if(dist > Config.maceMaxRange) {
|
||||
if(dist > getMaxRange()) {
|
||||
CustomData.update(DataComponents.CUSTOM_DATA, stack,
|
||||
tag -> tag.putInt("state", State.THROWING_BACK.ordinal()));
|
||||
}
|
||||
@@ -431,16 +508,16 @@ public class Mace extends SwordItem {
|
||||
EntityHitResult entityHitResult = CollisionUtil.checkEntityHit(summon, summon.position().add(summon.getDeltaMovement()));
|
||||
if(entityHitResult != null) {
|
||||
Entity target = entityHitResult.getEntity();
|
||||
if(DamageUtil.attack(player, target, (float) Config.maceDamage)) {
|
||||
if(DamageUtil.attack(player, target, (float) getDamage())) {
|
||||
target.invulnerableTime = 10;
|
||||
}
|
||||
}
|
||||
}
|
||||
}else if(state == State.DROPPING.ordinal()) {
|
||||
Vec3 g = new Vec3(0, -1, 0);
|
||||
summon.setDeltaMovement(g.scale(Config.maceGravity));
|
||||
summon.setDeltaMovement(g.scale(getGravity()));
|
||||
double dist = summon.position().subtract(player.position()).length();
|
||||
if(dist > Config.maceMaxRange) {
|
||||
if(dist > getMaxRange()) {
|
||||
CustomData.update(DataComponents.CUSTOM_DATA, stack,
|
||||
tag -> tag.putInt("state", State.THROWING_BACK.ordinal()));
|
||||
}
|
||||
@@ -450,16 +527,16 @@ public class Mace extends SwordItem {
|
||||
FilterUtil.createTargetFilter(summon, summon.getOwner())
|
||||
);
|
||||
for(Entity target : targets) {
|
||||
DamageUtil.attack(player, target, (float) Config.maceDamage);
|
||||
DamageUtil.attack(player, target, (float) getDamage());
|
||||
}
|
||||
}else if(state == State.THROWING_BACK.ordinal()){
|
||||
Vec3 moveDir = player.getEyePosition().subtract(summon.position());
|
||||
double dist = moveDir.length();
|
||||
summon.setDeltaMovement(moveDir.normalize().scale(Config.maceProjectileSpeed));
|
||||
summon.setDeltaMovement(moveDir.normalize().scale(getProjectileSpeed()));
|
||||
EntityHitResult entityHitResult = CollisionUtil.checkEntityHit(summon, summon.position().add(summon.getDeltaMovement()));
|
||||
if(entityHitResult != null) {
|
||||
Entity target = entityHitResult.getEntity();
|
||||
if(DamageUtil.attack(player, target, (float) Config.maceDamage)) {
|
||||
if(DamageUtil.attack(player, target, (float) getDamage())) {
|
||||
target.invulnerableTime = 10;
|
||||
}
|
||||
}
|
||||
@@ -553,7 +630,7 @@ public class Mace extends SwordItem {
|
||||
summon.yRotO = xyRot[1];
|
||||
|
||||
CompoundTag customData = new CompoundTag();
|
||||
customData.putInt("flyTime", Config.maceFlyTime);
|
||||
customData.putInt("flyTime", getFlyTime());
|
||||
summon.getEntityData().set(StaticSummon.CUSTOM_DATA, customData);
|
||||
|
||||
summon.setNoGravity(true);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.lzxnone.terraria.item.weapon.melee;
|
||||
|
||||
import com.lzxnone.terraria.Config;
|
||||
import com.lzxnone.terraria.LzxnoneTerraria;
|
||||
import com.lzxnone.terraria.ModSounds;
|
||||
import com.lzxnone.terraria.entity.ModEntities;
|
||||
@@ -10,6 +9,10 @@ import com.lzxnone.terraria.entity.summon.StaticSummon;
|
||||
import com.lzxnone.terraria.entity.summon.StaticSummonBehaviors;
|
||||
import com.lzxnone.terraria.item.ModItems;
|
||||
import com.lzxnone.terraria.particle.DustParticleOptions;
|
||||
import com.lzxnone.terraria.ui.config.ConfigFactory;
|
||||
import com.lzxnone.terraria.ui.config.ConfigListItem;
|
||||
import com.lzxnone.terraria.ui.config.ConfigUtil;
|
||||
import com.lzxnone.terraria.ui.config.IConfigData;
|
||||
import com.lzxnone.terraria.utils.*;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
@@ -19,6 +22,7 @@ import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.texture.OverlayTexture;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
@@ -39,6 +43,23 @@ import org.joml.Vector3f;
|
||||
import java.util.List;
|
||||
|
||||
public class Meowmere extends SwordItem {
|
||||
private static final String CONFIG_TRANSLATION_PREFIX = "lzxnoneterraria.configuration.";
|
||||
|
||||
public static final String DAMAGE_PATH = "weapon.meowmere.damage";
|
||||
public static final double DAMAGE_DEFAULT = 20.0;
|
||||
public static final double DAMAGE_MIN = 0.0;
|
||||
public static final double DAMAGE_MAX = 2147483647.0;
|
||||
|
||||
public static final String GRAVITY_PATH = "weapon.meowmere.gravity";
|
||||
public static final double GRAVITY_DEFAULT = 0.025;
|
||||
public static final double GRAVITY_MIN = 0.0;
|
||||
public static final double GRAVITY_MAX = 1.0;
|
||||
|
||||
public static final String INITIAL_SPEED_PATH = "weapon.meowmere.initial_speed";
|
||||
public static final double INITIAL_SPEED_DEFAULT = 1.5;
|
||||
public static final double INITIAL_SPEED_MIN = 0.0;
|
||||
public static final double INITIAL_SPEED_MAX = 10.0;
|
||||
|
||||
public Meowmere() {
|
||||
super(Tiers.DIAMOND, new Item.Properties().attributes(ItemAttributeModifiers.builder()
|
||||
.add(Attributes.ATTACK_DAMAGE,
|
||||
@@ -51,6 +72,42 @@ public class Meowmere extends SwordItem {
|
||||
).rarity(Rarity.RARE));
|
||||
}
|
||||
|
||||
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
||||
@Override
|
||||
public void onConfigLoad() {
|
||||
ConfigFactory.loadDoubleConfig(DAMAGE_PATH, configText("meowmere_damage"), configTooltip("meowmere_damage"), DAMAGE_DEFAULT, DAMAGE_MIN, DAMAGE_MAX);
|
||||
ConfigFactory.loadDoubleConfig(GRAVITY_PATH, configText("meowmere_gravity"), configTooltip("meowmere_gravity"), GRAVITY_DEFAULT, GRAVITY_MIN, GRAVITY_MAX);
|
||||
ConfigFactory.loadDoubleConfig(INITIAL_SPEED_PATH, configText("meowmere_initial_speed"), configTooltip("meowmere_initial_speed"), INITIAL_SPEED_DEFAULT, INITIAL_SPEED_MIN, INITIAL_SPEED_MAX);
|
||||
}
|
||||
};
|
||||
|
||||
private static Component configText(String key) {
|
||||
return Component.translatable(CONFIG_TRANSLATION_PREFIX + key);
|
||||
}
|
||||
|
||||
private static Component configTooltip(String key) {
|
||||
return Component.translatable(CONFIG_TRANSLATION_PREFIX + key + ".tooltip");
|
||||
}
|
||||
|
||||
public static double getDamage() {
|
||||
return Math.clamp(ConfigUtil.readDouble(DAMAGE_PATH, DAMAGE_DEFAULT), DAMAGE_MIN, DAMAGE_MAX);
|
||||
}
|
||||
|
||||
public static double getGravity() {
|
||||
return Math.clamp(ConfigUtil.readDouble(GRAVITY_PATH, GRAVITY_DEFAULT), GRAVITY_MIN, GRAVITY_MAX);
|
||||
}
|
||||
|
||||
public static double getInitialSpeed() {
|
||||
return Math.clamp(ConfigUtil.readDouble(INITIAL_SPEED_PATH, INITIAL_SPEED_DEFAULT), INITIAL_SPEED_MIN, INITIAL_SPEED_MAX);
|
||||
}
|
||||
|
||||
public static final ConfigListItem CONFIG_LIST_ITEM = new ConfigListItem(
|
||||
"meowmere",
|
||||
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/item/meowmere.png"),
|
||||
Component.translatable("item.lzxnoneterraria.meowmere"),
|
||||
CONFIG_DATA
|
||||
);
|
||||
|
||||
public static final DustParticleOptions PARTICLE = new DustParticleOptions(
|
||||
0.05f, 0.5f, 40, true, new Vector3f[]{
|
||||
new Vector3f(1.00f, 0.50f, 0.50f), // 淡红 (柔粉红)
|
||||
@@ -136,7 +193,7 @@ public class Meowmere extends SwordItem {
|
||||
public void tick(StaticSummon summon) {
|
||||
this.checkBeforeTick(summon);
|
||||
Vec3 motion = summon.getDeltaMovement();
|
||||
motion = motion.add(0, -Config.meowmereGravity, 0);
|
||||
motion = motion.add(0, -getGravity(), 0);
|
||||
Vec3 up = MathUtil.toVec3(MathUtil.computeCoordinateSystem(motion.toVector3f(), 0)[1]).normalize();
|
||||
|
||||
summon.trailPositions.addFirst(summon.position().add(up.scale(0.5)));
|
||||
@@ -149,7 +206,7 @@ public class Meowmere extends SwordItem {
|
||||
if(entityHitResult != null) {
|
||||
Entity target = entityHitResult.getEntity();
|
||||
if(summon.getOwner() instanceof Player player) {
|
||||
if(DamageUtil.attack(player, target, (float) Config.meowmereDamage)) {
|
||||
if(DamageUtil.attack(player, target, (float) getDamage())) {
|
||||
if(customData.contains("hitEntity") && customData.getInt("hitEntity") < 4) {
|
||||
customData.putInt("hitEntity", customData.getInt("hitEntity") + 1);
|
||||
summon.getEntityData().set(StaticSummon.CUSTOM_DATA, customData);
|
||||
@@ -202,7 +259,7 @@ public class Meowmere extends SwordItem {
|
||||
),
|
||||
FilterUtil.createLivingTargetFilter(summon.getOwner())
|
||||
);
|
||||
for(LivingEntity livingEntity : hitEntities) livingEntity.hurt(summon.damageSources().playerAttack(player), (float) Config.meowmereDamage);
|
||||
for(LivingEntity livingEntity : hitEntities) livingEntity.hurt(summon.damageSources().playerAttack(player), (float) getDamage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -296,7 +353,7 @@ public class Meowmere extends SwordItem {
|
||||
float[] xyRot = MathUtil.computeXYRot(dirs[0], dirs[1]);
|
||||
summon.setXRot(xyRot[0]);
|
||||
summon.setYRot(xyRot[1]);
|
||||
summon.setDeltaMovement(player.getLookAngle().normalize().scale(Config.meowmereInitialSpeed));
|
||||
summon.setDeltaMovement(player.getLookAngle().normalize().scale(getInitialSpeed()));
|
||||
level.addFreshEntity(summon);
|
||||
}else {
|
||||
ParticleUtil.addParticles(
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.lzxnone.terraria.item.weapon.melee;
|
||||
|
||||
import com.lzxnone.terraria.Config;
|
||||
import com.lzxnone.terraria.LzxnoneTerraria;
|
||||
import com.lzxnone.terraria.entity.ModEntities;
|
||||
import com.lzxnone.terraria.entity.ModRenderTypes;
|
||||
@@ -38,8 +37,46 @@ import net.neoforged.neoforge.event.entity.player.AttackEntityEvent;
|
||||
import net.neoforged.neoforge.event.entity.player.PlayerInteractEvent;
|
||||
import org.joml.Matrix4f;
|
||||
import org.joml.Vector3f;
|
||||
import com.lzxnone.terraria.ui.config.ConfigFactory;
|
||||
import com.lzxnone.terraria.ui.config.ConfigListItem;
|
||||
import com.lzxnone.terraria.ui.config.ConfigUtil;
|
||||
import com.lzxnone.terraria.ui.config.IConfigData;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
||||
public class Muramasa extends SwordItem {
|
||||
private static final String CONFIG_TRANSLATION_PREFIX = "lzxnoneterraria.configuration.";
|
||||
|
||||
public static final String BEAM_DAMAGE_PATH = "weapon.muramasa.beam_damage";
|
||||
public static final double BEAM_DAMAGE_DEFAULT = 2.5;
|
||||
public static final double BEAM_DAMAGE_MIN = 0.0;
|
||||
public static final double BEAM_DAMAGE_MAX = 2147483647.0;
|
||||
|
||||
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
||||
@Override
|
||||
public void onConfigLoad() {
|
||||
ConfigFactory.loadDoubleConfig(BEAM_DAMAGE_PATH, configText("muramasa_beam_damage"), configTooltip("muramasa_beam_damage"), BEAM_DAMAGE_DEFAULT, BEAM_DAMAGE_MIN, BEAM_DAMAGE_MAX);
|
||||
}
|
||||
};
|
||||
|
||||
private static Component configText(String key) {
|
||||
return Component.translatable(CONFIG_TRANSLATION_PREFIX + key);
|
||||
}
|
||||
|
||||
private static Component configTooltip(String key) {
|
||||
return Component.translatable(CONFIG_TRANSLATION_PREFIX + key + ".tooltip");
|
||||
}
|
||||
|
||||
public static double getBeamDamage() {
|
||||
return Math.clamp(ConfigUtil.readDouble(BEAM_DAMAGE_PATH, BEAM_DAMAGE_DEFAULT), BEAM_DAMAGE_MIN, BEAM_DAMAGE_MAX);
|
||||
}
|
||||
|
||||
public static final ConfigListItem CONFIG_LIST_ITEM = new ConfigListItem(
|
||||
"muramasa",
|
||||
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/item/muramasa.png"),
|
||||
Component.translatable("item.lzxnoneterraria.muramasa"),
|
||||
CONFIG_DATA
|
||||
);
|
||||
|
||||
public Muramasa() {
|
||||
super(Tiers.IRON, new Item.Properties().attributes(ItemAttributeModifiers.builder()
|
||||
.add(Attributes.ATTACK_DAMAGE,
|
||||
@@ -224,7 +261,7 @@ public class Muramasa extends SwordItem {
|
||||
Entity owner = projectile.getOwner();
|
||||
if(owner == null) return;
|
||||
if(!FilterUtil.createTargetFilter(owner).test(target) || !(owner instanceof Player player)) return;
|
||||
if(DamageUtil.attack(player, target, (float) Config.muramasaBeamDamage)) {
|
||||
if(DamageUtil.attack(player, target, (float) getBeamDamage())) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.lzxnone.terraria.item.weapon.melee;
|
||||
|
||||
import com.lzxnone.terraria.Config;
|
||||
import com.lzxnone.terraria.LzxnoneTerraria;
|
||||
import com.lzxnone.terraria.ModSounds;
|
||||
import com.lzxnone.terraria.entity.ModEntities;
|
||||
@@ -43,10 +42,136 @@ import net.neoforged.neoforge.event.entity.player.PlayerInteractEvent;
|
||||
import net.neoforged.neoforge.network.PacketDistributor;
|
||||
import org.joml.Quaternionf;
|
||||
import org.joml.Vector3f;
|
||||
import com.lzxnone.terraria.ui.config.ConfigFactory;
|
||||
import com.lzxnone.terraria.ui.config.ConfigListItem;
|
||||
import com.lzxnone.terraria.ui.config.ConfigUtil;
|
||||
import com.lzxnone.terraria.ui.config.IConfigData;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class NightsEdge extends SwordItem {
|
||||
private static final String CONFIG_TRANSLATION_PREFIX = "lzxnoneterraria.configuration.";
|
||||
|
||||
public static final String PROJECTILE_ALIGN_TO_BLADE_PATH = "weapon.nights_edge.projectile_align_to_blade";
|
||||
public static final boolean PROJECTILE_ALIGN_TO_BLADE_DEFAULT = true;
|
||||
|
||||
public static final String ROTATE_RANGE_PATH = "weapon.nights_edge.rotate_range";
|
||||
public static final int ROTATE_RANGE_DEFAULT = 45;
|
||||
public static final int ROTATE_RANGE_MIN = 0;
|
||||
public static final int ROTATE_RANGE_MAX = 90;
|
||||
|
||||
public static final String PROJECTILE_ROTATE_RANGE_PATH = "weapon.nights_edge.projectile_rotate_range";
|
||||
public static final int PROJECTILE_ROTATE_RANGE_DEFAULT = 40;
|
||||
public static final int PROJECTILE_ROTATE_RANGE_MIN = 0;
|
||||
public static final int PROJECTILE_ROTATE_RANGE_MAX = 90;
|
||||
|
||||
public static final String MAX_HIT_COUNT_PATH = "weapon.nights_edge.max_hit_count";
|
||||
public static final int MAX_HIT_COUNT_DEFAULT = 2;
|
||||
public static final int MAX_HIT_COUNT_MIN = 0;
|
||||
public static final int MAX_HIT_COUNT_MAX = 100;
|
||||
|
||||
public static final String PROJECTILE_MAX_HIT_COUNT_PATH = "weapon.nights_edge.projectile_max_hit_count";
|
||||
public static final int PROJECTILE_MAX_HIT_COUNT_DEFAULT = 2;
|
||||
public static final int PROJECTILE_MAX_HIT_COUNT_MIN = 0;
|
||||
public static final int PROJECTILE_MAX_HIT_COUNT_MAX = 100;
|
||||
|
||||
public static final String DAMAGE_PATH = "weapon.nights_edge.damage";
|
||||
public static final double DAMAGE_DEFAULT = 7.0;
|
||||
public static final double DAMAGE_MIN = 0.0;
|
||||
public static final double DAMAGE_MAX = 2147483647.0;
|
||||
|
||||
public static final String PROJECTILE_DAMAGE_PATH = "weapon.nights_edge.projectile_damage";
|
||||
public static final double PROJECTILE_DAMAGE_DEFAULT = 7.0;
|
||||
public static final double PROJECTILE_DAMAGE_MIN = 0.0;
|
||||
public static final double PROJECTILE_DAMAGE_MAX = 2147483647.0;
|
||||
|
||||
public static final String PROJECTILE_SPEED_PATH = "weapon.nights_edge.projectile_speed";
|
||||
public static final double PROJECTILE_SPEED_DEFAULT = 0.25;
|
||||
public static final double PROJECTILE_SPEED_MIN = 0.0;
|
||||
public static final double PROJECTILE_SPEED_MAX = 10.0;
|
||||
|
||||
public static final String PROJECTILE_LIFETIME_PATH = "weapon.nights_edge.projectile_lifetime";
|
||||
public static final int PROJECTILE_LIFETIME_DEFAULT = 10;
|
||||
public static final int PROJECTILE_LIFETIME_MIN = 1;
|
||||
public static final int PROJECTILE_LIFETIME_MAX = 1200;
|
||||
|
||||
public static final String PROJECTILE_ROTATION_SPEED_PATH = "weapon.nights_edge.projectile_rotation_speed";
|
||||
public static final int PROJECTILE_ROTATION_SPEED_DEFAULT = 36;
|
||||
public static final int PROJECTILE_ROTATION_SPEED_MIN = 0;
|
||||
public static final int PROJECTILE_ROTATION_SPEED_MAX = 360;
|
||||
|
||||
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
||||
@Override
|
||||
public void onConfigLoad() {
|
||||
ConfigFactory.loadBooleanConfig(PROJECTILE_ALIGN_TO_BLADE_PATH, configText("nights_edge_projectile_align_to_blade"), configTooltip("nights_edge_projectile_align_to_blade"), PROJECTILE_ALIGN_TO_BLADE_DEFAULT);
|
||||
ConfigFactory.loadIntConfig(ROTATE_RANGE_PATH, configText("nights_edge_rotate_range"), configTooltip("nights_edge_rotate_range"), ROTATE_RANGE_DEFAULT, ROTATE_RANGE_MIN, ROTATE_RANGE_MAX);
|
||||
ConfigFactory.loadIntConfig(PROJECTILE_ROTATE_RANGE_PATH, configText("nights_edge_projectile_rotate_range"), configTooltip("nights_edge_projectile_rotate_range"), PROJECTILE_ROTATE_RANGE_DEFAULT, PROJECTILE_ROTATE_RANGE_MIN, PROJECTILE_ROTATE_RANGE_MAX);
|
||||
ConfigFactory.loadIntConfig(MAX_HIT_COUNT_PATH, configText("nights_edge_max_hit_count"), configTooltip("nights_edge_max_hit_count"), MAX_HIT_COUNT_DEFAULT, MAX_HIT_COUNT_MIN, MAX_HIT_COUNT_MAX);
|
||||
ConfigFactory.loadIntConfig(PROJECTILE_MAX_HIT_COUNT_PATH, configText("nights_edge_projectile_max_hit_count"), configTooltip("nights_edge_projectile_max_hit_count"), PROJECTILE_MAX_HIT_COUNT_DEFAULT, PROJECTILE_MAX_HIT_COUNT_MIN, PROJECTILE_MAX_HIT_COUNT_MAX);
|
||||
ConfigFactory.loadDoubleConfig(DAMAGE_PATH, configText("nights_edge_damage"), configTooltip("nights_edge_damage"), DAMAGE_DEFAULT, DAMAGE_MIN, DAMAGE_MAX);
|
||||
ConfigFactory.loadDoubleConfig(PROJECTILE_DAMAGE_PATH, configText("nights_edge_projectile_damage"), configTooltip("nights_edge_projectile_damage"), PROJECTILE_DAMAGE_DEFAULT, PROJECTILE_DAMAGE_MIN, PROJECTILE_DAMAGE_MAX);
|
||||
ConfigFactory.loadDoubleConfig(PROJECTILE_SPEED_PATH, configText("nights_edge_projectile_speed"), configTooltip("nights_edge_projectile_speed"), PROJECTILE_SPEED_DEFAULT, PROJECTILE_SPEED_MIN, PROJECTILE_SPEED_MAX);
|
||||
ConfigFactory.loadIntConfig(PROJECTILE_LIFETIME_PATH, configText("nights_edge_projectile_lifetime"), configTooltip("nights_edge_projectile_lifetime"), PROJECTILE_LIFETIME_DEFAULT, PROJECTILE_LIFETIME_MIN, PROJECTILE_LIFETIME_MAX);
|
||||
ConfigFactory.loadIntConfig(PROJECTILE_ROTATION_SPEED_PATH, configText("nights_edge_projectile_rotation_speed"), configTooltip("nights_edge_projectile_rotation_speed"), PROJECTILE_ROTATION_SPEED_DEFAULT, PROJECTILE_ROTATION_SPEED_MIN, PROJECTILE_ROTATION_SPEED_MAX);
|
||||
}
|
||||
};
|
||||
|
||||
private static Component configText(String key) {
|
||||
return Component.translatable(CONFIG_TRANSLATION_PREFIX + key);
|
||||
}
|
||||
|
||||
private static Component configTooltip(String key) {
|
||||
return Component.translatable(CONFIG_TRANSLATION_PREFIX + key + ".tooltip");
|
||||
}
|
||||
|
||||
public static boolean isProjectileAlignToBlade() {
|
||||
return ConfigUtil.readBoolean(PROJECTILE_ALIGN_TO_BLADE_PATH, PROJECTILE_ALIGN_TO_BLADE_DEFAULT);
|
||||
}
|
||||
|
||||
public static int getRotateRange() {
|
||||
return Math.clamp(ConfigUtil.readInt(ROTATE_RANGE_PATH, ROTATE_RANGE_DEFAULT), ROTATE_RANGE_MIN, ROTATE_RANGE_MAX);
|
||||
}
|
||||
|
||||
public static int getProjectileRotateRange() {
|
||||
return Math.clamp(ConfigUtil.readInt(PROJECTILE_ROTATE_RANGE_PATH, PROJECTILE_ROTATE_RANGE_DEFAULT), PROJECTILE_ROTATE_RANGE_MIN, PROJECTILE_ROTATE_RANGE_MAX);
|
||||
}
|
||||
|
||||
public static int getMaxHitCount() {
|
||||
return Math.clamp(ConfigUtil.readInt(MAX_HIT_COUNT_PATH, MAX_HIT_COUNT_DEFAULT), MAX_HIT_COUNT_MIN, MAX_HIT_COUNT_MAX);
|
||||
}
|
||||
|
||||
public static int getProjectileMaxHitCount() {
|
||||
return Math.clamp(ConfigUtil.readInt(PROJECTILE_MAX_HIT_COUNT_PATH, PROJECTILE_MAX_HIT_COUNT_DEFAULT), PROJECTILE_MAX_HIT_COUNT_MIN, PROJECTILE_MAX_HIT_COUNT_MAX);
|
||||
}
|
||||
|
||||
public static double getDamage() {
|
||||
return Math.clamp(ConfigUtil.readDouble(DAMAGE_PATH, DAMAGE_DEFAULT), DAMAGE_MIN, DAMAGE_MAX);
|
||||
}
|
||||
|
||||
public static double getProjectileDamage() {
|
||||
return Math.clamp(ConfigUtil.readDouble(PROJECTILE_DAMAGE_PATH, PROJECTILE_DAMAGE_DEFAULT), PROJECTILE_DAMAGE_MIN, PROJECTILE_DAMAGE_MAX);
|
||||
}
|
||||
|
||||
public static double getProjectileSpeed() {
|
||||
return Math.clamp(ConfigUtil.readDouble(PROJECTILE_SPEED_PATH, PROJECTILE_SPEED_DEFAULT), PROJECTILE_SPEED_MIN, PROJECTILE_SPEED_MAX);
|
||||
}
|
||||
|
||||
public static int getProjectileLifetime() {
|
||||
return Math.clamp(ConfigUtil.readInt(PROJECTILE_LIFETIME_PATH, PROJECTILE_LIFETIME_DEFAULT), PROJECTILE_LIFETIME_MIN, PROJECTILE_LIFETIME_MAX);
|
||||
}
|
||||
|
||||
public static int getProjectileRotationSpeed() {
|
||||
return Math.clamp(ConfigUtil.readInt(PROJECTILE_ROTATION_SPEED_PATH, PROJECTILE_ROTATION_SPEED_DEFAULT), PROJECTILE_ROTATION_SPEED_MIN, PROJECTILE_ROTATION_SPEED_MAX);
|
||||
}
|
||||
|
||||
public static final ConfigListItem CONFIG_LIST_ITEM = new ConfigListItem(
|
||||
"nights_edge",
|
||||
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/item/nights_edge.png"),
|
||||
Component.translatable("item.lzxnoneterraria.nights_edge"),
|
||||
CONFIG_DATA
|
||||
);
|
||||
|
||||
public NightsEdge() {
|
||||
super(Tiers.IRON, new Item.Properties().attributes(ItemAttributeModifiers.builder()
|
||||
.add(Attributes.ATTACK_DAMAGE,
|
||||
@@ -191,8 +316,8 @@ public class NightsEdge extends SwordItem {
|
||||
CompoundTag custom_data = beam.getEntityData().get(SwordBeam.CUSTOM_DATA);
|
||||
if(custom_data.contains("hitEntityCount")) {
|
||||
int count = custom_data.getInt("hitEntityCount");
|
||||
if(count < Config.nightsEdgeMaxHitCount) {
|
||||
if(DamageUtil.attack(player, target, (float) Config.nightsEdgeDamage)) {
|
||||
if(count < getMaxHitCount()) {
|
||||
if(DamageUtil.attack(player, target, (float) getDamage())) {
|
||||
ParticleUtil.addParticles(
|
||||
(ServerLevel) target.level(), ModParticles.NIGHTS_EDGE_HIT_PARTICLE.get(),
|
||||
new Vec3(target.getX(), target.getY() + target.getBbHeight() / 2.0, target.getZ()), new Vec3(0, 0, 0),
|
||||
@@ -211,7 +336,7 @@ public class NightsEdge extends SwordItem {
|
||||
|
||||
@Override
|
||||
public void generate(Entity entity, CompoundTag beamData) {
|
||||
int randomAngle = (int) (Config.nightsEdgeRotateRange * (Math.random() * 2 - 1));
|
||||
int randomAngle = (int) (getRotateRange() * (Math.random() * 2 - 1));
|
||||
beamData.putInt("rotate", randomAngle);
|
||||
ISwordBeamBehavior.super.generate(entity, beamData);
|
||||
if(entity instanceof Player player) summon(player, randomAngle);
|
||||
@@ -329,11 +454,11 @@ public class NightsEdge extends SwordItem {
|
||||
//碰撞计算
|
||||
if(!summon.level().isClientSide() && customData.contains("hitCount") && summon.getOwner() instanceof Player player) {
|
||||
int count = customData.getInt("hitCount");
|
||||
if(count < Config.nightsEdgeProjectileMaxHitCount) {
|
||||
if(count < getProjectileMaxHitCount()) {
|
||||
List<Entity> targets = summon.level().getEntitiesOfClass(Entity.class, summon.getBoundingBox(), FilterUtil.createTargetFilter(summon, summon.getOwner()));
|
||||
for(Entity target : targets) {
|
||||
if(count >= Config.nightsEdgeProjectileMaxHitCount) break;
|
||||
if(DamageUtil.attack(player, target, (float) Config.nightsEdgeProjectileDamage)) {
|
||||
if(count >= getProjectileMaxHitCount()) break;
|
||||
if(DamageUtil.attack(player, target, (float) getProjectileDamage())) {
|
||||
count++;
|
||||
ParticleUtil.addParticles(
|
||||
(ServerLevel) target.level(), ModParticles.NIGHTS_EDGE_HIT_PARTICLE.get(),
|
||||
@@ -345,7 +470,7 @@ public class NightsEdge extends SwordItem {
|
||||
}
|
||||
if(!targets.isEmpty()) customData.putInt("hitCount", count);
|
||||
}
|
||||
if(count >= Config.nightsEdgeProjectileMaxHitCount) this.onDied(summon);
|
||||
if(count >= getProjectileMaxHitCount()) this.onDied(summon);
|
||||
}
|
||||
|
||||
ClipContext context = new ClipContext(
|
||||
@@ -377,7 +502,7 @@ public class NightsEdge extends SwordItem {
|
||||
Vec3 pos = new Vec3(player.getX(), player.getEyeY() - 0.1, player.getZ());
|
||||
summon.setPos(pos);
|
||||
|
||||
if(!Config.nightsEdgeProjectileAlignToBlade) randomAngle = (int) (Config.nightsEdgeProjectileRotateRange * (Math.random() * 2 - 1));
|
||||
if(!isProjectileAlignToBlade()) randomAngle = (int) (getProjectileRotateRange() * (Math.random() * 2 - 1));
|
||||
|
||||
Vector3f[] dirs = MathUtil.computeCoordinateSystem(player);
|
||||
dirs = MathUtil.rotateCoordinateSystem(dirs[0], dirs[2], randomAngle);
|
||||
@@ -389,9 +514,9 @@ public class NightsEdge extends SwordItem {
|
||||
|
||||
summon.getEntityData().set(StaticSummon.BEHAVIOR, StaticSummonBehaviors.NIGHTS_EDGE_BEAM);
|
||||
summon.getEntityData().set(StaticSummon.RENDER_MODE, "custom");
|
||||
summon.getEntityData().set(StaticSummon.LIFETIME, Config.nightsEdgeProjectileLifetime);
|
||||
summon.getEntityData().set(StaticSummon.LIFETIME, getProjectileLifetime());
|
||||
summon.getEntityData().set(StaticSummon.RZP, randomAngle);
|
||||
summon.getEntityData().set(StaticSummon.RZPS, Config.nightsEdgeProjectileRotationSpeed);
|
||||
summon.getEntityData().set(StaticSummon.RZPS, getProjectileRotationSpeed());
|
||||
summon.getEntityData().set(StaticSummon.GLOW, true);
|
||||
summon.setNoGravity(true);
|
||||
summon.noPhysics = true;
|
||||
@@ -428,7 +553,7 @@ public class NightsEdge extends SwordItem {
|
||||
customData.putFloat("rightZ", dirs[2].z);
|
||||
summon.getEntityData().set(StaticSummon.CUSTOM_DATA, customData);
|
||||
|
||||
summon.setDeltaMovement(player.getLookAngle().normalize().scale(Config.nightsEdgeProjectileSpeed));
|
||||
summon.setDeltaMovement(player.getLookAngle().normalize().scale(getProjectileSpeed()));
|
||||
|
||||
player.level().addFreshEntity(summon);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.lzxnone.terraria.item.weapon.melee;
|
||||
|
||||
import com.lzxnone.terraria.Config;
|
||||
import com.lzxnone.terraria.LzxnoneTerraria;
|
||||
import com.lzxnone.terraria.ModSounds;
|
||||
import com.lzxnone.terraria.entity.ModEntities;
|
||||
@@ -12,8 +11,13 @@ import com.lzxnone.terraria.entity.summon.StaticSummon;
|
||||
import com.lzxnone.terraria.entity.summon.StaticSummonBehaviors;
|
||||
import com.lzxnone.terraria.item.ModItems;
|
||||
import com.lzxnone.terraria.particle.ModParticles;
|
||||
import com.lzxnone.terraria.ui.config.ConfigFactory;
|
||||
import com.lzxnone.terraria.ui.config.ConfigListItem;
|
||||
import com.lzxnone.terraria.ui.config.ConfigUtil;
|
||||
import com.lzxnone.terraria.ui.config.IConfigData;
|
||||
import com.lzxnone.terraria.utils.*;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
@@ -35,6 +39,38 @@ import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
public class Seedler extends SwordItem {
|
||||
private static final String CONFIG_TRANSLATION_PREFIX = "lzxnoneterraria.configuration.";
|
||||
|
||||
public static final String NUT_GRAVITY_PATH = "weapon.seedler.nut_gravity";
|
||||
public static final double NUT_GRAVITY_DEFAULT = 0.075;
|
||||
public static final double NUT_GRAVITY_MIN = 0.0;
|
||||
public static final double NUT_GRAVITY_MAX = 1.0;
|
||||
|
||||
public static final String NUT_BOUNCE_PATH = "weapon.seedler.nut_bounce";
|
||||
public static final double NUT_BOUNCE_DEFAULT = 0.5;
|
||||
public static final double NUT_BOUNCE_MIN = 0.0;
|
||||
public static final double NUT_BOUNCE_MAX = 1.0;
|
||||
|
||||
public static final String NUT_INITIAL_SPEED_PATH = "weapon.seedler.nut_initial_speed";
|
||||
public static final double NUT_INITIAL_SPEED_DEFAULT = 0.75;
|
||||
public static final double NUT_INITIAL_SPEED_MIN = 0.0;
|
||||
public static final double NUT_INITIAL_SPEED_MAX = 10.0;
|
||||
|
||||
public static final String THORN_DAMAGE_PATH = "weapon.seedler.thorn_damage";
|
||||
public static final double THORN_DAMAGE_DEFAULT = 2.0;
|
||||
public static final double THORN_DAMAGE_MIN = 0.0;
|
||||
public static final double THORN_DAMAGE_MAX = 2147483647.0;
|
||||
|
||||
public static final String THORN_LIFETIME_PATH = "weapon.seedler.thorn_lifetime";
|
||||
public static final int THORN_LIFETIME_DEFAULT = 30;
|
||||
public static final int THORN_LIFETIME_MIN = 1;
|
||||
public static final int THORN_LIFETIME_MAX = 1200;
|
||||
|
||||
public static final String THORN_SPEED_PATH = "weapon.seedler.thorn_speed";
|
||||
public static final double THORN_SPEED_DEFAULT = 2.0;
|
||||
public static final double THORN_SPEED_MIN = 0.0;
|
||||
public static final double THORN_SPEED_MAX = 10.0;
|
||||
|
||||
public Seedler() {
|
||||
super(Tiers.DIAMOND, new Item.Properties().attributes(ItemAttributeModifiers.builder()
|
||||
.add(Attributes.ATTACK_DAMAGE,
|
||||
@@ -47,18 +83,69 @@ public class Seedler extends SwordItem {
|
||||
).rarity(Rarity.UNCOMMON));
|
||||
}
|
||||
|
||||
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
||||
@Override
|
||||
public void onConfigLoad() {
|
||||
ConfigFactory.loadDoubleConfig(NUT_GRAVITY_PATH, configText("seedler_nut_gravity"), configTooltip("seedler_nut_gravity"), NUT_GRAVITY_DEFAULT, NUT_GRAVITY_MIN, NUT_GRAVITY_MAX);
|
||||
ConfigFactory.loadDoubleConfig(NUT_BOUNCE_PATH, configText("seedler_nut_bounce"), configTooltip("seedler_nut_bounce"), NUT_BOUNCE_DEFAULT, NUT_BOUNCE_MIN, NUT_BOUNCE_MAX);
|
||||
ConfigFactory.loadDoubleConfig(NUT_INITIAL_SPEED_PATH, configText("seedler_nut_initial_speed"), configTooltip("seedler_nut_initial_speed"), NUT_INITIAL_SPEED_DEFAULT, NUT_INITIAL_SPEED_MIN, NUT_INITIAL_SPEED_MAX);
|
||||
ConfigFactory.loadDoubleConfig(THORN_DAMAGE_PATH, configText("seedler_thorn_damage"), configTooltip("seedler_thorn_damage"), THORN_DAMAGE_DEFAULT, THORN_DAMAGE_MIN, THORN_DAMAGE_MAX);
|
||||
ConfigFactory.loadIntConfig(THORN_LIFETIME_PATH, configText("seedler_thorn_lifetime"), configTooltip("seedler_thorn_lifetime"), THORN_LIFETIME_DEFAULT, THORN_LIFETIME_MIN, THORN_LIFETIME_MAX);
|
||||
ConfigFactory.loadDoubleConfig(THORN_SPEED_PATH, configText("seedler_thorn_speed"), configTooltip("seedler_thorn_speed"), THORN_SPEED_DEFAULT, THORN_SPEED_MIN, THORN_SPEED_MAX);
|
||||
}
|
||||
};
|
||||
|
||||
private static Component configText(String key) {
|
||||
return Component.translatable(CONFIG_TRANSLATION_PREFIX + key);
|
||||
}
|
||||
|
||||
private static Component configTooltip(String key) {
|
||||
return Component.translatable(CONFIG_TRANSLATION_PREFIX + key + ".tooltip");
|
||||
}
|
||||
|
||||
public static double getNutGravity() {
|
||||
return Math.clamp(ConfigUtil.readDouble(NUT_GRAVITY_PATH, NUT_GRAVITY_DEFAULT), NUT_GRAVITY_MIN, NUT_GRAVITY_MAX);
|
||||
}
|
||||
|
||||
public static double getNutBounce() {
|
||||
return Math.clamp(ConfigUtil.readDouble(NUT_BOUNCE_PATH, NUT_BOUNCE_DEFAULT), NUT_BOUNCE_MIN, NUT_BOUNCE_MAX);
|
||||
}
|
||||
|
||||
public static double getNutInitialSpeed() {
|
||||
return Math.clamp(ConfigUtil.readDouble(NUT_INITIAL_SPEED_PATH, NUT_INITIAL_SPEED_DEFAULT), NUT_INITIAL_SPEED_MIN, NUT_INITIAL_SPEED_MAX);
|
||||
}
|
||||
|
||||
public static double getThornDamage() {
|
||||
return Math.clamp(ConfigUtil.readDouble(THORN_DAMAGE_PATH, THORN_DAMAGE_DEFAULT), THORN_DAMAGE_MIN, THORN_DAMAGE_MAX);
|
||||
}
|
||||
|
||||
public static int getThornLifetime() {
|
||||
return Math.clamp(ConfigUtil.readInt(THORN_LIFETIME_PATH, THORN_LIFETIME_DEFAULT), THORN_LIFETIME_MIN, THORN_LIFETIME_MAX);
|
||||
}
|
||||
|
||||
public static double getThornSpeed() {
|
||||
return Math.clamp(ConfigUtil.readDouble(THORN_SPEED_PATH, THORN_SPEED_DEFAULT), THORN_SPEED_MIN, THORN_SPEED_MAX);
|
||||
}
|
||||
|
||||
public static final ConfigListItem CONFIG_LIST_ITEM = new ConfigListItem(
|
||||
"seedler",
|
||||
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/item/seedler.png"),
|
||||
Component.translatable("item.lzxnoneterraria.seedler"),
|
||||
CONFIG_DATA
|
||||
);
|
||||
|
||||
public static final IStaticSummonBehavior SUMMON_BEHAVIOR = new IStaticSummonBehavior() {
|
||||
@Override
|
||||
public void tick(StaticSummon summon) {
|
||||
this.checkBeforeTick(summon);
|
||||
Vec3 motion = summon.getDeltaMovement();
|
||||
motion = motion.add(0, -Config.seedlerNutGravity, 0);
|
||||
motion = motion.add(0, -getNutGravity(), 0);
|
||||
|
||||
EntityHitResult entityHitResult = CollisionUtil.checkEntityHit(summon, summon.position().add(motion));
|
||||
if(entityHitResult != null) {
|
||||
Entity target = entityHitResult.getEntity();
|
||||
if(summon.getOwner() instanceof Player player) {
|
||||
if(DamageUtil.attack(player, target, (float) Config.seedlerThornDamage)) {
|
||||
if(DamageUtil.attack(player, target, (float) getThornDamage())) {
|
||||
target.invulnerableTime = 2;
|
||||
}
|
||||
}
|
||||
@@ -75,15 +162,15 @@ public class Seedler extends SwordItem {
|
||||
double mz = motion.z;
|
||||
|
||||
switch(face.getAxis()) {
|
||||
case X -> mx = -mx * Config.seedlerNutBounce;
|
||||
case Y -> my = -my * Config.seedlerNutBounce;
|
||||
case Z -> mz = -mz * Config.seedlerNutBounce;
|
||||
case X -> mx = -mx * getNutBounce();
|
||||
case Y -> my = -my * getNutBounce();
|
||||
case Z -> mz = -mz * getNutBounce();
|
||||
}
|
||||
|
||||
if(face == Direction.UP && Math.abs(my) < 0.1) {
|
||||
my = 0;
|
||||
mx *= Config.seedlerNutBounce;
|
||||
mz *= Config.seedlerNutBounce;
|
||||
mx *= getNutBounce();
|
||||
mz *= getNutBounce();
|
||||
}
|
||||
|
||||
motion = new Vec3(mx, my, mz);
|
||||
@@ -129,8 +216,8 @@ public class Seedler extends SwordItem {
|
||||
proj.getEntityData().set(StaticProjectile.SCALE_X, 0.5f);
|
||||
proj.getEntityData().set(StaticProjectile.SCALE_Y, 0.5f);
|
||||
proj.getEntityData().set(StaticProjectile.RXP, 90);
|
||||
proj.getEntityData().set(StaticProjectile.LIFETIME, Config.seedlerThornLifetime);
|
||||
proj.getEntityData().set(StaticProjectile.EXPRESSION_Z, String.format("%.3f*t", Config.seedlerThornSpeed));
|
||||
proj.getEntityData().set(StaticProjectile.LIFETIME, getThornLifetime());
|
||||
proj.getEntityData().set(StaticProjectile.EXPRESSION_Z, String.format("%.3f*t", getThornSpeed()));
|
||||
|
||||
proj.setDeltaMovement(MathUtil.toVec3(dirs[0]));
|
||||
summon.level().addFreshEntity(proj);
|
||||
@@ -174,7 +261,7 @@ public class Seedler extends SwordItem {
|
||||
Entity owner = projectile.getOwner();
|
||||
if(owner == null) return;
|
||||
if(!FilterUtil.createTargetFilter(owner).test(target) || !(owner instanceof Player player)) return;
|
||||
if(DamageUtil.attack(player, target, (float) Config.seedlerThornDamage)) {
|
||||
if(DamageUtil.attack(player, target, (float) getThornDamage())) {
|
||||
target.invulnerableTime = 2;
|
||||
onDied(projectile);
|
||||
}
|
||||
@@ -213,7 +300,7 @@ public class Seedler extends SwordItem {
|
||||
float[] xyRot = MathUtil.computeXYRot(dirs[0], dirs[1]);
|
||||
summon.setXRot(xyRot[0]);
|
||||
summon.setYRot(xyRot[1]);
|
||||
summon.setDeltaMovement(player.getLookAngle().normalize().scale(Config.seedlerNutInitialSpeed));
|
||||
summon.setDeltaMovement(player.getLookAngle().normalize().scale(getNutInitialSpeed()));
|
||||
level.addFreshEntity(summon);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.lzxnone.terraria.item.weapon.melee;
|
||||
|
||||
import com.lzxnone.terraria.Config;
|
||||
import com.lzxnone.terraria.LzxnoneTerraria;
|
||||
import com.lzxnone.terraria.ModSounds;
|
||||
import com.lzxnone.terraria.entity.ModEntities;
|
||||
@@ -10,9 +9,14 @@ import com.lzxnone.terraria.entity.projectile.StaticProjectileBehaviors;
|
||||
import com.lzxnone.terraria.item.ModItems;
|
||||
import com.lzxnone.terraria.particle.DustParticleOptions;
|
||||
import com.lzxnone.terraria.particle.ModParticles;
|
||||
import com.lzxnone.terraria.ui.config.ConfigFactory;
|
||||
import com.lzxnone.terraria.ui.config.ConfigListItem;
|
||||
import com.lzxnone.terraria.ui.config.ConfigUtil;
|
||||
import com.lzxnone.terraria.ui.config.IConfigData;
|
||||
import com.lzxnone.terraria.utils.*;
|
||||
import net.minecraft.core.component.DataComponents;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
@@ -31,6 +35,23 @@ import net.minecraft.world.phys.*;
|
||||
import org.joml.Vector3f;
|
||||
|
||||
public class StarWrath extends SwordItem {
|
||||
private static final String CONFIG_TRANSLATION_PREFIX = "lzxnoneterraria.configuration.";
|
||||
|
||||
public static final String DAMAGE_PATH = "weapon.star_wrath.damage";
|
||||
public static final double DAMAGE_DEFAULT = 16.0;
|
||||
public static final double DAMAGE_MIN = 0.0;
|
||||
public static final double DAMAGE_MAX = 2147483647.0;
|
||||
|
||||
public static final String SPEED_PATH = "weapon.star_wrath.speed";
|
||||
public static final double SPEED_DEFAULT = 2.0;
|
||||
public static final double SPEED_MIN = 0.0;
|
||||
public static final double SPEED_MAX = 10.0;
|
||||
|
||||
public static final String MAX_RANGE_PATH = "weapon.star_wrath.max_range";
|
||||
public static final double MAX_RANGE_DEFAULT = 48.0;
|
||||
public static final double MAX_RANGE_MIN = 1.0;
|
||||
public static final double MAX_RANGE_MAX = 1024.0;
|
||||
|
||||
public StarWrath() {
|
||||
super(Tiers.DIAMOND, new Item.Properties().attributes(ItemAttributeModifiers.builder()
|
||||
.add(Attributes.ATTACK_DAMAGE,
|
||||
@@ -43,6 +64,42 @@ public class StarWrath extends SwordItem {
|
||||
).rarity(Rarity.RARE));
|
||||
}
|
||||
|
||||
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
||||
@Override
|
||||
public void onConfigLoad() {
|
||||
ConfigFactory.loadDoubleConfig(DAMAGE_PATH, configText("star_wrath_damage"), configTooltip("star_wrath_damage"), DAMAGE_DEFAULT, DAMAGE_MIN, DAMAGE_MAX);
|
||||
ConfigFactory.loadDoubleConfig(SPEED_PATH, configText("star_wrath_speed"), configTooltip("star_wrath_speed"), SPEED_DEFAULT, SPEED_MIN, SPEED_MAX);
|
||||
ConfigFactory.loadDoubleConfig(MAX_RANGE_PATH, configText("star_wrath_max_range"), configTooltip("star_wrath_max_range"), MAX_RANGE_DEFAULT, MAX_RANGE_MIN, MAX_RANGE_MAX);
|
||||
}
|
||||
};
|
||||
|
||||
private static Component configText(String key) {
|
||||
return Component.translatable(CONFIG_TRANSLATION_PREFIX + key);
|
||||
}
|
||||
|
||||
private static Component configTooltip(String key) {
|
||||
return Component.translatable(CONFIG_TRANSLATION_PREFIX + key + ".tooltip");
|
||||
}
|
||||
|
||||
public static double getDamage() {
|
||||
return Math.clamp(ConfigUtil.readDouble(DAMAGE_PATH, DAMAGE_DEFAULT), DAMAGE_MIN, DAMAGE_MAX);
|
||||
}
|
||||
|
||||
public static double getSpeed() {
|
||||
return Math.clamp(ConfigUtil.readDouble(SPEED_PATH, SPEED_DEFAULT), SPEED_MIN, SPEED_MAX);
|
||||
}
|
||||
|
||||
public static double getMaxRange() {
|
||||
return Math.clamp(ConfigUtil.readDouble(MAX_RANGE_PATH, MAX_RANGE_DEFAULT), MAX_RANGE_MIN, MAX_RANGE_MAX);
|
||||
}
|
||||
|
||||
public static final ConfigListItem CONFIG_LIST_ITEM = new ConfigListItem(
|
||||
"star_wrath",
|
||||
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/item/star_wrath.png"),
|
||||
Component.translatable("item.lzxnoneterraria.star_wrath"),
|
||||
CONFIG_DATA
|
||||
);
|
||||
|
||||
public static final DustParticleOptions PARTICLE = new DustParticleOptions(
|
||||
0.05f, 0.5f, 40, true, new Vector3f[]{
|
||||
new Vector3f(1.0F, 0.8F, 0.5F),
|
||||
@@ -82,7 +139,7 @@ public class StarWrath extends SwordItem {
|
||||
Entity target = result.getEntity();
|
||||
Entity owner = projectile.getOwner();
|
||||
if(!FilterUtil.createTargetFilter(owner).test(target) || !(owner instanceof Player player)) return;
|
||||
if(DamageUtil.attack(player, target, (float) Config.starWrathDamage)) {
|
||||
if(DamageUtil.attack(player, target, (float) getDamage())) {
|
||||
target.invulnerableTime = 2;
|
||||
}
|
||||
}
|
||||
@@ -144,7 +201,7 @@ public class StarWrath extends SwordItem {
|
||||
ItemStack itemstack = player.getItemInHand(hand);
|
||||
if(!level.isClientSide()) {
|
||||
for(int i = 0;i < SPAWN_COUNT;i++) {
|
||||
Vec3 targetPos = MathUtil.getCrosshairPos(player, level, Config.starWrathMaxRange);
|
||||
Vec3 targetPos = MathUtil.getCrosshairPos(player, level, getMaxRange());
|
||||
|
||||
Vec3 spawnPos = new Vec3(
|
||||
targetPos.x + SPAWN_OFFSET * (Math.random() * 2 - 1),
|
||||
@@ -176,10 +233,10 @@ public class StarWrath extends SwordItem {
|
||||
projectile.getEntityData().set(StaticProjectile.GLOW, true);
|
||||
projectile.getEntityData().set(StaticProjectile.RXP, 90);
|
||||
projectile.getEntityData().set(StaticProjectile.RZP, 90);
|
||||
projectile.getEntityData().set(StaticProjectile.EXPRESSION_Z, String.format("%.3f*t", Config.starWrathSpeed));
|
||||
projectile.getEntityData().set(StaticProjectile.EXPRESSION_Z, String.format("%.3f*t", getSpeed()));
|
||||
|
||||
CompoundTag customData = new CompoundTag();
|
||||
customData.putInt("targetLifetime", (int) Math.round(targetPos.distanceTo(spawnPos) / Config.starWrathSpeed));
|
||||
customData.putInt("targetLifetime", (int) Math.round(targetPos.distanceTo(spawnPos) / getSpeed()));
|
||||
projectile.getEntityData().set(StaticProjectile.CUSTOM_DATA, customData);
|
||||
|
||||
projectile.setDeltaMovement(MathUtil.toVec3(dirs[0]));
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.lzxnone.terraria.item.weapon.melee;
|
||||
|
||||
import com.lzxnone.terraria.Config;
|
||||
import com.lzxnone.terraria.LzxnoneTerraria;
|
||||
import com.lzxnone.terraria.ModSounds;
|
||||
import com.lzxnone.terraria.entity.ModEntities;
|
||||
@@ -9,9 +8,14 @@ import com.lzxnone.terraria.entity.projectile.StaticProjectileBehaviors;
|
||||
import com.lzxnone.terraria.entity.projectile.StaticProjectile;
|
||||
import com.lzxnone.terraria.item.ModItems;
|
||||
import com.lzxnone.terraria.particle.ModParticles;
|
||||
import com.lzxnone.terraria.ui.config.ConfigFactory;
|
||||
import com.lzxnone.terraria.ui.config.ConfigListItem;
|
||||
import com.lzxnone.terraria.ui.config.ConfigUtil;
|
||||
import com.lzxnone.terraria.ui.config.IConfigData;
|
||||
import com.lzxnone.terraria.utils.*;
|
||||
import net.minecraft.core.component.DataComponents;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
@@ -34,6 +38,23 @@ import net.minecraft.world.phys.*;
|
||||
import org.joml.Vector3f;
|
||||
|
||||
public class Starfury extends SwordItem {
|
||||
private static final String CONFIG_TRANSLATION_PREFIX = "lzxnoneterraria.configuration.";
|
||||
|
||||
public static final String DAMAGE_PATH = "weapon.starfury.damage";
|
||||
public static final double DAMAGE_DEFAULT = 6.0;
|
||||
public static final double DAMAGE_MIN = 0.0;
|
||||
public static final double DAMAGE_MAX = 2147483647.0;
|
||||
|
||||
public static final String MAX_RANGE_PATH = "weapon.starfury.max_range";
|
||||
public static final double MAX_RANGE_DEFAULT = 24.0;
|
||||
public static final double MAX_RANGE_MIN = 1.0;
|
||||
public static final double MAX_RANGE_MAX = 1024.0;
|
||||
|
||||
public static final String SPEED_PATH = "weapon.starfury.speed";
|
||||
public static final double SPEED_DEFAULT = 2.0;
|
||||
public static final double SPEED_MIN = 0.0;
|
||||
public static final double SPEED_MAX = 10.0;
|
||||
|
||||
public Starfury() {
|
||||
super(Tiers.IRON, new Item.Properties().attributes(ItemAttributeModifiers.builder()
|
||||
.add(Attributes.ATTACK_DAMAGE,
|
||||
@@ -46,6 +67,42 @@ public class Starfury extends SwordItem {
|
||||
));
|
||||
}
|
||||
|
||||
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
||||
@Override
|
||||
public void onConfigLoad() {
|
||||
ConfigFactory.loadDoubleConfig(DAMAGE_PATH, configText("starfury_damage"), configTooltip("starfury_damage"), DAMAGE_DEFAULT, DAMAGE_MIN, DAMAGE_MAX);
|
||||
ConfigFactory.loadDoubleConfig(MAX_RANGE_PATH, configText("starfury_max_range"), configTooltip("starfury_max_range"), MAX_RANGE_DEFAULT, MAX_RANGE_MIN, MAX_RANGE_MAX);
|
||||
ConfigFactory.loadDoubleConfig(SPEED_PATH, configText("starfury_speed"), configTooltip("starfury_speed"), SPEED_DEFAULT, SPEED_MIN, SPEED_MAX);
|
||||
}
|
||||
};
|
||||
|
||||
private static Component configText(String key) {
|
||||
return Component.translatable(CONFIG_TRANSLATION_PREFIX + key);
|
||||
}
|
||||
|
||||
private static Component configTooltip(String key) {
|
||||
return Component.translatable(CONFIG_TRANSLATION_PREFIX + key + ".tooltip");
|
||||
}
|
||||
|
||||
public static double getDamage() {
|
||||
return Math.clamp(ConfigUtil.readDouble(DAMAGE_PATH, DAMAGE_DEFAULT), DAMAGE_MIN, DAMAGE_MAX);
|
||||
}
|
||||
|
||||
public static double getMaxRange() {
|
||||
return Math.clamp(ConfigUtil.readDouble(MAX_RANGE_PATH, MAX_RANGE_DEFAULT), MAX_RANGE_MIN, MAX_RANGE_MAX);
|
||||
}
|
||||
|
||||
public static double getSpeed() {
|
||||
return Math.clamp(ConfigUtil.readDouble(SPEED_PATH, SPEED_DEFAULT), SPEED_MIN, SPEED_MAX);
|
||||
}
|
||||
|
||||
public static final ConfigListItem CONFIG_LIST_ITEM = new ConfigListItem(
|
||||
"starfury",
|
||||
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/item/starfury.png"),
|
||||
Component.translatable("item.lzxnoneterraria.starfury"),
|
||||
CONFIG_DATA
|
||||
);
|
||||
|
||||
public static final IStaticProjectileBehavior PROJECTILE_BEHAVIOR = new IStaticProjectileBehavior() {
|
||||
@Override
|
||||
public void onMoving(StaticProjectile projectile) {
|
||||
@@ -62,7 +119,7 @@ public class Starfury extends SwordItem {
|
||||
Entity owner = projectile.getOwner();
|
||||
if(owner == null) return;
|
||||
if(!FilterUtil.createTargetFilter(owner).test(target) || !(owner instanceof Player player)) return;
|
||||
if(DamageUtil.attack(player, target, (float) Config.starfuryDamage)) {
|
||||
if(DamageUtil.attack(player, target, (float) getDamage())) {
|
||||
target.invulnerableTime = 5;
|
||||
}
|
||||
}
|
||||
@@ -109,7 +166,7 @@ public class Starfury extends SwordItem {
|
||||
public InteractionResultHolder<ItemStack> use(Level level, Player player, InteractionHand hand) {
|
||||
ItemStack itemstack = player.getItemInHand(hand);
|
||||
if(!level.isClientSide()) {
|
||||
Vec3 targetPos = MathUtil.getCrosshairPos(player, level, Config.starfuryMaxRange);
|
||||
Vec3 targetPos = MathUtil.getCrosshairPos(player, level, getMaxRange());
|
||||
|
||||
Vec3 spawnPos = new Vec3(
|
||||
targetPos.x + SPAWN_OFFSET * (Math.random() * 2 - 1),
|
||||
@@ -135,10 +192,10 @@ public class Starfury extends SwordItem {
|
||||
projectile.getEntityData().set(StaticProjectile.GLOW, true);
|
||||
projectile.getEntityData().set(StaticProjectile.RXP, 90);
|
||||
projectile.getEntityData().set(StaticProjectile.RZP, 90);
|
||||
projectile.getEntityData().set(StaticProjectile.EXPRESSION_Z, String.format("%.3f*t", Config.starfurySpeed));
|
||||
projectile.getEntityData().set(StaticProjectile.EXPRESSION_Z, String.format("%.3f*t", getSpeed()));
|
||||
|
||||
CompoundTag customData = new CompoundTag();
|
||||
customData.putInt("targetLifetime", (int) Math.floor(targetPos.distanceTo(spawnPos) / Config.starfurySpeed));
|
||||
customData.putInt("targetLifetime", (int) Math.floor(targetPos.distanceTo(spawnPos) / getSpeed()));
|
||||
projectile.getEntityData().set(StaticProjectile.CUSTOM_DATA, customData);
|
||||
|
||||
projectile.setDeltaMovement(MathUtil.toVec3(dirs[0]));
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.lzxnone.terraria.item.weapon.melee;
|
||||
|
||||
import com.lzxnone.terraria.Config;
|
||||
import com.lzxnone.terraria.LzxnoneTerraria;
|
||||
import com.lzxnone.terraria.ModSounds;
|
||||
import com.lzxnone.terraria.entity.ModEntities;
|
||||
@@ -15,23 +14,24 @@ import com.lzxnone.terraria.item.IItemWaveBehavior;
|
||||
import com.lzxnone.terraria.network.payload.SwordBeamPayload;
|
||||
import com.lzxnone.terraria.particle.DustParticleOptions;
|
||||
import com.lzxnone.terraria.particle.ModParticles;
|
||||
import com.lzxnone.terraria.ui.config.ConfigFactory;
|
||||
import com.lzxnone.terraria.ui.config.ConfigListItem;
|
||||
import com.lzxnone.terraria.ui.config.ConfigUtil;
|
||||
import com.lzxnone.terraria.ui.config.IConfigData;
|
||||
import com.lzxnone.terraria.utils.*;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import com.mojang.math.Axis;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.client.renderer.LightTexture;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.texture.OverlayTexture;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResultHolder;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EquipmentSlotGroup;
|
||||
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;
|
||||
@@ -39,18 +39,61 @@ import net.minecraft.world.item.*;
|
||||
import net.minecraft.world.item.component.ItemAttributeModifiers;
|
||||
import net.minecraft.world.level.ClipContext;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.phys.*;
|
||||
import net.neoforged.neoforge.event.entity.player.AttackEntityEvent;
|
||||
import net.neoforged.neoforge.event.entity.player.PlayerInteractEvent;
|
||||
import net.neoforged.neoforge.network.PacketDistributor;
|
||||
import org.joml.Matrix4f;
|
||||
import org.joml.Quaternionf;
|
||||
import org.joml.Vector3f;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class TerraBlade extends SwordItem {
|
||||
private static final String CONFIG_TRANSLATION_PREFIX = "lzxnoneterraria.configuration.";
|
||||
|
||||
public static final String PROJECTILE_ALIGN_TO_SWORD_BEAM_PATH = "weapon.terra_blade.projectile_align_to_sword_beam";
|
||||
public static final boolean PROJECTILE_ALIGN_TO_SWORD_BEAM_DEFAULT = true;
|
||||
|
||||
public static final String SWORD_BEAM_ROTATE_RANGE_PATH = "weapon.terra_blade.sword_beam_rotate_range";
|
||||
public static final int SWORD_BEAM_ROTATE_RANGE_DEFAULT = 45;
|
||||
public static final int SWORD_BEAM_ROTATE_RANGE_MIN = 0;
|
||||
public static final int SWORD_BEAM_ROTATE_RANGE_MAX = 90;
|
||||
|
||||
public static final String PROJECTILE_ROTATE_RANGE_PATH = "weapon.terra_blade.projectile_rotate_range";
|
||||
public static final int PROJECTILE_ROTATE_RANGE_DEFAULT = 45;
|
||||
public static final int PROJECTILE_ROTATE_RANGE_MIN = 0;
|
||||
public static final int PROJECTILE_ROTATE_RANGE_MAX = 90;
|
||||
|
||||
public static final String SWORD_BEAM_MAX_HIT_COUNT_PATH = "weapon.terra_blade.sword_beam_max_hit_count";
|
||||
public static final int SWORD_BEAM_MAX_HIT_COUNT_DEFAULT = 3;
|
||||
public static final int SWORD_BEAM_MAX_HIT_COUNT_MIN = 0;
|
||||
public static final int SWORD_BEAM_MAX_HIT_COUNT_MAX = 100;
|
||||
|
||||
public static final String SWORD_BEAM_DAMAGE_PATH = "weapon.terra_blade.sword_beam_damage";
|
||||
public static final double SWORD_BEAM_DAMAGE_DEFAULT = 11.0;
|
||||
public static final double SWORD_BEAM_DAMAGE_MIN = 0.0;
|
||||
public static final double SWORD_BEAM_DAMAGE_MAX = 2147483647.0;
|
||||
|
||||
public static final String PROJECTILE_DAMAGE_PATH = "weapon.terra_blade.projectile_damage";
|
||||
public static final double PROJECTILE_DAMAGE_DEFAULT = 11.0;
|
||||
public static final double PROJECTILE_DAMAGE_MIN = 0.0;
|
||||
public static final double PROJECTILE_DAMAGE_MAX = 2147483647.0;
|
||||
|
||||
public static final String PROJECTILE_SPEED_PATH = "weapon.terra_blade.projectile_speed";
|
||||
public static final double PROJECTILE_SPEED_DEFAULT = 2.0;
|
||||
public static final double PROJECTILE_SPEED_MIN = 0.0;
|
||||
public static final double PROJECTILE_SPEED_MAX = 10.0;
|
||||
|
||||
public static final String PROJECTILE_LIFETIME_PATH = "weapon.terra_blade.projectile_lifetime";
|
||||
public static final int PROJECTILE_LIFETIME_DEFAULT = 60;
|
||||
public static final int PROJECTILE_LIFETIME_MIN = 1;
|
||||
public static final int PROJECTILE_LIFETIME_MAX = 1200;
|
||||
|
||||
public static final String PROJECTILE_DAMAGE_DECAY_PATH = "weapon.terra_blade.projectile_damage_decay";
|
||||
public static final double PROJECTILE_DAMAGE_DECAY_DEFAULT = 0.75;
|
||||
public static final double PROJECTILE_DAMAGE_DECAY_MIN = 0.0;
|
||||
public static final double PROJECTILE_DAMAGE_DECAY_MAX = 1.0;
|
||||
|
||||
public TerraBlade() {
|
||||
super(Tiers.DIAMOND, new Item.Properties().attributes(ItemAttributeModifiers.builder()
|
||||
.add(Attributes.ATTACK_DAMAGE,
|
||||
@@ -63,6 +106,72 @@ public class TerraBlade extends SwordItem {
|
||||
).rarity(Rarity.RARE));
|
||||
}
|
||||
|
||||
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
||||
@Override
|
||||
public void onConfigLoad() {
|
||||
ConfigFactory.loadBooleanConfig(PROJECTILE_ALIGN_TO_SWORD_BEAM_PATH, configText("terra_projectile_align_to_blade"), configTooltip("terra_projectile_align_to_blade"), PROJECTILE_ALIGN_TO_SWORD_BEAM_DEFAULT);
|
||||
ConfigFactory.loadIntConfig(SWORD_BEAM_ROTATE_RANGE_PATH, configText("terra_blade_rotate_range"), configTooltip("terra_blade_rotate_range"), SWORD_BEAM_ROTATE_RANGE_DEFAULT, SWORD_BEAM_ROTATE_RANGE_MIN, SWORD_BEAM_ROTATE_RANGE_MAX);
|
||||
ConfigFactory.loadIntConfig(PROJECTILE_ROTATE_RANGE_PATH, configText("terra_projectile_rotate_range"), configTooltip("terra_projectile_rotate_range"), PROJECTILE_ROTATE_RANGE_DEFAULT, PROJECTILE_ROTATE_RANGE_MIN, PROJECTILE_ROTATE_RANGE_MAX);
|
||||
ConfigFactory.loadIntConfig(SWORD_BEAM_MAX_HIT_COUNT_PATH, configText("terra_blade_max_hit_count"), configTooltip("terra_blade_max_hit_count"), SWORD_BEAM_MAX_HIT_COUNT_DEFAULT, SWORD_BEAM_MAX_HIT_COUNT_MIN, SWORD_BEAM_MAX_HIT_COUNT_MAX);
|
||||
ConfigFactory.loadDoubleConfig(SWORD_BEAM_DAMAGE_PATH, configText("terra_blade_damage"), configTooltip("terra_blade_damage"), SWORD_BEAM_DAMAGE_DEFAULT, SWORD_BEAM_DAMAGE_MIN, SWORD_BEAM_DAMAGE_MAX);
|
||||
ConfigFactory.loadDoubleConfig(PROJECTILE_DAMAGE_PATH, configText("terra_projectile_damage"), configTooltip("terra_projectile_damage"), PROJECTILE_DAMAGE_DEFAULT, PROJECTILE_DAMAGE_MIN, PROJECTILE_DAMAGE_MAX);
|
||||
ConfigFactory.loadDoubleConfig(PROJECTILE_SPEED_PATH, configText("terra_projectile_speed"), configTooltip("terra_projectile_speed"), PROJECTILE_SPEED_DEFAULT, PROJECTILE_SPEED_MIN, PROJECTILE_SPEED_MAX);
|
||||
ConfigFactory.loadIntConfig(PROJECTILE_LIFETIME_PATH, configText("terra_projectile_lifetime"), configTooltip("terra_projectile_lifetime"), PROJECTILE_LIFETIME_DEFAULT, PROJECTILE_LIFETIME_MIN, PROJECTILE_LIFETIME_MAX);
|
||||
ConfigFactory.loadDoubleConfig(PROJECTILE_DAMAGE_DECAY_PATH, configText("terra_projectile_damage_decay"), configTooltip("terra_projectile_damage_decay"), PROJECTILE_DAMAGE_DECAY_DEFAULT, PROJECTILE_DAMAGE_DECAY_MIN, PROJECTILE_DAMAGE_DECAY_MAX);
|
||||
}
|
||||
};
|
||||
|
||||
private static Component configText(String key) {
|
||||
return Component.translatable(CONFIG_TRANSLATION_PREFIX + key);
|
||||
}
|
||||
|
||||
private static Component configTooltip(String key) {
|
||||
return Component.translatable(CONFIG_TRANSLATION_PREFIX + key + ".tooltip");
|
||||
}
|
||||
|
||||
public static boolean isProjectileAlignToSwordBeam() {
|
||||
return ConfigUtil.readBoolean(PROJECTILE_ALIGN_TO_SWORD_BEAM_PATH, PROJECTILE_ALIGN_TO_SWORD_BEAM_DEFAULT);
|
||||
}
|
||||
|
||||
public static int getSwordBeamRotateRange() {
|
||||
return Math.clamp(ConfigUtil.readInt(SWORD_BEAM_ROTATE_RANGE_PATH, SWORD_BEAM_ROTATE_RANGE_DEFAULT), SWORD_BEAM_ROTATE_RANGE_MIN, SWORD_BEAM_ROTATE_RANGE_MAX);
|
||||
}
|
||||
|
||||
public static int getProjectileRotateRange() {
|
||||
return Math.clamp(ConfigUtil.readInt(PROJECTILE_ROTATE_RANGE_PATH, PROJECTILE_ROTATE_RANGE_DEFAULT), PROJECTILE_ROTATE_RANGE_MIN, PROJECTILE_ROTATE_RANGE_MAX);
|
||||
}
|
||||
|
||||
public static int getSwordBeamMaxHitCount() {
|
||||
return Math.clamp(ConfigUtil.readInt(SWORD_BEAM_MAX_HIT_COUNT_PATH, SWORD_BEAM_MAX_HIT_COUNT_DEFAULT), SWORD_BEAM_MAX_HIT_COUNT_MIN, SWORD_BEAM_MAX_HIT_COUNT_MAX);
|
||||
}
|
||||
|
||||
public static double getSwordBeamDamage() {
|
||||
return Math.clamp(ConfigUtil.readDouble(SWORD_BEAM_DAMAGE_PATH, SWORD_BEAM_DAMAGE_DEFAULT), SWORD_BEAM_DAMAGE_MIN, SWORD_BEAM_DAMAGE_MAX);
|
||||
}
|
||||
|
||||
public static double getProjectileDamage() {
|
||||
return Math.clamp(ConfigUtil.readDouble(PROJECTILE_DAMAGE_PATH, PROJECTILE_DAMAGE_DEFAULT), PROJECTILE_DAMAGE_MIN, PROJECTILE_DAMAGE_MAX);
|
||||
}
|
||||
|
||||
public static double getProjectileSpeed() {
|
||||
return Math.clamp(ConfigUtil.readDouble(PROJECTILE_SPEED_PATH, PROJECTILE_SPEED_DEFAULT), PROJECTILE_SPEED_MIN, PROJECTILE_SPEED_MAX);
|
||||
}
|
||||
|
||||
public static int getProjectileLifetime() {
|
||||
return Math.clamp(ConfigUtil.readInt(PROJECTILE_LIFETIME_PATH, PROJECTILE_LIFETIME_DEFAULT), PROJECTILE_LIFETIME_MIN, PROJECTILE_LIFETIME_MAX);
|
||||
}
|
||||
|
||||
public static double getProjectileDamageDecay() {
|
||||
return Math.clamp(ConfigUtil.readDouble(PROJECTILE_DAMAGE_DECAY_PATH, PROJECTILE_DAMAGE_DECAY_DEFAULT), PROJECTILE_DAMAGE_DECAY_MIN, PROJECTILE_DAMAGE_DECAY_MAX);
|
||||
}
|
||||
|
||||
public static final ConfigListItem CONFIG_LIST_ITEM = new ConfigListItem(
|
||||
"terra_blade",
|
||||
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/item/terra_blade.png"),
|
||||
Component.translatable("item.lzxnoneterraria.terra_blade"),
|
||||
CONFIG_DATA
|
||||
);
|
||||
|
||||
public static final CompoundTag BEAM_DATA = Util.make(new CompoundTag(), tag -> {
|
||||
tag.putString("behavior", "terra_blade");
|
||||
tag.putInt("lifetime", 5);
|
||||
@@ -109,8 +218,8 @@ public class TerraBlade extends SwordItem {
|
||||
CompoundTag custom_data = beam.getEntityData().get(SwordBeam.CUSTOM_DATA);
|
||||
if(custom_data.contains("hitEntityCount")) {
|
||||
int count = custom_data.getInt("hitEntityCount");
|
||||
if(count < Config.terraBladeMaxHitCount) {
|
||||
if(DamageUtil.attack(player, target, (float) Config.terraBladeDamage)) {
|
||||
if(count < getSwordBeamMaxHitCount()) {
|
||||
if(DamageUtil.attack(player, target, (float)getSwordBeamDamage())) {
|
||||
target.invulnerableTime = 20;
|
||||
count++;
|
||||
custom_data.putInt("hitEntityCount", count);
|
||||
@@ -124,7 +233,7 @@ public class TerraBlade extends SwordItem {
|
||||
|
||||
@Override
|
||||
public void generate(Entity entity, CompoundTag beamData) {
|
||||
int randomAngle = (int) (Config.terraBladeRotateRange * (Math.random() * 2 - 1));
|
||||
int randomAngle = (int) (getSwordBeamRotateRange() * (Math.random() * 2 - 1));
|
||||
beamData.putInt("rotate", randomAngle);
|
||||
ISwordBeamBehavior.super.generate(entity, beamData);
|
||||
if(entity instanceof Player player) summon(player, randomAngle);
|
||||
@@ -348,9 +457,10 @@ public class TerraBlade extends SwordItem {
|
||||
if(!customData.contains("dead")) {
|
||||
float progress = summon.getEntityData().get(StaticSummon.AGE) / (float) summon.getEntityData().get(StaticSummon.LIFETIME);
|
||||
if(progress > FADE_IN) {
|
||||
summon.setDeltaMovement(summon.getLookAngle().normalize().scale(Config.terraProjectileSpeed - Config.terraProjectileSpeed * (progress - FADE_IN) / (1.0f - FADE_IN)));
|
||||
double projectileSpeed = getProjectileSpeed();
|
||||
summon.setDeltaMovement(summon.getLookAngle().normalize().scale(projectileSpeed - projectileSpeed * (progress - FADE_IN) / (1.0f - FADE_IN)));
|
||||
}else {
|
||||
summon.setDeltaMovement(summon.getLookAngle().normalize().scale(Config.terraProjectileSpeed));
|
||||
summon.setDeltaMovement(summon.getLookAngle().normalize().scale(getProjectileSpeed()));
|
||||
}
|
||||
}else {
|
||||
summon.setDeltaMovement(summon.getLookAngle().normalize().scale(0.1));
|
||||
@@ -371,7 +481,7 @@ public class TerraBlade extends SwordItem {
|
||||
int count = customData.getInt("hitCount");
|
||||
List<Entity> targets = summon.level().getEntitiesOfClass(Entity.class, summon.getBoundingBox(), FilterUtil.createTargetFilter(summon, summon.getOwner()));
|
||||
for(Entity target : targets) {
|
||||
if(DamageUtil.attack(player, target, (float) Config.terraProjectileDamage * (float) Math.pow(Config.terraProjectileDamageDecay, count))) {
|
||||
if(DamageUtil.attack(player, target, (float)getProjectileDamage() * (float)Math.pow(getProjectileDamageDecay(), count))) {
|
||||
count++;
|
||||
ParticleUtil.addParticles(
|
||||
(ServerLevel) summon.level(), ModParticles.TERRA_BEAM_HIT_PARTICLE.get(),
|
||||
@@ -429,7 +539,7 @@ public class TerraBlade extends SwordItem {
|
||||
Vec3 pos = new Vec3(player.getX(), player.getEyeY() - 0.1, player.getZ());
|
||||
summon.setPos(pos);
|
||||
|
||||
if(!Config.terraProjectileAlignToBlade) randomAngle = (int) (Config.terraProjectileRotateRange * (Math.random() * 2 - 1));
|
||||
if(!isProjectileAlignToSwordBeam()) randomAngle = (int) (getProjectileRotateRange() * (Math.random() * 2 - 1));
|
||||
|
||||
Vector3f[] dirs = MathUtil.computeCoordinateSystem(player);
|
||||
dirs = MathUtil.rotateCoordinateSystem(dirs[0], dirs[2], randomAngle);
|
||||
@@ -441,7 +551,7 @@ public class TerraBlade extends SwordItem {
|
||||
|
||||
summon.getEntityData().set(StaticSummon.BEHAVIOR, StaticSummonBehaviors.TERRA_BLADE_BEAM);
|
||||
summon.getEntityData().set(StaticSummon.RENDER_MODE, "custom");
|
||||
summon.getEntityData().set(StaticSummon.LIFETIME, Config.terraProjectileLifetime);
|
||||
summon.getEntityData().set(StaticSummon.LIFETIME, getProjectileLifetime());
|
||||
summon.getEntityData().set(StaticSummon.RZP, randomAngle);
|
||||
summon.getEntityData().set(StaticSummon.GLOW, true);
|
||||
summon.setNoGravity(true);
|
||||
@@ -479,7 +589,7 @@ public class TerraBlade extends SwordItem {
|
||||
customData.putFloat("rightZ", dirs[2].z);
|
||||
summon.getEntityData().set(StaticSummon.CUSTOM_DATA, customData);
|
||||
|
||||
summon.setDeltaMovement(player.getLookAngle().normalize().scale(Config.terraProjectileSpeed));
|
||||
summon.setDeltaMovement(player.getLookAngle().normalize().scale(getProjectileSpeed()));
|
||||
|
||||
player.level().addFreshEntity(summon);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.lzxnone.terraria.item.weapon.melee;
|
||||
|
||||
import com.lzxnone.terraria.Config;
|
||||
import com.lzxnone.terraria.LzxnoneTerraria;
|
||||
import com.lzxnone.terraria.ModSounds;
|
||||
import com.lzxnone.terraria.entity.ModEntities;
|
||||
@@ -8,6 +7,10 @@ import com.lzxnone.terraria.entity.ModRenderTypes;
|
||||
import com.lzxnone.terraria.entity.summon.IStaticSummonBehavior;
|
||||
import com.lzxnone.terraria.entity.summon.StaticSummon;
|
||||
import com.lzxnone.terraria.entity.summon.StaticSummonBehaviors;
|
||||
import com.lzxnone.terraria.ui.config.ConfigFactory;
|
||||
import com.lzxnone.terraria.ui.config.ConfigListItem;
|
||||
import com.lzxnone.terraria.ui.config.ConfigUtil;
|
||||
import com.lzxnone.terraria.ui.config.IConfigData;
|
||||
import com.lzxnone.terraria.utils.DamageUtil;
|
||||
import com.lzxnone.terraria.utils.FilterUtil;
|
||||
import com.lzxnone.terraria.utils.MathUtil;
|
||||
@@ -20,6 +23,7 @@ import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.texture.OverlayTexture;
|
||||
import net.minecraft.core.component.DataComponents;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResultHolder;
|
||||
@@ -43,6 +47,23 @@ import org.jspecify.annotations.NonNull;
|
||||
import java.util.List;
|
||||
|
||||
public class Terragrim extends SwordItem {
|
||||
private static final String CONFIG_TRANSLATION_PREFIX = "lzxnoneterraria.configuration.";
|
||||
|
||||
public static final String HIT_RANGE_PATH = "weapon.terragrim.hit_range";
|
||||
public static final double HIT_RANGE_DEFAULT = 2.5;
|
||||
public static final double HIT_RANGE_MIN = 0.5;
|
||||
public static final double HIT_RANGE_MAX = 10.0;
|
||||
|
||||
public static final String DAMAGE_PATH = "weapon.terragrim.damage";
|
||||
public static final double DAMAGE_DEFAULT = 0.25;
|
||||
public static final double DAMAGE_MIN = 0.0;
|
||||
public static final double DAMAGE_MAX = 2147483647.0;
|
||||
|
||||
public static final String ROTATE_RANGE_PATH = "weapon.terragrim.rotate_range";
|
||||
public static final int ROTATE_RANGE_DEFAULT = 45;
|
||||
public static final int ROTATE_RANGE_MIN = 0;
|
||||
public static final int ROTATE_RANGE_MAX = 90;
|
||||
|
||||
public Terragrim() {
|
||||
super(Tiers.DIAMOND, new Item.Properties().attributes(ItemAttributeModifiers.builder()
|
||||
.add(Attributes.ATTACK_DAMAGE,
|
||||
@@ -55,6 +76,42 @@ public class Terragrim extends SwordItem {
|
||||
).rarity(Rarity.RARE));
|
||||
}
|
||||
|
||||
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
||||
@Override
|
||||
public void onConfigLoad() {
|
||||
ConfigFactory.loadDoubleConfig(HIT_RANGE_PATH, configText("terragrim_hit_range"), configTooltip("terragrim_hit_range"), HIT_RANGE_DEFAULT, HIT_RANGE_MIN, HIT_RANGE_MAX);
|
||||
ConfigFactory.loadDoubleConfig(DAMAGE_PATH, configText("terragrim_damage"), configTooltip("terragrim_damage"), DAMAGE_DEFAULT, DAMAGE_MIN, DAMAGE_MAX);
|
||||
ConfigFactory.loadIntConfig(ROTATE_RANGE_PATH, configText("terragrim_rotate_range"), configTooltip("terragrim_rotate_range"), ROTATE_RANGE_DEFAULT, ROTATE_RANGE_MIN, ROTATE_RANGE_MAX);
|
||||
}
|
||||
};
|
||||
|
||||
private static Component configText(String key) {
|
||||
return Component.translatable(CONFIG_TRANSLATION_PREFIX + key);
|
||||
}
|
||||
|
||||
private static Component configTooltip(String key) {
|
||||
return Component.translatable(CONFIG_TRANSLATION_PREFIX + key + ".tooltip");
|
||||
}
|
||||
|
||||
public static double getHitRange() {
|
||||
return Math.clamp(ConfigUtil.readDouble(HIT_RANGE_PATH, HIT_RANGE_DEFAULT), HIT_RANGE_MIN, HIT_RANGE_MAX);
|
||||
}
|
||||
|
||||
public static double getDamage() {
|
||||
return Math.clamp(ConfigUtil.readDouble(DAMAGE_PATH, DAMAGE_DEFAULT), DAMAGE_MIN, DAMAGE_MAX);
|
||||
}
|
||||
|
||||
public static int getRotateRange() {
|
||||
return Math.clamp(ConfigUtil.readInt(ROTATE_RANGE_PATH, ROTATE_RANGE_DEFAULT), ROTATE_RANGE_MIN, ROTATE_RANGE_MAX);
|
||||
}
|
||||
|
||||
public static final ConfigListItem CONFIG_LIST_ITEM = new ConfigListItem(
|
||||
"terragrim",
|
||||
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/item/terragrim.png"),
|
||||
Component.translatable("item.lzxnoneterraria.terragrim"),
|
||||
CONFIG_DATA
|
||||
);
|
||||
|
||||
public static final ResourceLocation[] RES = {
|
||||
ResourceLocation.parse("lzxnoneterraria:textures/vfx/terragrim_beam0.png"),
|
||||
ResourceLocation.parse("lzxnoneterraria:textures/vfx/terragrim_beam1.png"),
|
||||
@@ -135,9 +192,10 @@ public class Terragrim extends SwordItem {
|
||||
if(summon.getOwner() != null) {
|
||||
summon.setPos(summon.getOwner().getX(), summon.getOwner().getY() + summon.getOwner().getBbHeight() * 0.5, summon.getOwner().getZ());
|
||||
}
|
||||
double hitRange = getHitRange();
|
||||
summon.setBoundingBox(new AABB(
|
||||
summon.getX() - Config.terragrimHitRange, summon.getY() - Config.terragrimHitRange, summon.getZ() - Config.terragrimHitRange,
|
||||
summon.getX() + Config.terragrimHitRange, summon.getY() + Config.terragrimHitRange, summon.getZ() + Config.terragrimHitRange
|
||||
summon.getX() - hitRange, summon.getY() - hitRange, summon.getZ() - hitRange,
|
||||
summon.getX() + hitRange, summon.getY() + hitRange, summon.getZ() + hitRange
|
||||
));
|
||||
if(!summon.level().isClientSide()) {
|
||||
if(summon.getOwner() instanceof Player player) {
|
||||
@@ -156,7 +214,7 @@ public class Terragrim extends SwordItem {
|
||||
knockbackResist.setBaseValue(Math.max(0.9, originalResist));
|
||||
}
|
||||
|
||||
if(DamageUtil.attack(player, target, (float) Config.terragrimDamage)) {
|
||||
if(DamageUtil.attack(player, target, (float) getDamage())) {
|
||||
target.invulnerableTime = 0;
|
||||
}
|
||||
|
||||
@@ -164,7 +222,7 @@ public class Terragrim extends SwordItem {
|
||||
knockbackResist.setBaseValue(originalResist);
|
||||
}
|
||||
}else {
|
||||
if(DamageUtil.attack(player, target, (float) Config.terragrimDamage)) {
|
||||
if(DamageUtil.attack(player, target, (float) getDamage())) {
|
||||
target.invulnerableTime = 0;
|
||||
}
|
||||
}
|
||||
@@ -195,7 +253,7 @@ public class Terragrim extends SwordItem {
|
||||
summon.setPos(pos);
|
||||
summon.getEntityData().set(StaticSummon.BEHAVIOR, StaticSummonBehaviors.TERRAGRIM_BEAM);
|
||||
summon.getEntityData().set(StaticSummon.RENDER_MODE, "custom");
|
||||
summon.getEntityData().set(StaticSummon.RZP, (int) ((Math.random() * 2 - 1) * Config.terragrimRotateRange));
|
||||
summon.getEntityData().set(StaticSummon.RZP, (int) ((Math.random() * 2 - 1) * getRotateRange()));
|
||||
summon.getEntityData().set(StaticSummon.LIFETIME, 1);
|
||||
summon.getEntityData().set(StaticSummon.GLOW, true);
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.lzxnone.terraria.item.weapon.melee;
|
||||
|
||||
import com.lzxnone.terraria.Config;
|
||||
import com.lzxnone.terraria.LzxnoneTerraria;
|
||||
import com.lzxnone.terraria.ModSounds;
|
||||
import com.lzxnone.terraria.entity.ModEntities;
|
||||
@@ -42,11 +41,109 @@ import net.neoforged.neoforge.event.entity.player.AttackEntityEvent;
|
||||
import net.neoforged.neoforge.event.entity.player.PlayerInteractEvent;
|
||||
import net.neoforged.neoforge.network.PacketDistributor;
|
||||
import org.joml.Vector3f;
|
||||
import com.lzxnone.terraria.ui.config.ConfigFactory;
|
||||
import com.lzxnone.terraria.ui.config.ConfigListItem;
|
||||
import com.lzxnone.terraria.ui.config.ConfigUtil;
|
||||
import com.lzxnone.terraria.ui.config.IConfigData;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
public class TheHorsemansBlade extends SwordItem {
|
||||
private static final String CONFIG_TRANSLATION_PREFIX = "lzxnoneterraria.configuration.";
|
||||
|
||||
public static final String BLADE_ROTATE_RANGE_PATH = "weapon.the_horsemans_blade.blade_rotate_range";
|
||||
public static final int BLADE_ROTATE_RANGE_DEFAULT = 45;
|
||||
public static final int BLADE_ROTATE_RANGE_MIN = 0;
|
||||
public static final int BLADE_ROTATE_RANGE_MAX = 90;
|
||||
|
||||
public static final String BLADE_MAX_HIT_COUNT_PATH = "weapon.the_horsemans_blade.blade_max_hit_count";
|
||||
public static final int BLADE_MAX_HIT_COUNT_DEFAULT = 3;
|
||||
public static final int BLADE_MAX_HIT_COUNT_MIN = 0;
|
||||
public static final int BLADE_MAX_HIT_COUNT_MAX = 100;
|
||||
|
||||
public static final String BLADE_DAMAGE_PATH = "weapon.the_horsemans_blade.blade_damage";
|
||||
public static final double BLADE_DAMAGE_DEFAULT = 15.0;
|
||||
public static final double BLADE_DAMAGE_MIN = 0.0;
|
||||
public static final double BLADE_DAMAGE_MAX = 2147483647.0;
|
||||
|
||||
public static final String PUMPKIN_SPAWN_RANGE_PATH = "weapon.the_horsemans_blade.pumpkin_spawn_range";
|
||||
public static final double PUMPKIN_SPAWN_RANGE_DEFAULT = 16.0;
|
||||
public static final double PUMPKIN_SPAWN_RANGE_MIN = 1.0;
|
||||
public static final double PUMPKIN_SPAWN_RANGE_MAX = 64.0;
|
||||
|
||||
public static final String PUMPKIN_SPEED_PATH = "weapon.the_horsemans_blade.pumpkin_speed";
|
||||
public static final double PUMPKIN_SPEED_DEFAULT = 0.5;
|
||||
public static final double PUMPKIN_SPEED_MIN = 0.0;
|
||||
public static final double PUMPKIN_SPEED_MAX = 10.0;
|
||||
|
||||
public static final String PUMPKIN_DAMAGE_PATH = "weapon.the_horsemans_blade.pumpkin_damage";
|
||||
public static final double PUMPKIN_DAMAGE_DEFAULT = 15.0;
|
||||
public static final double PUMPKIN_DAMAGE_MIN = 0.0;
|
||||
public static final double PUMPKIN_DAMAGE_MAX = 2147483647.0;
|
||||
|
||||
public static final String PUMPKIN_MAX_TARGET_RANGE_PATH = "weapon.the_horsemans_blade.pumpkin_max_target_range";
|
||||
public static final double PUMPKIN_MAX_TARGET_RANGE_DEFAULT = 32.0;
|
||||
public static final double PUMPKIN_MAX_TARGET_RANGE_MIN = 1.0;
|
||||
public static final double PUMPKIN_MAX_TARGET_RANGE_MAX = 64.0;
|
||||
|
||||
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
||||
@Override
|
||||
public void onConfigLoad() {
|
||||
ConfigFactory.loadIntConfig(BLADE_ROTATE_RANGE_PATH, configText("horsemans_blade_rotate_range"), configTooltip("horsemans_blade_rotate_range"), BLADE_ROTATE_RANGE_DEFAULT, BLADE_ROTATE_RANGE_MIN, BLADE_ROTATE_RANGE_MAX);
|
||||
ConfigFactory.loadIntConfig(BLADE_MAX_HIT_COUNT_PATH, configText("horsemans_blade_max_hit_count"), configTooltip("horsemans_blade_max_hit_count"), BLADE_MAX_HIT_COUNT_DEFAULT, BLADE_MAX_HIT_COUNT_MIN, BLADE_MAX_HIT_COUNT_MAX);
|
||||
ConfigFactory.loadDoubleConfig(BLADE_DAMAGE_PATH, configText("horsemans_blade_damage"), configTooltip("horsemans_blade_damage"), BLADE_DAMAGE_DEFAULT, BLADE_DAMAGE_MIN, BLADE_DAMAGE_MAX);
|
||||
ConfigFactory.loadDoubleConfig(PUMPKIN_SPAWN_RANGE_PATH, configText("horsemans_pumpkin_spawn_range"), configTooltip("horsemans_pumpkin_spawn_range"), PUMPKIN_SPAWN_RANGE_DEFAULT, PUMPKIN_SPAWN_RANGE_MIN, PUMPKIN_SPAWN_RANGE_MAX);
|
||||
ConfigFactory.loadDoubleConfig(PUMPKIN_SPEED_PATH, configText("horsemans_pumpkin_speed"), configTooltip("horsemans_pumpkin_speed"), PUMPKIN_SPEED_DEFAULT, PUMPKIN_SPEED_MIN, PUMPKIN_SPEED_MAX);
|
||||
ConfigFactory.loadDoubleConfig(PUMPKIN_DAMAGE_PATH, configText("horsemans_pumpkin_damage"), configTooltip("horsemans_pumpkin_damage"), PUMPKIN_DAMAGE_DEFAULT, PUMPKIN_DAMAGE_MIN, PUMPKIN_DAMAGE_MAX);
|
||||
ConfigFactory.loadDoubleConfig(PUMPKIN_MAX_TARGET_RANGE_PATH, configText("horsemans_pumpkin_max_target_range"), configTooltip("horsemans_pumpkin_max_target_range"), PUMPKIN_MAX_TARGET_RANGE_DEFAULT, PUMPKIN_MAX_TARGET_RANGE_MIN, PUMPKIN_MAX_TARGET_RANGE_MAX);
|
||||
}
|
||||
};
|
||||
|
||||
private static Component configText(String key) {
|
||||
return Component.translatable(CONFIG_TRANSLATION_PREFIX + key);
|
||||
}
|
||||
|
||||
private static Component configTooltip(String key) {
|
||||
return Component.translatable(CONFIG_TRANSLATION_PREFIX + key + ".tooltip");
|
||||
}
|
||||
|
||||
public static int getBladeRotateRange() {
|
||||
return Math.clamp(ConfigUtil.readInt(BLADE_ROTATE_RANGE_PATH, BLADE_ROTATE_RANGE_DEFAULT), BLADE_ROTATE_RANGE_MIN, BLADE_ROTATE_RANGE_MAX);
|
||||
}
|
||||
|
||||
public static int getBladeMaxHitCount() {
|
||||
return Math.clamp(ConfigUtil.readInt(BLADE_MAX_HIT_COUNT_PATH, BLADE_MAX_HIT_COUNT_DEFAULT), BLADE_MAX_HIT_COUNT_MIN, BLADE_MAX_HIT_COUNT_MAX);
|
||||
}
|
||||
|
||||
public static double getBladeDamage() {
|
||||
return Math.clamp(ConfigUtil.readDouble(BLADE_DAMAGE_PATH, BLADE_DAMAGE_DEFAULT), BLADE_DAMAGE_MIN, BLADE_DAMAGE_MAX);
|
||||
}
|
||||
|
||||
public static double getPumpkinSpawnRange() {
|
||||
return Math.clamp(ConfigUtil.readDouble(PUMPKIN_SPAWN_RANGE_PATH, PUMPKIN_SPAWN_RANGE_DEFAULT), PUMPKIN_SPAWN_RANGE_MIN, PUMPKIN_SPAWN_RANGE_MAX);
|
||||
}
|
||||
|
||||
public static double getPumpkinSpeed() {
|
||||
return Math.clamp(ConfigUtil.readDouble(PUMPKIN_SPEED_PATH, PUMPKIN_SPEED_DEFAULT), PUMPKIN_SPEED_MIN, PUMPKIN_SPEED_MAX);
|
||||
}
|
||||
|
||||
public static double getPumpkinDamage() {
|
||||
return Math.clamp(ConfigUtil.readDouble(PUMPKIN_DAMAGE_PATH, PUMPKIN_DAMAGE_DEFAULT), PUMPKIN_DAMAGE_MIN, PUMPKIN_DAMAGE_MAX);
|
||||
}
|
||||
|
||||
public static double getPumpkinMaxTargetRange() {
|
||||
return Math.clamp(ConfigUtil.readDouble(PUMPKIN_MAX_TARGET_RANGE_PATH, PUMPKIN_MAX_TARGET_RANGE_DEFAULT), PUMPKIN_MAX_TARGET_RANGE_MIN, PUMPKIN_MAX_TARGET_RANGE_MAX);
|
||||
}
|
||||
|
||||
public static final ConfigListItem CONFIG_LIST_ITEM = new ConfigListItem(
|
||||
"the_horsemans_blade",
|
||||
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/item/the_horsemans_blade.png"),
|
||||
Component.translatable("item.lzxnoneterraria.the_horsemans_blade"),
|
||||
CONFIG_DATA
|
||||
);
|
||||
|
||||
public TheHorsemansBlade() {
|
||||
super(Tiers.DIAMOND, new Item.Properties().attributes(ItemAttributeModifiers.builder()
|
||||
.add(Attributes.ATTACK_DAMAGE,
|
||||
@@ -104,8 +201,8 @@ public class TheHorsemansBlade extends SwordItem {
|
||||
CompoundTag custom_data = beam.getEntityData().get(SwordBeam.CUSTOM_DATA);
|
||||
if(custom_data.contains("hitEntityCount")) {
|
||||
int count = custom_data.getInt("hitEntityCount");
|
||||
if(count < Config.horsemansBladeMaxHitCount) {
|
||||
if(DamageUtil.attack(player, target, (float) Config.horsemansBladeDamage)) {
|
||||
if(count < getBladeMaxHitCount()) {
|
||||
if(DamageUtil.attack(player, target, (float) getBladeDamage())) {
|
||||
target.invulnerableTime = 20;
|
||||
count++;
|
||||
custom_data.putInt("hitEntityCount", count);
|
||||
@@ -115,7 +212,7 @@ public class TheHorsemansBlade extends SwordItem {
|
||||
Entity entity = beam.getOwner();
|
||||
if(entity == null) return;
|
||||
summon.setOwner(entity);
|
||||
Vec3 pos = MathUtil.getRandomPosInRadius(entity.position(), Config.horsemansPumpkinSpawnRange);
|
||||
Vec3 pos = MathUtil.getRandomPosInRadius(entity.position(), getPumpkinSpawnRange());
|
||||
summon.setPos(pos);
|
||||
|
||||
float[] xyRot = MathUtil.computeXYRot(MathUtil.toVector3f(target.position().subtract(pos)));
|
||||
@@ -150,7 +247,7 @@ public class TheHorsemansBlade extends SwordItem {
|
||||
|
||||
@Override
|
||||
public void generate(Entity entity, CompoundTag beamData) {
|
||||
beamData.putInt("rotate", (int) (Config.horsemansBladeRotateRange * (Math.random() * 2 - 1)));
|
||||
beamData.putInt("rotate", (int) (getBladeRotateRange() * (Math.random() * 2 - 1)));
|
||||
//beamData.putBoolean("right", entity.getRandom().nextInt(2) == 0);
|
||||
ISwordBeamBehavior.super.generate(entity, beamData);
|
||||
}
|
||||
@@ -213,7 +310,7 @@ public class TheHorsemansBlade extends SwordItem {
|
||||
if(target == null) {
|
||||
List<Monster> targets = summon.level().getEntitiesOfClass(
|
||||
Monster.class,
|
||||
AABB.ofSize(summon.position(), Config.horsemansPumpkinMaxTargetRange * 2, Config.horsemansPumpkinMaxTargetRange * 2, Config.horsemansPumpkinMaxTargetRange * 2),
|
||||
AABB.ofSize(summon.position(), getPumpkinMaxTargetRange() * 2, getPumpkinMaxTargetRange() * 2, getPumpkinMaxTargetRange() * 2),
|
||||
FilterUtil.createMonsterFilter(summon.getOwner())
|
||||
);
|
||||
targets.sort(Comparator.comparingDouble(e -> e.distanceToSqr(summon.position())));
|
||||
@@ -230,18 +327,18 @@ public class TheHorsemansBlade extends SwordItem {
|
||||
Vec3 selfPos = summon.position();
|
||||
Vec3 dir = targetPos.subtract(selfPos).normalize();
|
||||
|
||||
summon.setDeltaMovement(dir.scale(Config.horsemansPumpkinSpeed));
|
||||
summon.setDeltaMovement(dir.scale(getPumpkinSpeed()));
|
||||
|
||||
float[] xyRot = MathUtil.computeXYRot(MathUtil.toVector3f(dir));
|
||||
summon.setXRot(xyRot[0]);
|
||||
summon.setYRot(xyRot[1]);
|
||||
|
||||
if(selfPos.distanceToSqr(targetPos) < 2.0D) {
|
||||
if(summon.getOwner() instanceof Player player && FilterUtil.createLivingTargetFilter(player).test(target) && DamageUtil.attack(player, target, (float) Config.horsemansPumpkinDamage)) onDied(summon);
|
||||
if(summon.getOwner() instanceof Player player && FilterUtil.createLivingTargetFilter(player).test(target) && DamageUtil.attack(player, target, (float) getPumpkinDamage())) onDied(summon);
|
||||
}
|
||||
}else {
|
||||
Vec3 dir = summon.getLookAngle().normalize();
|
||||
summon.setDeltaMovement(dir.scale(Config.horsemansPumpkinSpeed));
|
||||
summon.setDeltaMovement(dir.scale(getPumpkinSpeed()));
|
||||
}
|
||||
|
||||
if(!summon.level().isClientSide()) {
|
||||
@@ -262,7 +359,7 @@ public class TheHorsemansBlade extends SwordItem {
|
||||
for(Entity hitEntity : hitEntities) {
|
||||
if(target != null && hitEntity.getUUID() == target.getUUID()) continue;
|
||||
if(summon.getOwner() instanceof Player player) {
|
||||
if(DamageUtil.attack(player, target, (float) Config.horsemansPumpkinDamage)) {
|
||||
if(DamageUtil.attack(player, target, (float) getPumpkinDamage())) {
|
||||
hitEntity.invulnerableTime = 2;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.lzxnone.terraria.item.weapon.melee;
|
||||
|
||||
import com.lzxnone.terraria.Config;
|
||||
import com.lzxnone.terraria.LzxnoneTerraria;
|
||||
import com.lzxnone.terraria.ModSounds;
|
||||
import com.lzxnone.terraria.entity.ModEntities;
|
||||
@@ -42,24 +41,24 @@ public class TrueCopperShortsword extends SwordItem {
|
||||
|
||||
public static void summon(Player player, double deltaDist) {
|
||||
Vector3f[] dirs = MathUtil.computeCoordinateSystem(player);
|
||||
int randomAngle = (int) ((Math.random() * 2 - 1) * Config.zenithTrailOffset);
|
||||
int randomAngle = (int) ((Math.random() * 2 - 1) * Zenith.getTrailOffset());
|
||||
dirs = MathUtil.rotateCoordinateSystem(dirs[0], dirs[2], randomAngle);
|
||||
|
||||
Vec3 pos = (player.getBoundingBox().getCenter()).add(MathUtil.toVec3(dirs[0]).scale(-2));
|
||||
double dist;
|
||||
if(Config.zenithDistanceMode) {
|
||||
Vec3 targetPos = MathUtil.getCrosshairPos(player, player.level(), Config.zenithMaxRange);
|
||||
dist = Math.max(0, Math.min(targetPos.subtract(pos).length() + deltaDist, Config.zenithMaxRange));
|
||||
if(Zenith.isDistanceMode()) {
|
||||
Vec3 targetPos = MathUtil.getCrosshairPos(player, player.level(), Zenith.getMaxRange());
|
||||
dist = Math.max(0, Math.min(targetPos.subtract(pos).length() + deltaDist, Zenith.getMaxRange()));
|
||||
}else {
|
||||
dist = deltaDist;
|
||||
}
|
||||
int cycle = (int) Math.max(10, dist / Config.zenithMaxRange * Config.zenithCycle);
|
||||
int cycle = (int) Math.max(10, dist / Zenith.getMaxRange() * Zenith.getCycle());
|
||||
double a = Math.max(dist / 2, 2);
|
||||
double b = Math.min(Math.random() * Config.zenithTrailB + Config.zenithTrailB, a / 2);
|
||||
double b = Math.min(Math.random() * Zenith.getTrailB() + Zenith.getTrailB(), a / 2);
|
||||
double w = Math.PI * 2 / (double) cycle;
|
||||
if(player.getRandom().nextInt(2) == 0) w = -w;
|
||||
|
||||
for(int i = 0;i < Config.zenithWeaponCount;i++) {
|
||||
for(int i = 0;i < Zenith.getWeaponCount();i++) {
|
||||
StaticProjectile projectile = new StaticProjectile(ModEntities.STATIC_PROJECTILE.get(), player.level());
|
||||
projectile.setOwner(player);
|
||||
|
||||
@@ -85,16 +84,16 @@ public class TrueCopperShortsword extends SwordItem {
|
||||
customData.putInt("angle", randomAngle);
|
||||
if(i == 0) {
|
||||
projectile.getEntityData().set(StaticProjectile.COLOR_A, 1.0f);
|
||||
projectile.getEntityData().set(StaticProjectile.SCALE_X, (float) Config.zenithScale);
|
||||
projectile.getEntityData().set(StaticProjectile.SCALE_Y, (float) Config.zenithScale);
|
||||
projectile.getEntityData().set(StaticProjectile.SCALE_X, (float) Zenith.getScale());
|
||||
projectile.getEntityData().set(StaticProjectile.SCALE_Y, (float) Zenith.getScale());
|
||||
projectile.getEntityData().set(StaticProjectile.LIFETIME, cycle);
|
||||
projectile.getEntityData().set(StaticProjectile.EXPRESSION_X, String.format("%.3f*cos(%.3ft-1.571)", b, w));
|
||||
projectile.getEntityData().set(StaticProjectile.EXPRESSION_Z, String.format("%.3f*sin(%.3ft-1.571)+%.3f", a, w, a));
|
||||
customData.putInt("start", 0);
|
||||
}else if(i == 1) {
|
||||
projectile.getEntityData().set(StaticProjectile.COLOR_A, 0.75f);
|
||||
projectile.getEntityData().set(StaticProjectile.SCALE_X, (float) Config.zenithScale * 0.75f);
|
||||
projectile.getEntityData().set(StaticProjectile.SCALE_Y, (float) Config.zenithScale * 0.75f);
|
||||
projectile.getEntityData().set(StaticProjectile.SCALE_X, (float) Zenith.getScale() * 0.75f);
|
||||
projectile.getEntityData().set(StaticProjectile.SCALE_Y, (float) Zenith.getScale() * 0.75f);
|
||||
projectile.getEntityData().set(StaticProjectile.LIFETIME, (int) (cycle * 1.25));
|
||||
if(w > 0) {
|
||||
projectile.getEntityData().set(StaticProjectile.EXPRESSION_X, String.format("%.3f*cos(%.3ft-3.142)", b, w));
|
||||
@@ -106,8 +105,8 @@ public class TrueCopperShortsword extends SwordItem {
|
||||
customData.putInt("start", (int) (cycle * 0.25));
|
||||
}else if(i == 2) {
|
||||
projectile.getEntityData().set(StaticProjectile.COLOR_A, 0.5f);
|
||||
projectile.getEntityData().set(StaticProjectile.SCALE_X, (float) Config.zenithScale * 0.5f);
|
||||
projectile.getEntityData().set(StaticProjectile.SCALE_Y, (float) Config.zenithScale * 0.5f);
|
||||
projectile.getEntityData().set(StaticProjectile.SCALE_X, (float) Zenith.getScale() * 0.5f);
|
||||
projectile.getEntityData().set(StaticProjectile.SCALE_Y, (float) Zenith.getScale() * 0.5f);
|
||||
projectile.getEntityData().set(StaticProjectile.LIFETIME, (int) (cycle * 1.5));
|
||||
if(w > 0) {
|
||||
projectile.getEntityData().set(StaticProjectile.EXPRESSION_X, String.format("%.3f*cos(%.3ft-4.713)", b, w));
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.lzxnone.terraria.item.weapon.melee;
|
||||
|
||||
import com.lzxnone.terraria.Config;
|
||||
import com.lzxnone.terraria.LzxnoneTerraria;
|
||||
import com.lzxnone.terraria.ModSounds;
|
||||
import com.lzxnone.terraria.entity.ModRenderTypes;
|
||||
@@ -37,8 +36,66 @@ import net.neoforged.neoforge.event.entity.player.AttackEntityEvent;
|
||||
import net.neoforged.neoforge.event.entity.player.PlayerInteractEvent;
|
||||
import net.neoforged.neoforge.network.PacketDistributor;
|
||||
import org.joml.Vector3f;
|
||||
import com.lzxnone.terraria.ui.config.ConfigFactory;
|
||||
import com.lzxnone.terraria.ui.config.ConfigListItem;
|
||||
import com.lzxnone.terraria.ui.config.ConfigUtil;
|
||||
import com.lzxnone.terraria.ui.config.IConfigData;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
||||
public class TrueExcalibur extends SwordItem {
|
||||
private static final String CONFIG_TRANSLATION_PREFIX = "lzxnoneterraria.configuration.";
|
||||
|
||||
public static final String ROTATE_RANGE_PATH = "weapon.true_excalibur.rotate_range";
|
||||
public static final int ROTATE_RANGE_DEFAULT = 45;
|
||||
public static final int ROTATE_RANGE_MIN = 0;
|
||||
public static final int ROTATE_RANGE_MAX = 90;
|
||||
|
||||
public static final String MAX_HIT_COUNT_PATH = "weapon.true_excalibur.max_hit_count";
|
||||
public static final int MAX_HIT_COUNT_DEFAULT = 6;
|
||||
public static final int MAX_HIT_COUNT_MIN = 0;
|
||||
public static final int MAX_HIT_COUNT_MAX = 100;
|
||||
|
||||
public static final String DAMAGE_PATH = "weapon.true_excalibur.damage";
|
||||
public static final double DAMAGE_DEFAULT = 8.0;
|
||||
public static final double DAMAGE_MIN = 0.0;
|
||||
public static final double DAMAGE_MAX = 2147483647.0;
|
||||
|
||||
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
||||
@Override
|
||||
public void onConfigLoad() {
|
||||
ConfigFactory.loadIntConfig(ROTATE_RANGE_PATH, configText("true_excalibur_rotate_range"), configTooltip("true_excalibur_rotate_range"), ROTATE_RANGE_DEFAULT, ROTATE_RANGE_MIN, ROTATE_RANGE_MAX);
|
||||
ConfigFactory.loadIntConfig(MAX_HIT_COUNT_PATH, configText("true_excalibur_max_hit_count"), configTooltip("true_excalibur_max_hit_count"), MAX_HIT_COUNT_DEFAULT, MAX_HIT_COUNT_MIN, MAX_HIT_COUNT_MAX);
|
||||
ConfigFactory.loadDoubleConfig(DAMAGE_PATH, configText("true_excalibur_damage"), configTooltip("true_excalibur_damage"), DAMAGE_DEFAULT, DAMAGE_MIN, DAMAGE_MAX);
|
||||
}
|
||||
};
|
||||
|
||||
private static Component configText(String key) {
|
||||
return Component.translatable(CONFIG_TRANSLATION_PREFIX + key);
|
||||
}
|
||||
|
||||
private static Component configTooltip(String key) {
|
||||
return Component.translatable(CONFIG_TRANSLATION_PREFIX + key + ".tooltip");
|
||||
}
|
||||
|
||||
public static int getRotateRange() {
|
||||
return Math.clamp(ConfigUtil.readInt(ROTATE_RANGE_PATH, ROTATE_RANGE_DEFAULT), ROTATE_RANGE_MIN, ROTATE_RANGE_MAX);
|
||||
}
|
||||
|
||||
public static int getMaxHitCount() {
|
||||
return Math.clamp(ConfigUtil.readInt(MAX_HIT_COUNT_PATH, MAX_HIT_COUNT_DEFAULT), MAX_HIT_COUNT_MIN, MAX_HIT_COUNT_MAX);
|
||||
}
|
||||
|
||||
public static double getDamage() {
|
||||
return Math.clamp(ConfigUtil.readDouble(DAMAGE_PATH, DAMAGE_DEFAULT), DAMAGE_MIN, DAMAGE_MAX);
|
||||
}
|
||||
|
||||
public static final ConfigListItem CONFIG_LIST_ITEM = new ConfigListItem(
|
||||
"true_excalibur",
|
||||
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/item/true_excalibur.png"),
|
||||
Component.translatable("item.lzxnoneterraria.true_excalibur"),
|
||||
CONFIG_DATA
|
||||
);
|
||||
|
||||
public TrueExcalibur() {
|
||||
super(Tiers.DIAMOND, new Item.Properties().attributes(ItemAttributeModifiers.builder()
|
||||
.add(Attributes.ATTACK_DAMAGE,
|
||||
@@ -219,8 +276,8 @@ public class TrueExcalibur extends SwordItem {
|
||||
CompoundTag custom_data = beam.getEntityData().get(SwordBeam.CUSTOM_DATA);
|
||||
if(custom_data.contains("hitEntityCount")) {
|
||||
int count = custom_data.getInt("hitEntityCount");
|
||||
if(count < Config.trueExcaliburMaxHitCount) {
|
||||
if(DamageUtil.attack(player, target, (float) Config.trueExcaliburDamage)) {
|
||||
if(count < getMaxHitCount()) {
|
||||
if(DamageUtil.attack(player, target, (float) getDamage())) {
|
||||
target.invulnerableTime = 20;
|
||||
count++;
|
||||
custom_data.putInt("hitEntityCount", count);
|
||||
@@ -244,7 +301,7 @@ public class TrueExcalibur extends SwordItem {
|
||||
|
||||
@Override
|
||||
public void generate(Entity entity, CompoundTag beamData) {
|
||||
beamData.putInt("rotate", (int) (Config.trueExcaliburRotateRange * (Math.random() * 2 - 1)));
|
||||
beamData.putInt("rotate", (int) (getRotateRange() * (Math.random() * 2 - 1)));
|
||||
ISwordBeamBehavior.super.generate(entity, beamData);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.lzxnone.terraria.item.weapon.melee;
|
||||
|
||||
import com.lzxnone.terraria.Config;
|
||||
import com.lzxnone.terraria.LzxnoneTerraria;
|
||||
import com.lzxnone.terraria.ModSounds;
|
||||
import com.lzxnone.terraria.entity.ModEntities;
|
||||
@@ -43,10 +42,146 @@ import net.neoforged.neoforge.event.entity.player.PlayerInteractEvent;
|
||||
import net.neoforged.neoforge.network.PacketDistributor;
|
||||
import org.joml.Quaternionf;
|
||||
import org.joml.Vector3f;
|
||||
import com.lzxnone.terraria.ui.config.ConfigFactory;
|
||||
import com.lzxnone.terraria.ui.config.ConfigListItem;
|
||||
import com.lzxnone.terraria.ui.config.ConfigUtil;
|
||||
import com.lzxnone.terraria.ui.config.IConfigData;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class TrueNightsEdge extends SwordItem {
|
||||
private static final String CONFIG_TRANSLATION_PREFIX = "lzxnoneterraria.configuration.";
|
||||
|
||||
public static final String PROJECTILE_ALIGN_TO_BLADE_PATH = "weapon.true_nights_edge.projectile_align_to_blade";
|
||||
public static final boolean PROJECTILE_ALIGN_TO_BLADE_DEFAULT = true;
|
||||
|
||||
public static final String ROTATE_RANGE_PATH = "weapon.true_nights_edge.rotate_range";
|
||||
public static final int ROTATE_RANGE_DEFAULT = 45;
|
||||
public static final int ROTATE_RANGE_MIN = 0;
|
||||
public static final int ROTATE_RANGE_MAX = 90;
|
||||
|
||||
public static final String PROJECTILE_ROTATE_RANGE_PATH = "weapon.true_nights_edge.projectile_rotate_range";
|
||||
public static final int PROJECTILE_ROTATE_RANGE_DEFAULT = 45;
|
||||
public static final int PROJECTILE_ROTATE_RANGE_MIN = 0;
|
||||
public static final int PROJECTILE_ROTATE_RANGE_MAX = 90;
|
||||
|
||||
public static final String MAX_HIT_COUNT_PATH = "weapon.true_nights_edge.max_hit_count";
|
||||
public static final int MAX_HIT_COUNT_DEFAULT = 2;
|
||||
public static final int MAX_HIT_COUNT_MIN = 0;
|
||||
public static final int MAX_HIT_COUNT_MAX = 100;
|
||||
|
||||
public static final String PROJECTILE_MAX_HIT_COUNT_PATH = "weapon.true_nights_edge.projectile_max_hit_count";
|
||||
public static final int PROJECTILE_MAX_HIT_COUNT_DEFAULT = 3;
|
||||
public static final int PROJECTILE_MAX_HIT_COUNT_MIN = 0;
|
||||
public static final int PROJECTILE_MAX_HIT_COUNT_MAX = 100;
|
||||
|
||||
public static final String DAMAGE_PATH = "weapon.true_nights_edge.damage";
|
||||
public static final double DAMAGE_DEFAULT = 8.0;
|
||||
public static final double DAMAGE_MIN = 0.0;
|
||||
public static final double DAMAGE_MAX = 2147483647.0;
|
||||
|
||||
public static final String PROJECTILE_DAMAGE_PATH = "weapon.true_nights_edge.projectile_damage";
|
||||
public static final double PROJECTILE_DAMAGE_DEFAULT = 4.0;
|
||||
public static final double PROJECTILE_DAMAGE_MIN = 0.0;
|
||||
public static final double PROJECTILE_DAMAGE_MAX = 2147483647.0;
|
||||
|
||||
public static final String PROJECTILE_MAX_SPEED_PATH = "weapon.true_nights_edge.projectile_max_speed";
|
||||
public static final double PROJECTILE_MAX_SPEED_DEFAULT = 2.0;
|
||||
public static final double PROJECTILE_MAX_SPEED_MIN = 0.0;
|
||||
public static final double PROJECTILE_MAX_SPEED_MAX = 10.0;
|
||||
|
||||
public static final String PROJECTILE_ACCELERATION_PATH = "weapon.true_nights_edge.projectile_acceleration";
|
||||
public static final double PROJECTILE_ACCELERATION_DEFAULT = 0.03;
|
||||
public static final double PROJECTILE_ACCELERATION_MIN = 0.0;
|
||||
public static final double PROJECTILE_ACCELERATION_MAX = 10.0;
|
||||
|
||||
public static final String PROJECTILE_LIFETIME_PATH = "weapon.true_nights_edge.projectile_lifetime";
|
||||
public static final int PROJECTILE_LIFETIME_DEFAULT = 60;
|
||||
public static final int PROJECTILE_LIFETIME_MIN = 1;
|
||||
public static final int PROJECTILE_LIFETIME_MAX = 1200;
|
||||
|
||||
public static final String PROJECTILE_ROTATION_SPEED_PATH = "weapon.true_nights_edge.projectile_rotation_speed";
|
||||
public static final int PROJECTILE_ROTATION_SPEED_DEFAULT = 30;
|
||||
public static final int PROJECTILE_ROTATION_SPEED_MIN = 0;
|
||||
public static final int PROJECTILE_ROTATION_SPEED_MAX = 360;
|
||||
|
||||
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
||||
@Override
|
||||
public void onConfigLoad() {
|
||||
ConfigFactory.loadBooleanConfig(PROJECTILE_ALIGN_TO_BLADE_PATH, configText("true_nights_edge_projectile_align_to_blade"), configTooltip("true_nights_edge_projectile_align_to_blade"), PROJECTILE_ALIGN_TO_BLADE_DEFAULT);
|
||||
ConfigFactory.loadIntConfig(ROTATE_RANGE_PATH, configText("true_nights_edge_rotate_range"), configTooltip("true_nights_edge_rotate_range"), ROTATE_RANGE_DEFAULT, ROTATE_RANGE_MIN, ROTATE_RANGE_MAX);
|
||||
ConfigFactory.loadIntConfig(PROJECTILE_ROTATE_RANGE_PATH, configText("true_nights_edge_projectile_rotate_range"), configTooltip("true_nights_edge_projectile_rotate_range"), PROJECTILE_ROTATE_RANGE_DEFAULT, PROJECTILE_ROTATE_RANGE_MIN, PROJECTILE_ROTATE_RANGE_MAX);
|
||||
ConfigFactory.loadIntConfig(MAX_HIT_COUNT_PATH, configText("true_nights_edge_max_hit_count"), configTooltip("true_nights_edge_max_hit_count"), MAX_HIT_COUNT_DEFAULT, MAX_HIT_COUNT_MIN, MAX_HIT_COUNT_MAX);
|
||||
ConfigFactory.loadIntConfig(PROJECTILE_MAX_HIT_COUNT_PATH, configText("true_nights_edge_projectile_max_hit_count"), configTooltip("true_nights_edge_projectile_max_hit_count"), PROJECTILE_MAX_HIT_COUNT_DEFAULT, PROJECTILE_MAX_HIT_COUNT_MIN, PROJECTILE_MAX_HIT_COUNT_MAX);
|
||||
ConfigFactory.loadDoubleConfig(DAMAGE_PATH, configText("true_nights_edge_damage"), configTooltip("true_nights_edge_damage"), DAMAGE_DEFAULT, DAMAGE_MIN, DAMAGE_MAX);
|
||||
ConfigFactory.loadDoubleConfig(PROJECTILE_DAMAGE_PATH, configText("true_nights_edge_projectile_damage"), configTooltip("true_nights_edge_projectile_damage"), PROJECTILE_DAMAGE_DEFAULT, PROJECTILE_DAMAGE_MIN, PROJECTILE_DAMAGE_MAX);
|
||||
ConfigFactory.loadDoubleConfig(PROJECTILE_MAX_SPEED_PATH, configText("true_nights_edge_projectile_max_speed"), configTooltip("true_nights_edge_projectile_max_speed"), PROJECTILE_MAX_SPEED_DEFAULT, PROJECTILE_MAX_SPEED_MIN, PROJECTILE_MAX_SPEED_MAX);
|
||||
ConfigFactory.loadDoubleConfig(PROJECTILE_ACCELERATION_PATH, configText("true_nights_edge_projectile_acceleration"), configTooltip("true_nights_edge_projectile_acceleration"), PROJECTILE_ACCELERATION_DEFAULT, PROJECTILE_ACCELERATION_MIN, PROJECTILE_ACCELERATION_MAX);
|
||||
ConfigFactory.loadIntConfig(PROJECTILE_LIFETIME_PATH, configText("true_nights_edge_projectile_lifetime"), configTooltip("true_nights_edge_projectile_lifetime"), PROJECTILE_LIFETIME_DEFAULT, PROJECTILE_LIFETIME_MIN, PROJECTILE_LIFETIME_MAX);
|
||||
ConfigFactory.loadIntConfig(PROJECTILE_ROTATION_SPEED_PATH, configText("true_nights_edge_projectile_rotation_speed"), configTooltip("true_nights_edge_projectile_rotation_speed"), PROJECTILE_ROTATION_SPEED_DEFAULT, PROJECTILE_ROTATION_SPEED_MIN, PROJECTILE_ROTATION_SPEED_MAX);
|
||||
}
|
||||
};
|
||||
|
||||
private static Component configText(String key) {
|
||||
return Component.translatable(CONFIG_TRANSLATION_PREFIX + key);
|
||||
}
|
||||
|
||||
private static Component configTooltip(String key) {
|
||||
return Component.translatable(CONFIG_TRANSLATION_PREFIX + key + ".tooltip");
|
||||
}
|
||||
|
||||
public static boolean isProjectileAlignToBlade() {
|
||||
return ConfigUtil.readBoolean(PROJECTILE_ALIGN_TO_BLADE_PATH, PROJECTILE_ALIGN_TO_BLADE_DEFAULT);
|
||||
}
|
||||
|
||||
public static int getRotateRange() {
|
||||
return Math.clamp(ConfigUtil.readInt(ROTATE_RANGE_PATH, ROTATE_RANGE_DEFAULT), ROTATE_RANGE_MIN, ROTATE_RANGE_MAX);
|
||||
}
|
||||
|
||||
public static int getProjectileRotateRange() {
|
||||
return Math.clamp(ConfigUtil.readInt(PROJECTILE_ROTATE_RANGE_PATH, PROJECTILE_ROTATE_RANGE_DEFAULT), PROJECTILE_ROTATE_RANGE_MIN, PROJECTILE_ROTATE_RANGE_MAX);
|
||||
}
|
||||
|
||||
public static int getMaxHitCount() {
|
||||
return Math.clamp(ConfigUtil.readInt(MAX_HIT_COUNT_PATH, MAX_HIT_COUNT_DEFAULT), MAX_HIT_COUNT_MIN, MAX_HIT_COUNT_MAX);
|
||||
}
|
||||
|
||||
public static int getProjectileMaxHitCount() {
|
||||
return Math.clamp(ConfigUtil.readInt(PROJECTILE_MAX_HIT_COUNT_PATH, PROJECTILE_MAX_HIT_COUNT_DEFAULT), PROJECTILE_MAX_HIT_COUNT_MIN, PROJECTILE_MAX_HIT_COUNT_MAX);
|
||||
}
|
||||
|
||||
public static double getDamage() {
|
||||
return Math.clamp(ConfigUtil.readDouble(DAMAGE_PATH, DAMAGE_DEFAULT), DAMAGE_MIN, DAMAGE_MAX);
|
||||
}
|
||||
|
||||
public static double getProjectileDamage() {
|
||||
return Math.clamp(ConfigUtil.readDouble(PROJECTILE_DAMAGE_PATH, PROJECTILE_DAMAGE_DEFAULT), PROJECTILE_DAMAGE_MIN, PROJECTILE_DAMAGE_MAX);
|
||||
}
|
||||
|
||||
public static double getProjectileMaxSpeed() {
|
||||
return Math.clamp(ConfigUtil.readDouble(PROJECTILE_MAX_SPEED_PATH, PROJECTILE_MAX_SPEED_DEFAULT), PROJECTILE_MAX_SPEED_MIN, PROJECTILE_MAX_SPEED_MAX);
|
||||
}
|
||||
|
||||
public static double getProjectileAcceleration() {
|
||||
return Math.clamp(ConfigUtil.readDouble(PROJECTILE_ACCELERATION_PATH, PROJECTILE_ACCELERATION_DEFAULT), PROJECTILE_ACCELERATION_MIN, PROJECTILE_ACCELERATION_MAX);
|
||||
}
|
||||
|
||||
public static int getProjectileLifetime() {
|
||||
return Math.clamp(ConfigUtil.readInt(PROJECTILE_LIFETIME_PATH, PROJECTILE_LIFETIME_DEFAULT), PROJECTILE_LIFETIME_MIN, PROJECTILE_LIFETIME_MAX);
|
||||
}
|
||||
|
||||
public static int getProjectileRotationSpeed() {
|
||||
return Math.clamp(ConfigUtil.readInt(PROJECTILE_ROTATION_SPEED_PATH, PROJECTILE_ROTATION_SPEED_DEFAULT), PROJECTILE_ROTATION_SPEED_MIN, PROJECTILE_ROTATION_SPEED_MAX);
|
||||
}
|
||||
|
||||
public static final ConfigListItem CONFIG_LIST_ITEM = new ConfigListItem(
|
||||
"true_nights_edge",
|
||||
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/item/true_nights_edge.png"),
|
||||
Component.translatable("item.lzxnoneterraria.true_nights_edge"),
|
||||
CONFIG_DATA
|
||||
);
|
||||
|
||||
public TrueNightsEdge() {
|
||||
super(Tiers.DIAMOND, new Item.Properties().attributes(ItemAttributeModifiers.builder()
|
||||
.add(Attributes.ATTACK_DAMAGE,
|
||||
@@ -197,8 +332,8 @@ public class TrueNightsEdge extends SwordItem {
|
||||
CompoundTag custom_data = beam.getEntityData().get(SwordBeam.CUSTOM_DATA);
|
||||
if(custom_data.contains("hitEntityCount")) {
|
||||
int count = custom_data.getInt("hitEntityCount");
|
||||
if(count < Config.trueNightsEdgeMaxHitCount) {
|
||||
if(DamageUtil.attack(player, target, (float) Config.trueNightsEdgeDamage)) {
|
||||
if(count < getMaxHitCount()) {
|
||||
if(DamageUtil.attack(player, target, (float) getDamage())) {
|
||||
ParticleUtil.addParticles(
|
||||
(ServerLevel) target.level(), ModParticles.NIGHTS_EDGE_HIT_PARTICLE.get(),
|
||||
new Vec3(target.getX(), target.getY() + target.getBbHeight() / 2.0, target.getZ()), new Vec3(0, 0, 0),
|
||||
@@ -217,7 +352,7 @@ public class TrueNightsEdge extends SwordItem {
|
||||
|
||||
@Override
|
||||
public void generate(Entity entity, CompoundTag beamData) {
|
||||
int randomAngle = (int) (Config.trueNightsEdgeRotateRange * (Math.random() * 2 - 1));
|
||||
int randomAngle = (int) (getRotateRange() * (Math.random() * 2 - 1));
|
||||
beamData.putInt("rotate", randomAngle);
|
||||
ISwordBeamBehavior.super.generate(entity, beamData);
|
||||
if(entity instanceof Player player) summon(player, randomAngle);
|
||||
@@ -410,8 +545,8 @@ public class TrueNightsEdge extends SwordItem {
|
||||
//运动逻辑
|
||||
Vec3 motion = summon.getDeltaMovement();
|
||||
double currentSpeed = motion.length();
|
||||
double maxSpeed = Config.trueNightsEdgeProjectileMaxSpeed;
|
||||
double acceleration = Config.trueNightsEdgeProjectileAcceleration;
|
||||
double maxSpeed = getProjectileMaxSpeed();
|
||||
double acceleration = getProjectileAcceleration();
|
||||
if(currentSpeed < maxSpeed && currentSpeed > 0) {
|
||||
Vec3 dir = motion.normalize();
|
||||
double newSpeed = Math.min(currentSpeed + acceleration, maxSpeed);
|
||||
@@ -432,11 +567,11 @@ public class TrueNightsEdge extends SwordItem {
|
||||
//碰撞计算
|
||||
if(!summon.level().isClientSide() && customData.contains("hitCount") && summon.getOwner() instanceof Player player) {
|
||||
int count = customData.getInt("hitCount");
|
||||
if(count < Config.trueNightsEdgeProjectileMaxHitCount) {
|
||||
if(count < getProjectileMaxHitCount()) {
|
||||
List<Entity> targets = summon.level().getEntitiesOfClass(Entity.class, summon.getBoundingBox(), FilterUtil.createTargetFilter(summon, summon.getOwner()));
|
||||
for(Entity target : targets) {
|
||||
if(count >= Config.trueNightsEdgeProjectileMaxHitCount) break;
|
||||
if(DamageUtil.attack(player, target, (float) Config.trueNightsEdgeProjectileDamage)) {
|
||||
if(count >= getProjectileMaxHitCount()) break;
|
||||
if(DamageUtil.attack(player, target, (float) getProjectileDamage())) {
|
||||
count++;
|
||||
ParticleUtil.addParticles(
|
||||
(ServerLevel) target.level(), ModParticles.TRUE_NIGHTS_EDGE_HIT_PARTICLE.get(),
|
||||
@@ -448,7 +583,7 @@ public class TrueNightsEdge extends SwordItem {
|
||||
}
|
||||
if(!targets.isEmpty()) customData.putInt("hitCount", count);
|
||||
}
|
||||
if(count >= Config.trueNightsEdgeProjectileMaxHitCount) this.onDied(summon);
|
||||
if(count >= getProjectileMaxHitCount()) this.onDied(summon);
|
||||
}
|
||||
|
||||
ClipContext context = new ClipContext(
|
||||
@@ -480,7 +615,7 @@ public class TrueNightsEdge extends SwordItem {
|
||||
Vec3 pos = new Vec3(player.getX(), player.getEyeY() - 0.1, player.getZ());
|
||||
summon.setPos(pos);
|
||||
|
||||
if(!Config.trueNightsEdgeProjectileAlignToBlade) randomAngle = (int) (Config.trueNightsEdgeProjectileRotateRange * (Math.random() * 2 - 1));
|
||||
if(!isProjectileAlignToBlade()) randomAngle = (int) (getProjectileRotateRange() * (Math.random() * 2 - 1));
|
||||
|
||||
Vector3f[] dirs = MathUtil.computeCoordinateSystem(player);
|
||||
dirs = MathUtil.rotateCoordinateSystem(dirs[0], dirs[2], randomAngle);
|
||||
@@ -492,9 +627,9 @@ public class TrueNightsEdge extends SwordItem {
|
||||
|
||||
summon.getEntityData().set(StaticSummon.BEHAVIOR, StaticSummonBehaviors.TRUE_NIGHTS_EDGE_BEAM);
|
||||
summon.getEntityData().set(StaticSummon.RENDER_MODE, "custom");
|
||||
summon.getEntityData().set(StaticSummon.LIFETIME, Config.trueNightsEdgeProjectileLifetime);
|
||||
summon.getEntityData().set(StaticSummon.LIFETIME, getProjectileLifetime());
|
||||
summon.getEntityData().set(StaticSummon.RZP, randomAngle);
|
||||
summon.getEntityData().set(StaticSummon.RZPS, Config.trueNightsEdgeProjectileRotationSpeed);
|
||||
summon.getEntityData().set(StaticSummon.RZPS, getProjectileRotationSpeed());
|
||||
summon.getEntityData().set(StaticSummon.GLOW, true);
|
||||
summon.setNoGravity(true);
|
||||
summon.noPhysics = true;
|
||||
@@ -531,7 +666,7 @@ public class TrueNightsEdge extends SwordItem {
|
||||
customData.putFloat("rightZ", dirs[2].z);
|
||||
summon.getEntityData().set(StaticSummon.CUSTOM_DATA, customData);
|
||||
|
||||
summon.setDeltaMovement(player.getLookAngle().normalize().scale(Config.trueNightsEdgeProjectileMaxSpeed * 0.1));
|
||||
summon.setDeltaMovement(player.getLookAngle().normalize().scale(getProjectileMaxSpeed() * 0.1));
|
||||
|
||||
player.level().addFreshEntity(summon);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.lzxnone.terraria.item.weapon.melee;
|
||||
|
||||
import com.lzxnone.terraria.Config;
|
||||
import com.lzxnone.terraria.LzxnoneTerraria;
|
||||
import com.lzxnone.terraria.ModSounds;
|
||||
import com.lzxnone.terraria.entity.ModEntities;
|
||||
@@ -10,10 +9,15 @@ import com.lzxnone.terraria.entity.summon.StaticSummonBehaviors;
|
||||
import com.lzxnone.terraria.item.IItemWaveBehavior;
|
||||
import com.lzxnone.terraria.particle.DustParticleOptions;
|
||||
import com.lzxnone.terraria.particle.ModParticles;
|
||||
import com.lzxnone.terraria.ui.config.ConfigFactory;
|
||||
import com.lzxnone.terraria.ui.config.ConfigListItem;
|
||||
import com.lzxnone.terraria.ui.config.ConfigUtil;
|
||||
import com.lzxnone.terraria.ui.config.IConfigData;
|
||||
import com.lzxnone.terraria.utils.DamageUtil;
|
||||
import com.lzxnone.terraria.utils.FilterUtil;
|
||||
import com.lzxnone.terraria.utils.ParticleUtil;
|
||||
import com.lzxnone.terraria.utils.SoundUtil;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
@@ -38,6 +42,28 @@ import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
public class Volcano extends SwordItem {
|
||||
private static final String CONFIG_TRANSLATION_PREFIX = "lzxnoneterraria.configuration.";
|
||||
|
||||
public static final String EXPLOSION_RANGE_PATH = "weapon.volcano.explosion_range";
|
||||
public static final double EXPLOSION_RANGE_DEFAULT = 4.0;
|
||||
public static final double EXPLOSION_RANGE_MIN = 1.0;
|
||||
public static final double EXPLOSION_RANGE_MAX = 64.0;
|
||||
|
||||
public static final String EXPLOSION_DAMAGE_PATH = "weapon.volcano.explosion_damage";
|
||||
public static final double EXPLOSION_DAMAGE_DEFAULT = 6.0;
|
||||
public static final double EXPLOSION_DAMAGE_MIN = 0.0;
|
||||
public static final double EXPLOSION_DAMAGE_MAX = 2147483647.0;
|
||||
|
||||
public static final String EXPLOSION_MAX_HIT_COUNT_PATH = "weapon.volcano.explosion_max_hit_count";
|
||||
public static final int EXPLOSION_MAX_HIT_COUNT_DEFAULT = 2;
|
||||
public static final int EXPLOSION_MAX_HIT_COUNT_MIN = 0;
|
||||
public static final int EXPLOSION_MAX_HIT_COUNT_MAX = 100;
|
||||
|
||||
public static final String IGNITE_SECONDS_PATH = "weapon.volcano.ignite_seconds";
|
||||
public static final int IGNITE_SECONDS_DEFAULT = 3;
|
||||
public static final int IGNITE_SECONDS_MIN = 0;
|
||||
public static final int IGNITE_SECONDS_MAX = 60;
|
||||
|
||||
public Volcano() {
|
||||
super(Tiers.IRON, new Item.Properties().attributes(ItemAttributeModifiers.builder()
|
||||
.add(Attributes.ATTACK_DAMAGE,
|
||||
@@ -50,6 +76,47 @@ public class Volcano extends SwordItem {
|
||||
));
|
||||
}
|
||||
|
||||
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
||||
@Override
|
||||
public void onConfigLoad() {
|
||||
ConfigFactory.loadDoubleConfig(EXPLOSION_RANGE_PATH, configText("volcano_explosion_range"), configTooltip("volcano_explosion_range"), EXPLOSION_RANGE_DEFAULT, EXPLOSION_RANGE_MIN, EXPLOSION_RANGE_MAX);
|
||||
ConfigFactory.loadDoubleConfig(EXPLOSION_DAMAGE_PATH, configText("volcano_explosion_damage"), configTooltip("volcano_explosion_damage"), EXPLOSION_DAMAGE_DEFAULT, EXPLOSION_DAMAGE_MIN, EXPLOSION_DAMAGE_MAX);
|
||||
ConfigFactory.loadIntConfig(EXPLOSION_MAX_HIT_COUNT_PATH, configText("volcano_explosion_max_hit_count"), configTooltip("volcano_explosion_max_hit_count"), EXPLOSION_MAX_HIT_COUNT_DEFAULT, EXPLOSION_MAX_HIT_COUNT_MIN, EXPLOSION_MAX_HIT_COUNT_MAX);
|
||||
ConfigFactory.loadIntConfig(IGNITE_SECONDS_PATH, configText("volcano_ignite_seconds"), configTooltip("volcano_ignite_seconds"), IGNITE_SECONDS_DEFAULT, IGNITE_SECONDS_MIN, IGNITE_SECONDS_MAX);
|
||||
}
|
||||
};
|
||||
|
||||
private static Component configText(String key) {
|
||||
return Component.translatable(CONFIG_TRANSLATION_PREFIX + key);
|
||||
}
|
||||
|
||||
private static Component configTooltip(String key) {
|
||||
return Component.translatable(CONFIG_TRANSLATION_PREFIX + key + ".tooltip");
|
||||
}
|
||||
|
||||
public static double getExplosionRange() {
|
||||
return Math.clamp(ConfigUtil.readDouble(EXPLOSION_RANGE_PATH, EXPLOSION_RANGE_DEFAULT), EXPLOSION_RANGE_MIN, EXPLOSION_RANGE_MAX);
|
||||
}
|
||||
|
||||
public static double getExplosionDamage() {
|
||||
return Math.clamp(ConfigUtil.readDouble(EXPLOSION_DAMAGE_PATH, EXPLOSION_DAMAGE_DEFAULT), EXPLOSION_DAMAGE_MIN, EXPLOSION_DAMAGE_MAX);
|
||||
}
|
||||
|
||||
public static int getExplosionMaxHitCount() {
|
||||
return Math.clamp(ConfigUtil.readInt(EXPLOSION_MAX_HIT_COUNT_PATH, EXPLOSION_MAX_HIT_COUNT_DEFAULT), EXPLOSION_MAX_HIT_COUNT_MIN, EXPLOSION_MAX_HIT_COUNT_MAX);
|
||||
}
|
||||
|
||||
public static int getIgniteSeconds() {
|
||||
return Math.clamp(ConfigUtil.readInt(IGNITE_SECONDS_PATH, IGNITE_SECONDS_DEFAULT), IGNITE_SECONDS_MIN, IGNITE_SECONDS_MAX);
|
||||
}
|
||||
|
||||
public static final ConfigListItem CONFIG_LIST_ITEM = new ConfigListItem(
|
||||
"volcano",
|
||||
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/item/volcano.png"),
|
||||
Component.translatable("item.lzxnoneterraria.volcano"),
|
||||
CONFIG_DATA
|
||||
);
|
||||
|
||||
public static final DustParticleOptions PARTICLE = new DustParticleOptions(
|
||||
0.075f, 0.5f, 40, true, new Vector3f[]{
|
||||
new Vector3f(1.0F, 0.8F, 0.5F),
|
||||
@@ -110,16 +177,16 @@ public class Volcano extends SwordItem {
|
||||
if(!player.getCooldowns().isOnCooldown(item)) {
|
||||
List<LivingEntity> targets = player.level().getEntitiesOfClass(
|
||||
LivingEntity.class,
|
||||
AABB.ofSize(player.getBoundingBox().getCenter(), Config.volcanoExplosionRange * 2, Config.volcanoExplosionRange * 2, Config.volcanoExplosionRange * 2),
|
||||
AABB.ofSize(player.getBoundingBox().getCenter(), getExplosionRange() * 2, getExplosionRange() * 2, getExplosionRange() * 2),
|
||||
FilterUtil.createLivingTargetFilter(player)
|
||||
);
|
||||
targets.sort(Comparator.comparingDouble(e -> e.distanceToSqr(target.position())));
|
||||
int hitCount = 0;
|
||||
for(LivingEntity livingEntity : targets) {
|
||||
if(livingEntity.getUUID() == target.getUUID()) continue;
|
||||
if(hitCount >= Config.volcanoExplosionMaxHitCount) break;
|
||||
if(DamageUtil.attack(player, livingEntity, (float) Config.volcanoExplosionDamage)) {
|
||||
livingTarget.igniteForSeconds(Config.volcanoIgniteSeconds);
|
||||
if(hitCount >= getExplosionMaxHitCount()) break;
|
||||
if(DamageUtil.attack(player, livingEntity, (float) getExplosionDamage())) {
|
||||
livingTarget.igniteForSeconds(getIgniteSeconds());
|
||||
hitCount++;
|
||||
}
|
||||
}
|
||||
@@ -160,7 +227,7 @@ public class Volcano extends SwordItem {
|
||||
);
|
||||
player.getCooldowns().addCooldown(item, 10);
|
||||
}
|
||||
if(player.getRandom().nextInt(2) == 0) livingTarget.igniteForSeconds(Config.volcanoIgniteSeconds);
|
||||
if(player.getRandom().nextInt(2) == 0) livingTarget.igniteForSeconds(getIgniteSeconds());
|
||||
}
|
||||
}else {
|
||||
ParticleUtil.addParticles(
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.lzxnone.terraria.item.weapon.melee;
|
||||
|
||||
import com.lzxnone.terraria.Config;
|
||||
import com.lzxnone.terraria.LzxnoneTerraria;
|
||||
import com.lzxnone.terraria.ModSounds;
|
||||
import com.lzxnone.terraria.entity.ModEntities;
|
||||
@@ -42,10 +41,156 @@ import org.joml.Matrix4f;
|
||||
import org.joml.Quaternionf;
|
||||
import org.joml.Vector3f;
|
||||
import org.jspecify.annotations.NonNull;
|
||||
import com.lzxnone.terraria.ui.config.ConfigFactory;
|
||||
import com.lzxnone.terraria.ui.config.ConfigListItem;
|
||||
import com.lzxnone.terraria.ui.config.ConfigUtil;
|
||||
import com.lzxnone.terraria.ui.config.IConfigData;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Zenith extends SwordItem {
|
||||
private static final String CONFIG_TRANSLATION_PREFIX = "lzxnoneterraria.configuration.";
|
||||
|
||||
public static final String DAMAGE_PATH = "weapon.zenith.damage";
|
||||
public static final double DAMAGE_DEFAULT = 4.0;
|
||||
public static final double DAMAGE_MIN = 1.0;
|
||||
public static final double DAMAGE_MAX = 2147483647.0;
|
||||
|
||||
public static final String MAX_RANGE_PATH = "weapon.zenith.max_range";
|
||||
public static final double MAX_RANGE_DEFAULT = 64.0;
|
||||
public static final double MAX_RANGE_MIN = 1.0;
|
||||
public static final double MAX_RANGE_MAX = 1024.0;
|
||||
|
||||
public static final String DISTANCE_MODE_PATH = "weapon.zenith.distance_mode";
|
||||
public static final boolean DISTANCE_MODE_DEFAULT = true;
|
||||
|
||||
public static final String MOUSE_SPEED_PATH = "weapon.zenith.mouse_speed";
|
||||
public static final int MOUSE_SPEED_DEFAULT = 4;
|
||||
public static final int MOUSE_SPEED_MIN = 0;
|
||||
public static final int MOUSE_SPEED_MAX = 128;
|
||||
|
||||
public static final String TRAIL_B_PATH = "weapon.zenith.trail_b";
|
||||
public static final double TRAIL_B_DEFAULT = 4.0;
|
||||
public static final double TRAIL_B_MIN = 0.1;
|
||||
public static final double TRAIL_B_MAX = 512.0;
|
||||
|
||||
public static final String TRAIL_OFFSET_PATH = "weapon.zenith.trail_offset";
|
||||
public static final int TRAIL_OFFSET_DEFAULT = 30;
|
||||
public static final int TRAIL_OFFSET_MIN = 0;
|
||||
public static final int TRAIL_OFFSET_MAX = 90;
|
||||
|
||||
public static final String WEAPON_COUNT_PATH = "weapon.zenith.weapon_count";
|
||||
public static final int WEAPON_COUNT_DEFAULT = 3;
|
||||
public static final int WEAPON_COUNT_MIN = 1;
|
||||
public static final int WEAPON_COUNT_MAX = 3;
|
||||
|
||||
public static final String BOUNDING_BOX_SIZE_PATH = "weapon.zenith.bounding_box_size";
|
||||
public static final double BOUNDING_BOX_SIZE_DEFAULT = 1.5;
|
||||
public static final double BOUNDING_BOX_SIZE_MIN = 0.1;
|
||||
public static final double BOUNDING_BOX_SIZE_MAX = 4.0;
|
||||
|
||||
public static final String CYCLE_PATH = "weapon.zenith.cycle";
|
||||
public static final int CYCLE_DEFAULT = 20;
|
||||
public static final int CYCLE_MIN = 10;
|
||||
public static final int CYCLE_MAX = 100;
|
||||
|
||||
public static final String SCALE_PATH = "weapon.zenith.scale";
|
||||
public static final double SCALE_DEFAULT = 2.0;
|
||||
public static final double SCALE_MIN = 0.1;
|
||||
public static final double SCALE_MAX = 10.0;
|
||||
|
||||
public static final String TRAIL_ALPHA_PATH = "weapon.zenith.trail_alpha";
|
||||
public static final double TRAIL_ALPHA_DEFAULT = 0.15;
|
||||
public static final double TRAIL_ALPHA_MIN = 0.0;
|
||||
public static final double TRAIL_ALPHA_MAX = 1.0;
|
||||
|
||||
public static final String TRAIL_MAX_LENGTH_PATH = "weapon.zenith.trail_max_length";
|
||||
public static final int TRAIL_MAX_LENGTH_DEFAULT = 10;
|
||||
public static final int TRAIL_MAX_LENGTH_MIN = 0;
|
||||
public static final int TRAIL_MAX_LENGTH_MAX = 100;
|
||||
|
||||
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
||||
@Override
|
||||
public void onConfigLoad() {
|
||||
ConfigFactory.loadDoubleConfig(DAMAGE_PATH, configText("zenith_damage"), configTooltip("zenith_damage"), DAMAGE_DEFAULT, DAMAGE_MIN, DAMAGE_MAX);
|
||||
ConfigFactory.loadDoubleConfig(MAX_RANGE_PATH, configText("zenith_max_range"), configTooltip("zenith_max_range"), MAX_RANGE_DEFAULT, MAX_RANGE_MIN, MAX_RANGE_MAX);
|
||||
ConfigFactory.loadBooleanConfig(DISTANCE_MODE_PATH, configText("zenith_distance_mode"), configTooltip("zenith_distance_mode"), DISTANCE_MODE_DEFAULT);
|
||||
ConfigFactory.loadIntConfig(MOUSE_SPEED_PATH, configText("zenith_mouse_speed"), configTooltip("zenith_mouse_speed"), MOUSE_SPEED_DEFAULT, MOUSE_SPEED_MIN, MOUSE_SPEED_MAX);
|
||||
ConfigFactory.loadDoubleConfig(TRAIL_B_PATH, configText("zenith_trail_b"), configTooltip("zenith_trail_b"), TRAIL_B_DEFAULT, TRAIL_B_MIN, TRAIL_B_MAX);
|
||||
ConfigFactory.loadIntConfig(TRAIL_OFFSET_PATH, configText("zenith_trail_offset"), configTooltip("zenith_trail_offset"), TRAIL_OFFSET_DEFAULT, TRAIL_OFFSET_MIN, TRAIL_OFFSET_MAX);
|
||||
ConfigFactory.loadIntConfig(WEAPON_COUNT_PATH, configText("zenith_weapon_count"), configTooltip("zenith_weapon_count"), WEAPON_COUNT_DEFAULT, WEAPON_COUNT_MIN, WEAPON_COUNT_MAX);
|
||||
ConfigFactory.loadDoubleConfig(BOUNDING_BOX_SIZE_PATH, configText("zenith_bounding_box_size"), configTooltip("zenith_bounding_box_size"), BOUNDING_BOX_SIZE_DEFAULT, BOUNDING_BOX_SIZE_MIN, BOUNDING_BOX_SIZE_MAX);
|
||||
ConfigFactory.loadIntConfig(CYCLE_PATH, configText("zenith_cycle"), configTooltip("zenith_cycle"), CYCLE_DEFAULT, CYCLE_MIN, CYCLE_MAX);
|
||||
ConfigFactory.loadDoubleConfig(SCALE_PATH, configText("zenith_scale"), configTooltip("zenith_scale"), SCALE_DEFAULT, SCALE_MIN, SCALE_MAX);
|
||||
ConfigFactory.loadDoubleConfig(TRAIL_ALPHA_PATH, configText("zenith_trail_alpha"), configTooltip("zenith_trail_alpha"), TRAIL_ALPHA_DEFAULT, TRAIL_ALPHA_MIN, TRAIL_ALPHA_MAX);
|
||||
ConfigFactory.loadIntConfig(TRAIL_MAX_LENGTH_PATH, configText("zenith_trail_max_length"), configTooltip("zenith_trail_max_length"), TRAIL_MAX_LENGTH_DEFAULT, TRAIL_MAX_LENGTH_MIN, TRAIL_MAX_LENGTH_MAX);
|
||||
}
|
||||
};
|
||||
|
||||
private static Component configText(String key) {
|
||||
return Component.translatable(CONFIG_TRANSLATION_PREFIX + key);
|
||||
}
|
||||
|
||||
private static Component configTooltip(String key) {
|
||||
return Component.translatable(CONFIG_TRANSLATION_PREFIX + key + ".tooltip");
|
||||
}
|
||||
|
||||
public static double getDamage() {
|
||||
return Math.clamp(ConfigUtil.readDouble(DAMAGE_PATH, DAMAGE_DEFAULT), DAMAGE_MIN, DAMAGE_MAX);
|
||||
}
|
||||
|
||||
public static double getMaxRange() {
|
||||
return Math.clamp(ConfigUtil.readDouble(MAX_RANGE_PATH, MAX_RANGE_DEFAULT), MAX_RANGE_MIN, MAX_RANGE_MAX);
|
||||
}
|
||||
|
||||
public static boolean isDistanceMode() {
|
||||
return ConfigUtil.readBoolean(DISTANCE_MODE_PATH, DISTANCE_MODE_DEFAULT);
|
||||
}
|
||||
|
||||
public static int getMouseSpeed() {
|
||||
return Math.clamp(ConfigUtil.readInt(MOUSE_SPEED_PATH, MOUSE_SPEED_DEFAULT), MOUSE_SPEED_MIN, MOUSE_SPEED_MAX);
|
||||
}
|
||||
|
||||
public static double getTrailB() {
|
||||
return Math.clamp(ConfigUtil.readDouble(TRAIL_B_PATH, TRAIL_B_DEFAULT), TRAIL_B_MIN, TRAIL_B_MAX);
|
||||
}
|
||||
|
||||
public static int getTrailOffset() {
|
||||
return Math.clamp(ConfigUtil.readInt(TRAIL_OFFSET_PATH, TRAIL_OFFSET_DEFAULT), TRAIL_OFFSET_MIN, TRAIL_OFFSET_MAX);
|
||||
}
|
||||
|
||||
public static int getWeaponCount() {
|
||||
return Math.clamp(ConfigUtil.readInt(WEAPON_COUNT_PATH, WEAPON_COUNT_DEFAULT), WEAPON_COUNT_MIN, WEAPON_COUNT_MAX);
|
||||
}
|
||||
|
||||
public static double getBoundingBoxSize() {
|
||||
return Math.clamp(ConfigUtil.readDouble(BOUNDING_BOX_SIZE_PATH, BOUNDING_BOX_SIZE_DEFAULT), BOUNDING_BOX_SIZE_MIN, BOUNDING_BOX_SIZE_MAX);
|
||||
}
|
||||
|
||||
public static int getCycle() {
|
||||
return Math.clamp(ConfigUtil.readInt(CYCLE_PATH, CYCLE_DEFAULT), CYCLE_MIN, CYCLE_MAX);
|
||||
}
|
||||
|
||||
public static double getScale() {
|
||||
return Math.clamp(ConfigUtil.readDouble(SCALE_PATH, SCALE_DEFAULT), SCALE_MIN, SCALE_MAX);
|
||||
}
|
||||
|
||||
public static double getTrailAlpha() {
|
||||
return Math.clamp(ConfigUtil.readDouble(TRAIL_ALPHA_PATH, TRAIL_ALPHA_DEFAULT), TRAIL_ALPHA_MIN, TRAIL_ALPHA_MAX);
|
||||
}
|
||||
|
||||
public static int getTrailMaxLength() {
|
||||
return Math.clamp(ConfigUtil.readInt(TRAIL_MAX_LENGTH_PATH, TRAIL_MAX_LENGTH_DEFAULT), TRAIL_MAX_LENGTH_MIN, TRAIL_MAX_LENGTH_MAX);
|
||||
}
|
||||
|
||||
public static final ConfigListItem CONFIG_LIST_ITEM = new ConfigListItem(
|
||||
"zenith",
|
||||
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/item/zenith.png"),
|
||||
Component.translatable("item.lzxnoneterraria.zenith"),
|
||||
CONFIG_DATA
|
||||
);
|
||||
|
||||
public Zenith() {
|
||||
super(Tiers.NETHERITE, new Item.Properties().attributes(ItemAttributeModifiers.builder()
|
||||
.add(Attributes.ATTACK_DAMAGE,
|
||||
@@ -191,7 +336,7 @@ public class Zenith extends SwordItem {
|
||||
proj.getEntityData().get(StaticProjectile.COLOR_G),
|
||||
proj.getEntityData().get(StaticProjectile.COLOR_B)
|
||||
);
|
||||
float mainAlpha = (float) Config.zenithTrailAlpha;
|
||||
float mainAlpha = (float) getTrailAlpha();
|
||||
if(idx == 1) mainAlpha = mainAlpha * 0.5f;
|
||||
if(idx == 2) mainAlpha = mainAlpha * 0.25f;
|
||||
|
||||
@@ -321,11 +466,11 @@ public class Zenith extends SwordItem {
|
||||
|
||||
projectile.trailPositions.addFirst(projectile.position().add(right.scale(-1.2)));
|
||||
projectile.trailPositions.addFirst(projectile.position().add(right.scale(1.5)));
|
||||
while(projectile.trailPositions.size() > Config.zenithTrailMaxLength) projectile.trailPositions.removeLast();
|
||||
while(projectile.trailPositions.size() > getTrailMaxLength()) projectile.trailPositions.removeLast();
|
||||
|
||||
projectile.setBoundingBox(new AABB(
|
||||
projectile.getX() - Config.zenithBoundingBoxSize, projectile.getY() - Config.zenithBoundingBoxSize, projectile.getZ() - Config.zenithBoundingBoxSize,
|
||||
projectile.getX() + Config.zenithBoundingBoxSize, projectile.getY() + Config.zenithBoundingBoxSize, projectile.getZ() + Config.zenithBoundingBoxSize
|
||||
projectile.getX() - getBoundingBoxSize(), projectile.getY() - getBoundingBoxSize(), projectile.getZ() - getBoundingBoxSize(),
|
||||
projectile.getX() + getBoundingBoxSize(), projectile.getY() + getBoundingBoxSize(), projectile.getZ() + getBoundingBoxSize()
|
||||
));
|
||||
|
||||
if(!projectile.level().isClientSide()) {
|
||||
@@ -362,7 +507,7 @@ public class Zenith extends SwordItem {
|
||||
if(!projectile.level().isClientSide()) {
|
||||
Entity target = result.getEntity();
|
||||
if(projectile.getOwner() instanceof Player player && FilterUtil.createTargetFilter(projectile, projectile.getOwner()).test(target)) {
|
||||
if(DamageUtil.attack(player, target, (float) (Config.zenithDamage + Math.random() * Config.zenithDamage))) {
|
||||
if(DamageUtil.attack(player, target, (float) (getDamage() + Math.random() * getDamage()))) {
|
||||
target.invulnerableTime = 2;
|
||||
}
|
||||
}
|
||||
@@ -372,26 +517,26 @@ public class Zenith extends SwordItem {
|
||||
|
||||
public static void summon(Player player, double deltaDist, boolean isFirst) {
|
||||
Vector3f[] dirs = MathUtil.computeCoordinateSystem(player);
|
||||
int randomAngle = (int) ((Math.random() * 2 - 1) * Config.zenithTrailOffset);
|
||||
int randomAngle = (int) ((Math.random() * 2 - 1) * getTrailOffset());
|
||||
dirs = MathUtil.rotateCoordinateSystem(dirs[0], dirs[2], randomAngle);
|
||||
|
||||
Vec3 pos = (player.getBoundingBox().getCenter()).add(MathUtil.toVec3(dirs[0]).scale(-2));
|
||||
double dist;
|
||||
if(Config.zenithDistanceMode) {
|
||||
Vec3 targetPos = MathUtil.getCrosshairPos(player, player.level(), Config.zenithMaxRange);
|
||||
dist = Math.max(0, Math.min(targetPos.subtract(pos).length() + deltaDist, Config.zenithMaxRange));
|
||||
if(isDistanceMode()) {
|
||||
Vec3 targetPos = MathUtil.getCrosshairPos(player, player.level(), getMaxRange());
|
||||
dist = Math.max(0, Math.min(targetPos.subtract(pos).length() + deltaDist, getMaxRange()));
|
||||
}else {
|
||||
dist = deltaDist;
|
||||
}
|
||||
int cycle = (int) Math.max(10, dist / Config.zenithMaxRange * Config.zenithCycle);
|
||||
int cycle = (int) Math.max(10, dist / getMaxRange() * getCycle());
|
||||
double a = Math.max(dist / 2, 2);
|
||||
double b = Math.min(Math.random() * Config.zenithTrailB + Config.zenithTrailB, a / 2);
|
||||
double b = Math.min(Math.random() * getTrailB() + getTrailB(), a / 2);
|
||||
double w = Math.PI * 2 / (double) cycle;
|
||||
if(player.getRandom().nextInt(2) == 0) w = -w;
|
||||
|
||||
int randomIndex = isFirst ? getWeapons().length - 1 : player.getRandom().nextInt(getWeapons().length);
|
||||
|
||||
for(int i = 0;i < Config.zenithWeaponCount;i++) {
|
||||
for(int i = 0;i < getWeaponCount();i++) {
|
||||
StaticProjectile projectile = new StaticProjectile(ModEntities.STATIC_PROJECTILE.get(), player.level());
|
||||
projectile.setOwner(player);
|
||||
|
||||
@@ -417,16 +562,16 @@ public class Zenith extends SwordItem {
|
||||
customData.putInt("angle", randomAngle);
|
||||
if(i == 0) {
|
||||
projectile.getEntityData().set(StaticProjectile.COLOR_A, 1.0f);
|
||||
projectile.getEntityData().set(StaticProjectile.SCALE_X, (float) Config.zenithScale);
|
||||
projectile.getEntityData().set(StaticProjectile.SCALE_Y, (float) Config.zenithScale);
|
||||
projectile.getEntityData().set(StaticProjectile.SCALE_X, (float) getScale());
|
||||
projectile.getEntityData().set(StaticProjectile.SCALE_Y, (float) getScale());
|
||||
projectile.getEntityData().set(StaticProjectile.LIFETIME, cycle);
|
||||
projectile.getEntityData().set(StaticProjectile.EXPRESSION_X, String.format("%.3f*cos(%.3ft-1.571)", b, w));
|
||||
projectile.getEntityData().set(StaticProjectile.EXPRESSION_Z, String.format("%.3f*sin(%.3ft-1.571)+%.3f", a, w, a));
|
||||
customData.putInt("start", 0);
|
||||
}else if(i == 1) {
|
||||
projectile.getEntityData().set(StaticProjectile.COLOR_A, 0.75f);
|
||||
projectile.getEntityData().set(StaticProjectile.SCALE_X, (float) Config.zenithScale * 0.75f);
|
||||
projectile.getEntityData().set(StaticProjectile.SCALE_Y, (float) Config.zenithScale * 0.75f);
|
||||
projectile.getEntityData().set(StaticProjectile.SCALE_X, (float) getScale() * 0.75f);
|
||||
projectile.getEntityData().set(StaticProjectile.SCALE_Y, (float) getScale() * 0.75f);
|
||||
projectile.getEntityData().set(StaticProjectile.LIFETIME, (int) (cycle * 1.25));
|
||||
if(w > 0) {
|
||||
projectile.getEntityData().set(StaticProjectile.EXPRESSION_X, String.format("%.3f*cos(%.3ft-3.142)", b, w));
|
||||
@@ -438,8 +583,8 @@ public class Zenith extends SwordItem {
|
||||
customData.putInt("start", (int) (cycle * 0.25));
|
||||
}else if(i == 2) {
|
||||
projectile.getEntityData().set(StaticProjectile.COLOR_A, 0.5f);
|
||||
projectile.getEntityData().set(StaticProjectile.SCALE_X, (float) Config.zenithScale * 0.5f);
|
||||
projectile.getEntityData().set(StaticProjectile.SCALE_Y, (float) Config.zenithScale * 0.5f);
|
||||
projectile.getEntityData().set(StaticProjectile.SCALE_X, (float) getScale() * 0.5f);
|
||||
projectile.getEntityData().set(StaticProjectile.SCALE_Y, (float) getScale() * 0.5f);
|
||||
projectile.getEntityData().set(StaticProjectile.LIFETIME, (int) (cycle * 1.5));
|
||||
if(w > 0) {
|
||||
projectile.getEntityData().set(StaticProjectile.EXPRESSION_X, String.format("%.3f*cos(%.3ft-4.713)", b, w));
|
||||
|
||||
+1
-2
@@ -1,6 +1,5 @@
|
||||
package com.lzxnone.terraria.network.handler;
|
||||
|
||||
import com.lzxnone.terraria.Config;
|
||||
import com.lzxnone.terraria.effect.ModEffects;
|
||||
import com.lzxnone.terraria.item.ModItems;
|
||||
import com.lzxnone.terraria.item.weapon.melee.DevilsDevastation;
|
||||
@@ -22,7 +21,7 @@ public class DevilsDevastationKillModeHandler {
|
||||
MobEffectInstance instance = player.getEffect(ModEffects.KILL_MODE_COOLDOWN);
|
||||
MobEffectInstance instance2 = player.getEffect(ModEffects.KILL_MODE);
|
||||
if(instance == null && instance2 == null) {
|
||||
MobEffectInstance effectInstance = new MobEffectInstance(ModEffects.KILL_MODE, Config.devilsDevastationKillModeTime, 0);
|
||||
MobEffectInstance effectInstance = new MobEffectInstance(ModEffects.KILL_MODE, DevilsDevastation.getKillModeTime(), 0);
|
||||
player.addEffect(effectInstance);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.lzxnone.terraria.network.handler;
|
||||
|
||||
import com.lzxnone.terraria.Config;
|
||||
import com.lzxnone.terraria.item.weapon.melee.FirstFractal;
|
||||
import com.lzxnone.terraria.network.payload.FirstFractalScrollPayload;
|
||||
import net.minecraft.core.component.DataComponents;
|
||||
@@ -21,13 +20,13 @@ public class FirstFractalScrollHandler {
|
||||
double scrollDelta = payload.scrollDelta();
|
||||
double deltaDist = weapon.getOrDefault(DataComponents.CUSTOM_DATA, CustomData.EMPTY)
|
||||
.copyTag().getDouble("deltaDist");
|
||||
double finalDelta = deltaDist + scrollDelta * Config.firstFractalScrollSpeed;
|
||||
double finalDelta = deltaDist + scrollDelta * FirstFractal.getScrollSpeed();
|
||||
|
||||
if(Config.firstFractalDistanceMode) {
|
||||
if(finalDelta > Config.firstFractalMaxRange) finalDelta = Config.firstFractalMaxRange;
|
||||
else if(finalDelta < -Config.firstFractalMaxRange) finalDelta = -Config.firstFractalMaxRange;
|
||||
if(FirstFractal.isDistanceMode()) {
|
||||
if(finalDelta > FirstFractal.getMaxRange()) finalDelta = FirstFractal.getMaxRange();
|
||||
else if(finalDelta < -FirstFractal.getMaxRange()) finalDelta = -FirstFractal.getMaxRange();
|
||||
}else {
|
||||
if(finalDelta > Config.firstFractalMaxRange) finalDelta = Config.firstFractalMaxRange;
|
||||
if(finalDelta > FirstFractal.getMaxRange()) finalDelta = FirstFractal.getMaxRange();
|
||||
else if(finalDelta < 0) finalDelta = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.lzxnone.terraria.network.handler;
|
||||
|
||||
import com.lzxnone.terraria.Config;
|
||||
import com.lzxnone.terraria.item.weapon.melee.TrueCopperShortsword;
|
||||
import com.lzxnone.terraria.item.weapon.melee.Zenith;
|
||||
import com.lzxnone.terraria.network.payload.ZenithScrollPayload;
|
||||
@@ -22,14 +21,14 @@ public class ZenithScrollHandler {
|
||||
double scrollDelta = payload.scrollDelta();
|
||||
double deltaDist = weapon.getOrDefault(DataComponents.CUSTOM_DATA, CustomData.EMPTY)
|
||||
.copyTag().getDouble("deltaDist");
|
||||
double finalDelta = deltaDist + scrollDelta * Config.zenithMouseSpeed;
|
||||
double finalDelta = deltaDist + scrollDelta * Zenith.getMouseSpeed();
|
||||
|
||||
if(Config.zenithDistanceMode) {
|
||||
if(Zenith.isDistanceMode()) {
|
||||
|
||||
if(finalDelta > Config.zenithMaxRange) finalDelta = Config.zenithMaxRange;
|
||||
else if(finalDelta < -Config.zenithMaxRange) finalDelta = -Config.zenithMaxRange;
|
||||
if(finalDelta > Zenith.getMaxRange()) finalDelta = Zenith.getMaxRange();
|
||||
else if(finalDelta < -Zenith.getMaxRange()) finalDelta = -Zenith.getMaxRange();
|
||||
}else {
|
||||
if(finalDelta > Config.zenithMaxRange) finalDelta = Config.zenithMaxRange;
|
||||
if(finalDelta > Zenith.getMaxRange()) finalDelta = Zenith.getMaxRange();
|
||||
else if(finalDelta < 0) finalDelta = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,339 @@
|
||||
package com.lzxnone.terraria.ui.config;
|
||||
|
||||
import com.lowdragmc.lowdraglib2.gui.ui.UIElement;
|
||||
import com.lowdragmc.lowdraglib2.gui.ui.elements.Button;
|
||||
import com.lowdragmc.lowdraglib2.gui.ui.elements.Label;
|
||||
import com.lowdragmc.lowdraglib2.gui.ui.elements.Scroller;
|
||||
import com.lowdragmc.lowdraglib2.gui.ui.elements.Switch;
|
||||
import com.lowdragmc.lowdraglib2.gui.ui.elements.TextField;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
||||
public class ConfigFactory {
|
||||
private static final String RESET_BUTTON_TRANSLATION_KEY = "lzxnoneterraria.configuration.reset_button";
|
||||
private static UIElement configContainer;
|
||||
|
||||
public static void bindConfigContainer(UIElement container) {
|
||||
configContainer = container;
|
||||
}
|
||||
|
||||
public static void clearConfigContainer() {
|
||||
if(configContainer != null) {
|
||||
configContainer.clearAllChildren();
|
||||
}
|
||||
}
|
||||
|
||||
public static void addConfigElement(UIElement element) {
|
||||
if(configContainer == null) {
|
||||
throw new IllegalStateException("Config container has not been bound.");
|
||||
}
|
||||
configContainer.addChild(element);
|
||||
}
|
||||
|
||||
public static void loadIntConfig(String path, String text, int defaultValue, int minValue, int maxValue) {
|
||||
loadIntConfig(path, Component.literal(text), null, defaultValue, minValue, maxValue);
|
||||
}
|
||||
|
||||
public static void loadIntConfig(String path, Component text, int defaultValue, int minValue, int maxValue) {
|
||||
loadIntConfig(path, text, null, defaultValue, minValue, maxValue);
|
||||
}
|
||||
|
||||
public static void loadIntConfig(String path, Component text, Component tooltip, int defaultValue, int minValue, int maxValue) {
|
||||
if(configContainer == null) {
|
||||
throw new IllegalStateException("Config container has not been bound.");
|
||||
}
|
||||
|
||||
int value = Math.clamp(ConfigUtil.readInt(path, defaultValue), minValue, maxValue);
|
||||
int resetValue = Math.clamp(defaultValue, minValue, maxValue);
|
||||
|
||||
UIElement container = new UIElement();
|
||||
container.addClass("config-scroller-container");
|
||||
|
||||
Label label = new Label();
|
||||
label.addClass("config-scroller-label");
|
||||
label.setText(text);
|
||||
applyLabelTooltip(label, tooltip);
|
||||
|
||||
Scroller.Horizontal scroller = new Scroller.Horizontal();
|
||||
scroller.addClass("config-scroller");
|
||||
disableScrollerWheel(scroller);
|
||||
scroller.setRange(minValue, maxValue);
|
||||
scroller.setValue((float)value, false);
|
||||
|
||||
TextField valueField = new TextField();
|
||||
valueField.addClass("config-scroller-textfield");
|
||||
valueField.setNumbersOnlyInt(minValue, maxValue);
|
||||
disableTextFieldWheel(valueField);
|
||||
valueField.setText(Integer.toString(value), false);
|
||||
|
||||
Button resetButton = new Button();
|
||||
resetButton.addClass("reset-button");
|
||||
resetButton.setText(Component.translatable(RESET_BUTTON_TRANSLATION_KEY));
|
||||
|
||||
scroller.setOnValueChanged(floatValue -> setIntConfigValue(path, scroller, valueField, Math.round(floatValue), minValue, maxValue));
|
||||
valueField.setTextResponder(textValue -> setIntConfigValue(path, scroller, valueField, parseInt(textValue, defaultValue), minValue, maxValue));
|
||||
resetButton.setOnClick(event -> setIntConfigValue(path, scroller, valueField, resetValue, minValue, maxValue));
|
||||
|
||||
container.addChildren(label, scroller, valueField, resetButton);
|
||||
configContainer.addChild(container);
|
||||
configContainer.addChild(new UIElement().addClass("config-divider"));
|
||||
}
|
||||
|
||||
public static void loadFloatConfig(String path, String text, float defaultValue, float minValue, float maxValue) {
|
||||
loadFloatConfig(path, Component.literal(text), null, defaultValue, minValue, maxValue);
|
||||
}
|
||||
|
||||
public static void loadFloatConfig(String path, Component text, float defaultValue, float minValue, float maxValue) {
|
||||
loadFloatConfig(path, text, null, defaultValue, minValue, maxValue);
|
||||
}
|
||||
|
||||
public static void loadFloatConfig(String path, Component text, Component tooltip, float defaultValue, float minValue, float maxValue) {
|
||||
if(configContainer == null) {
|
||||
throw new IllegalStateException("Config container has not been bound.");
|
||||
}
|
||||
|
||||
float value = Math.clamp(ConfigUtil.readFloat(path, defaultValue), minValue, maxValue);
|
||||
float resetValue = Math.clamp(defaultValue, minValue, maxValue);
|
||||
|
||||
UIElement container = new UIElement();
|
||||
container.addClass("config-scroller-container");
|
||||
|
||||
Label label = new Label();
|
||||
label.addClass("config-scroller-label");
|
||||
label.setText(text);
|
||||
applyLabelTooltip(label, tooltip);
|
||||
|
||||
Scroller.Horizontal scroller = new Scroller.Horizontal();
|
||||
scroller.addClass("config-scroller");
|
||||
disableScrollerWheel(scroller);
|
||||
scroller.setRange(minValue, maxValue);
|
||||
scroller.setValue(value, false);
|
||||
|
||||
TextField valueField = new TextField();
|
||||
valueField.addClass("config-scroller-textfield");
|
||||
valueField.setNumbersOnlyFloat(minValue, maxValue);
|
||||
disableTextFieldWheel(valueField);
|
||||
valueField.setText(formatFloat(value), false);
|
||||
|
||||
Button resetButton = new Button();
|
||||
resetButton.addClass("reset-button");
|
||||
resetButton.setText(Component.translatable(RESET_BUTTON_TRANSLATION_KEY));
|
||||
|
||||
scroller.setOnValueChanged(floatValue -> setFloatConfigValue(path, scroller, valueField, floatValue, minValue, maxValue));
|
||||
valueField.setTextResponder(textValue -> setFloatConfigValue(path, scroller, valueField, parseFloat(textValue, defaultValue), minValue, maxValue));
|
||||
resetButton.setOnClick(event -> setFloatConfigValue(path, scroller, valueField, resetValue, minValue, maxValue));
|
||||
|
||||
container.addChildren(label, scroller, valueField, resetButton);
|
||||
configContainer.addChild(container);
|
||||
configContainer.addChild(new UIElement().addClass("config-divider"));
|
||||
}
|
||||
|
||||
public static void loadDoubleConfig(String path, String text, double defaultValue, double minValue, double maxValue) {
|
||||
loadDoubleConfig(path, Component.literal(text), null, defaultValue, minValue, maxValue);
|
||||
}
|
||||
|
||||
public static void loadDoubleConfig(String path, Component text, double defaultValue, double minValue, double maxValue) {
|
||||
loadDoubleConfig(path, text, null, defaultValue, minValue, maxValue);
|
||||
}
|
||||
|
||||
public static void loadDoubleConfig(String path, Component text, Component tooltip, double defaultValue, double minValue, double maxValue) {
|
||||
if(configContainer == null) {
|
||||
throw new IllegalStateException("Config container has not been bound.");
|
||||
}
|
||||
|
||||
double value = Math.clamp(ConfigUtil.readDouble(path, defaultValue), minValue, maxValue);
|
||||
double resetValue = Math.clamp(defaultValue, minValue, maxValue);
|
||||
|
||||
UIElement container = new UIElement();
|
||||
container.addClass("config-scroller-container");
|
||||
|
||||
Label label = new Label();
|
||||
label.addClass("config-scroller-label");
|
||||
label.setText(text);
|
||||
applyLabelTooltip(label, tooltip);
|
||||
|
||||
Scroller.Horizontal scroller = new Scroller.Horizontal();
|
||||
scroller.addClass("config-scroller");
|
||||
disableScrollerWheel(scroller);
|
||||
scroller.setRange((float)minValue, (float)maxValue);
|
||||
scroller.setValue((float)value, false);
|
||||
|
||||
TextField valueField = new TextField();
|
||||
valueField.addClass("config-scroller-textfield");
|
||||
valueField.setNumbersOnlyDouble(minValue, maxValue);
|
||||
disableTextFieldWheel(valueField);
|
||||
valueField.setText(formatDouble(value), false);
|
||||
|
||||
Button resetButton = new Button();
|
||||
resetButton.addClass("reset-button");
|
||||
resetButton.setText(Component.translatable(RESET_BUTTON_TRANSLATION_KEY));
|
||||
|
||||
scroller.setOnValueChanged(floatValue -> setDoubleConfigValue(path, scroller, valueField, floatValue, minValue, maxValue));
|
||||
valueField.setTextResponder(textValue -> setDoubleConfigValue(path, scroller, valueField, parseDouble(textValue, defaultValue), minValue, maxValue));
|
||||
resetButton.setOnClick(event -> setDoubleConfigValue(path, scroller, valueField, resetValue, minValue, maxValue));
|
||||
|
||||
container.addChildren(label, scroller, valueField, resetButton);
|
||||
configContainer.addChild(container);
|
||||
configContainer.addChild(new UIElement().addClass("config-divider"));
|
||||
}
|
||||
|
||||
public static void loadStringConfig(String path, String text, String defaultValue) {
|
||||
loadStringConfig(path, Component.literal(text), null, defaultValue);
|
||||
}
|
||||
|
||||
public static void loadStringConfig(String path, Component text, String defaultValue) {
|
||||
loadStringConfig(path, text, null, defaultValue);
|
||||
}
|
||||
|
||||
public static void loadStringConfig(String path, Component text, Component tooltip, String defaultValue) {
|
||||
if(configContainer == null) {
|
||||
throw new IllegalStateException("Config container has not been bound.");
|
||||
}
|
||||
|
||||
String value = ConfigUtil.readString(path, defaultValue);
|
||||
|
||||
UIElement container = new UIElement();
|
||||
container.addClass("config-textfield-container");
|
||||
|
||||
Label label = new Label();
|
||||
label.addClass("config-textfield-label");
|
||||
label.setText(text);
|
||||
applyLabelTooltip(label, tooltip);
|
||||
|
||||
TextField textField = new TextField();
|
||||
textField.addClass("config-textfield");
|
||||
textField.setText(value, false);
|
||||
|
||||
Button resetButton = new Button();
|
||||
resetButton.addClass("reset-button");
|
||||
resetButton.setText(Component.translatable(RESET_BUTTON_TRANSLATION_KEY));
|
||||
|
||||
textField.setTextResponder(textValue -> ConfigUtil.setString(path, textValue));
|
||||
resetButton.setOnClick(event -> setStringConfigValue(path, textField, defaultValue));
|
||||
|
||||
container.addChildren(label, textField, resetButton);
|
||||
configContainer.addChild(container);
|
||||
configContainer.addChild(new UIElement().addClass("config-divider"));
|
||||
}
|
||||
|
||||
public static void loadBooleanConfig(String path, String text, boolean defaultValue) {
|
||||
loadBooleanConfig(path, Component.literal(text), null, defaultValue);
|
||||
}
|
||||
|
||||
public static void loadBooleanConfig(String path, Component text, boolean defaultValue) {
|
||||
loadBooleanConfig(path, text, null, defaultValue);
|
||||
}
|
||||
|
||||
public static void loadBooleanConfig(String path, Component text, Component tooltip, boolean defaultValue) {
|
||||
if(configContainer == null) {
|
||||
throw new IllegalStateException("Config container has not been bound.");
|
||||
}
|
||||
|
||||
boolean value = ConfigUtil.readBoolean(path, defaultValue);
|
||||
|
||||
UIElement container = new UIElement();
|
||||
container.addClass("config-switch-container");
|
||||
|
||||
Label label = new Label();
|
||||
label.addClass("config-switch-label");
|
||||
label.setText(text);
|
||||
applyLabelTooltip(label, tooltip);
|
||||
|
||||
Switch configSwitch = new Switch();
|
||||
configSwitch.addClass("config-switch");
|
||||
configSwitch.setOn(value, false);
|
||||
|
||||
Button resetButton = new Button();
|
||||
resetButton.addClass("reset-button");
|
||||
resetButton.setText(Component.translatable(RESET_BUTTON_TRANSLATION_KEY));
|
||||
|
||||
configSwitch.setOnSwitchChanged(switchValue -> ConfigUtil.setBoolean(path, switchValue));
|
||||
resetButton.setOnClick(event -> setBooleanConfigValue(path, configSwitch, defaultValue));
|
||||
|
||||
container.addChildren(label, configSwitch, resetButton);
|
||||
configContainer.addChild(container);
|
||||
configContainer.addChild(new UIElement().addClass("config-divider"));
|
||||
}
|
||||
|
||||
private static void setIntConfigValue(String path, Scroller scroller, TextField valueField, int value, int minValue, int maxValue) {
|
||||
int intValue = Math.clamp(value, minValue, maxValue);
|
||||
if(scroller.getValue() != intValue) {
|
||||
scroller.setValue((float)intValue, false);
|
||||
}
|
||||
valueField.setText(Integer.toString(intValue), false);
|
||||
ConfigUtil.setInt(path, intValue);
|
||||
}
|
||||
|
||||
private static void setFloatConfigValue(String path, Scroller scroller, TextField valueField, float value, float minValue, float maxValue) {
|
||||
float floatValue = Math.clamp(value, minValue, maxValue);
|
||||
if(scroller.getValue() != floatValue) {
|
||||
scroller.setValue(floatValue, false);
|
||||
}
|
||||
valueField.setText(formatFloat(floatValue), false);
|
||||
ConfigUtil.setFloat(path, floatValue);
|
||||
}
|
||||
|
||||
private static void setDoubleConfigValue(String path, Scroller scroller, TextField valueField, double value, double minValue, double maxValue) {
|
||||
double doubleValue = Math.clamp(value, minValue, maxValue);
|
||||
if(scroller.getValue() != (float)doubleValue) {
|
||||
scroller.setValue((float)doubleValue, false);
|
||||
}
|
||||
valueField.setText(formatDouble(doubleValue), false);
|
||||
ConfigUtil.setDouble(path, doubleValue);
|
||||
}
|
||||
|
||||
private static void setStringConfigValue(String path, TextField textField, String value) {
|
||||
textField.setText(value, false);
|
||||
ConfigUtil.setString(path, value);
|
||||
}
|
||||
|
||||
private static void setBooleanConfigValue(String path, Switch configSwitch, boolean value) {
|
||||
configSwitch.setOn(value, false);
|
||||
ConfigUtil.setBoolean(path, value);
|
||||
}
|
||||
|
||||
private static void disableScrollerWheel(Scroller scroller) {
|
||||
scroller.scrollerStyle(style -> style.scrollDelta(0));
|
||||
}
|
||||
|
||||
private static void disableTextFieldWheel(TextField textField) {
|
||||
textField.setWheelDur(0);
|
||||
}
|
||||
|
||||
private static void applyLabelTooltip(Label label, Component tooltip) {
|
||||
if(tooltip != null) {
|
||||
label.style(style -> style.tooltips(tooltip));
|
||||
}
|
||||
}
|
||||
|
||||
private static int parseInt(String value, int defaultValue) {
|
||||
try {
|
||||
return Integer.parseInt(value);
|
||||
} catch(NumberFormatException ignored) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
private static float parseFloat(String value, float defaultValue) {
|
||||
try {
|
||||
return Float.parseFloat(value);
|
||||
} catch(NumberFormatException ignored) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
private static double parseDouble(String value, double defaultValue) {
|
||||
try {
|
||||
return Double.parseDouble(value);
|
||||
} catch(NumberFormatException ignored) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
private static String formatFloat(float value) {
|
||||
return Float.toString(value);
|
||||
}
|
||||
|
||||
private static String formatDouble(double value) {
|
||||
return Double.toString(value);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package com.lzxnone.terraria.ui.config;
|
||||
|
||||
import com.lzxnone.terraria.effect.BloodButcheredEffect;
|
||||
import com.lzxnone.terraria.effect.DemonicFlamesEffect;
|
||||
import com.lzxnone.terraria.item.weapon.melee.BeeKeeper;
|
||||
import com.lzxnone.terraria.item.weapon.melee.BladeOfGrass;
|
||||
import com.lzxnone.terraria.item.weapon.melee.BloodButcherer;
|
||||
import com.lzxnone.terraria.item.weapon.melee.DevilsDevastation;
|
||||
import com.lzxnone.terraria.item.weapon.melee.EnchantedSword;
|
||||
import com.lzxnone.terraria.item.weapon.melee.Excalibur;
|
||||
import com.lzxnone.terraria.item.weapon.melee.FirstFractal;
|
||||
import com.lzxnone.terraria.item.weapon.melee.InfluxWaver;
|
||||
import com.lzxnone.terraria.item.weapon.melee.LightsBane;
|
||||
import com.lzxnone.terraria.item.weapon.melee.Mace;
|
||||
import com.lzxnone.terraria.item.weapon.melee.Meowmere;
|
||||
import com.lzxnone.terraria.item.weapon.melee.Muramasa;
|
||||
import com.lzxnone.terraria.item.weapon.melee.NightsEdge;
|
||||
import com.lzxnone.terraria.item.weapon.melee.Seedler;
|
||||
import com.lzxnone.terraria.item.weapon.melee.StarWrath;
|
||||
import com.lzxnone.terraria.item.weapon.melee.Starfury;
|
||||
import com.lzxnone.terraria.item.weapon.melee.TerraBlade;
|
||||
import com.lzxnone.terraria.item.weapon.melee.Terragrim;
|
||||
import com.lzxnone.terraria.item.weapon.melee.TheHorsemansBlade;
|
||||
import com.lzxnone.terraria.item.weapon.melee.TrueExcalibur;
|
||||
import com.lzxnone.terraria.item.weapon.melee.TrueNightsEdge;
|
||||
import com.lzxnone.terraria.item.weapon.melee.Volcano;
|
||||
import com.lzxnone.terraria.item.weapon.melee.Zenith;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class ConfigList {
|
||||
public static final String WEAPON = "weapon";
|
||||
public static final String EFFECT = "effect";
|
||||
|
||||
private static final Map<String, ConfigListItem[]> ITEMS = new HashMap<>();
|
||||
|
||||
static {
|
||||
ITEMS.put(WEAPON, new ConfigListItem[]{
|
||||
EnchantedSword.CONFIG_LIST_ITEM,
|
||||
BeeKeeper.CONFIG_LIST_ITEM,
|
||||
Starfury.CONFIG_LIST_ITEM,
|
||||
Seedler.CONFIG_LIST_ITEM,
|
||||
TheHorsemansBlade.CONFIG_LIST_ITEM,
|
||||
InfluxWaver.CONFIG_LIST_ITEM,
|
||||
StarWrath.CONFIG_LIST_ITEM,
|
||||
Meowmere.CONFIG_LIST_ITEM,
|
||||
TerraBlade.CONFIG_LIST_ITEM,
|
||||
Zenith.CONFIG_LIST_ITEM,
|
||||
Excalibur.CONFIG_LIST_ITEM,
|
||||
NightsEdge.CONFIG_LIST_ITEM,
|
||||
TrueExcalibur.CONFIG_LIST_ITEM,
|
||||
TrueNightsEdge.CONFIG_LIST_ITEM,
|
||||
LightsBane.CONFIG_LIST_ITEM,
|
||||
BloodButcherer.CONFIG_LIST_ITEM,
|
||||
Muramasa.CONFIG_LIST_ITEM,
|
||||
BladeOfGrass.CONFIG_LIST_ITEM,
|
||||
Volcano.CONFIG_LIST_ITEM,
|
||||
Terragrim.CONFIG_LIST_ITEM,
|
||||
FirstFractal.CONFIG_LIST_ITEM,
|
||||
Mace.CONFIG_LIST_ITEM,
|
||||
DevilsDevastation.CONFIG_LIST_ITEM
|
||||
});
|
||||
ITEMS.put(EFFECT, new ConfigListItem[]{
|
||||
BloodButcheredEffect.CONFIG_LIST_ITEM,
|
||||
DemonicFlamesEffect.CONFIG_LIST_ITEM
|
||||
});
|
||||
}
|
||||
|
||||
public static ConfigListItem[] getItems(String id) {
|
||||
return ITEMS.getOrDefault(id, ITEMS.get(WEAPON));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.lzxnone.terraria.ui.config;
|
||||
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
public class ConfigListItem {
|
||||
String id;
|
||||
ResourceLocation icon;
|
||||
Component name;
|
||||
IConfigData data;
|
||||
|
||||
public ConfigListItem(String id, ResourceLocation icon, Component name, IConfigData data) {
|
||||
this.id = id;
|
||||
this.icon = icon;
|
||||
this.name = name;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public void onConfigLoad() {
|
||||
data.onConfigLoad();
|
||||
}
|
||||
|
||||
public void onConfigSave() {
|
||||
data.onConfigSave();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,161 @@
|
||||
package com.lzxnone.terraria.ui.config;
|
||||
|
||||
import com.lowdragmc.lowdraglib2.gui.holder.ModularUIScreen;
|
||||
import com.lowdragmc.lowdraglib2.gui.ui.ModularUI;
|
||||
import com.lowdragmc.lowdraglib2.gui.ui.UI;
|
||||
import com.lowdragmc.lowdraglib2.gui.ui.UIElement;
|
||||
import com.lowdragmc.lowdraglib2.gui.texture.SpriteTexture;
|
||||
import com.lowdragmc.lowdraglib2.gui.ui.elements.Button;
|
||||
import com.lowdragmc.lowdraglib2.gui.ui.elements.Label;
|
||||
import com.lowdragmc.lowdraglib2.utils.XmlUtils;
|
||||
import com.lzxnone.terraria.LzxnoneTerraria;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import org.w3c.dom.Document;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class ConfigScreen {
|
||||
private static final ResourceLocation UI_PATH = ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "ui/config.xml");
|
||||
private static final String[] NAV_KEYS = {"weapon", "effect"};
|
||||
private static String selectedNavKey = ConfigList.WEAPON;
|
||||
private static final Map<String, Integer> NAV_SELECTED_INDEXES = new HashMap<>();
|
||||
|
||||
public static Screen create(Screen parent) {
|
||||
UI ui = loadUI();
|
||||
|
||||
//返回回调
|
||||
findElement(ui, "back-button", Button.class).setOnClick(event -> saveAndReturn(parent));
|
||||
|
||||
//为头部导航按钮设置回调
|
||||
findElement(ui, "nav-button-weapon", Button.class).setOnClick(event -> onNavSelected(ui, ConfigList.WEAPON));
|
||||
findElement(ui, "nav-button-effect", Button.class).setOnClick(event -> onNavSelected(ui, ConfigList.EFFECT));
|
||||
|
||||
//底部回调
|
||||
findElement(ui, "button-cancel", Button.class).setOnClick(event -> discardAndReturn(parent));
|
||||
findElement(ui, "button-confirm", Button.class).setOnClick(event -> saveAndReturn(parent));
|
||||
|
||||
ConfigFactory.bindConfigContainer(findElement(ui, "config-container", UIElement.class));
|
||||
|
||||
onNavSelected(ui, getCachedNavKey());
|
||||
|
||||
ModularUI modularUI = ModularUI.of(UI.of(ui.rootElement, ui.stylesheets, screenSize -> screenSize));
|
||||
modularUI.shouldCloseOnEsc(true);
|
||||
return new ModularUIScreen(modularUI, Component.translatable("lzxnoneterraria.configuration.title")) {
|
||||
@Override
|
||||
public boolean isPauseScreen() {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
//UI文件加载
|
||||
private static UI loadUI() {
|
||||
Document document = XmlUtils.loadXml(UI_PATH);
|
||||
if(document == null) {
|
||||
LzxnoneTerraria.LOGGER.error("Failed to load LDLib2 UI template {}", UI_PATH);
|
||||
return UI.of(new UIElement());
|
||||
}
|
||||
return UI.of(document);
|
||||
}
|
||||
|
||||
//头部导航按钮回调
|
||||
private static void onNavSelected(UI ui, String key) {
|
||||
selectedNavKey = getValidNavKey(key);
|
||||
for(String navKey : NAV_KEYS) {
|
||||
findElement(ui, "nav-item-" + navKey, UIElement.class).removeClass("nav-item--selected");
|
||||
}
|
||||
findElement(ui, "nav-item-" + selectedNavKey, UIElement.class).addClass("nav-item--selected");
|
||||
ConfigFactory.clearConfigContainer();
|
||||
|
||||
ConfigListItem[] items = ConfigList.getItems(selectedNavKey);
|
||||
UIElement toggleContainer = findElement(ui, "toggle-container", UIElement.class);
|
||||
toggleContainer.clearAllChildren();
|
||||
|
||||
for(int index = 0; index < items.length; index++) {
|
||||
ConfigListItem item = items[index];
|
||||
int itemIndex = index;
|
||||
Button toggleItem = new Button();
|
||||
toggleItem.setId(getToggleItemId(selectedNavKey, itemIndex));
|
||||
toggleItem.addClass("toggle-item");
|
||||
toggleItem.noText();
|
||||
toggleItem.setOnClick(event -> loadConfigItem(ui, selectedNavKey, itemIndex, item));
|
||||
|
||||
UIElement itemIcon = new UIElement();
|
||||
itemIcon.addClass("toggle-item-img");
|
||||
itemIcon.style(style -> style.backgroundTexture(SpriteTexture.of(item.icon)));
|
||||
|
||||
Label itemLabel = new Label();
|
||||
itemLabel.addClass("toggle-item-label");
|
||||
itemLabel.setText(item.name);
|
||||
|
||||
toggleItem.addChildren(itemIcon, itemLabel);
|
||||
toggleContainer.addChild(toggleItem);
|
||||
}
|
||||
|
||||
if(items.length > 0) {
|
||||
int selectedIndex = Math.clamp(NAV_SELECTED_INDEXES.getOrDefault(selectedNavKey, 0), 0, items.length - 1);
|
||||
loadConfigItem(ui, selectedNavKey, selectedIndex, items[selectedIndex]);
|
||||
}
|
||||
}
|
||||
|
||||
private static String getCachedNavKey() {
|
||||
return getValidNavKey(selectedNavKey);
|
||||
}
|
||||
|
||||
private static String getValidNavKey(String key) {
|
||||
for(String navKey : NAV_KEYS) {
|
||||
if(navKey.equals(key)) {
|
||||
return key;
|
||||
}
|
||||
}
|
||||
return NAV_KEYS[0];
|
||||
}
|
||||
|
||||
private static void loadConfigItem(UI ui, String navKey, int index, ConfigListItem item) {
|
||||
NAV_SELECTED_INDEXES.put(navKey, index);
|
||||
updateToggleSelected(ui, navKey, index);
|
||||
ConfigFactory.clearConfigContainer();
|
||||
ConfigFactory.addConfigElement(createConfigTitle(item.name));
|
||||
item.onConfigLoad();
|
||||
}
|
||||
|
||||
private static Label createConfigTitle(Component name) {
|
||||
Label title = new Label();
|
||||
title.addClass("config-title");
|
||||
title.setText(name);
|
||||
return title;
|
||||
}
|
||||
|
||||
private static void updateToggleSelected(UI ui, String navKey, int selectedIndex) {
|
||||
UIElement toggleContainer = findElement(ui, "toggle-container", UIElement.class);
|
||||
for(UIElement child : toggleContainer.getChildren()) {
|
||||
child.removeClass("toggle-item--selected");
|
||||
}
|
||||
ui.selectId(getToggleItemId(navKey, selectedIndex), UIElement.class)
|
||||
.findFirst()
|
||||
.ifPresent(element -> element.addClass("toggle-item--selected"));
|
||||
}
|
||||
|
||||
private static String getToggleItemId(String navKey, int index) {
|
||||
return "toggle-item-" + navKey + "-" + index;
|
||||
}
|
||||
|
||||
private static void saveAndReturn(Screen parent) {
|
||||
ConfigUtil.save();
|
||||
Minecraft.getInstance().setScreen(parent);
|
||||
}
|
||||
|
||||
private static void discardAndReturn(Screen parent) {
|
||||
ConfigUtil.reload();
|
||||
Minecraft.getInstance().setScreen(parent);
|
||||
}
|
||||
|
||||
private static <T extends UIElement> T findElement(UI ui, String id, Class<T> type) {
|
||||
return ui.selectId(id, type).findFirst().orElseThrow(() ->
|
||||
new IllegalStateException("Missing " + type.getSimpleName() + " with id '" + id + "' in " + UI_PATH));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,192 @@
|
||||
package com.lzxnone.terraria.ui.config;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.google.gson.JsonPrimitive;
|
||||
import com.lzxnone.terraria.LzxnoneTerraria;
|
||||
import net.neoforged.fml.loading.FMLPaths;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.io.Writer;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.function.Function;
|
||||
|
||||
public final class ConfigUtil {
|
||||
private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create();
|
||||
private static final Path CONFIG_PATH = FMLPaths.CONFIGDIR.get().resolve(LzxnoneTerraria.MODID + "-config.json");
|
||||
private static JsonObject configCache;
|
||||
private static boolean loaded;
|
||||
private static boolean dirty;
|
||||
|
||||
private ConfigUtil() {
|
||||
}
|
||||
|
||||
public static Path getConfigPath() {
|
||||
return CONFIG_PATH;
|
||||
}
|
||||
|
||||
public static <T> T read(String path, T defaultValue, Function<JsonElement, T> parser) {
|
||||
ensureLoaded();
|
||||
JsonElement element = findElement(configCache, path);
|
||||
if(element == null || element.isJsonNull()) {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
try {
|
||||
T value = parser.apply(element);
|
||||
return value == null ? defaultValue : value;
|
||||
} catch(RuntimeException exception) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
public static int readInt(String path, int defaultValue) {
|
||||
return read(path, defaultValue, JsonElement::getAsInt);
|
||||
}
|
||||
|
||||
public static float readFloat(String path, float defaultValue) {
|
||||
return read(path, defaultValue, JsonElement::getAsFloat);
|
||||
}
|
||||
|
||||
public static double readDouble(String path, double defaultValue) {
|
||||
return read(path, defaultValue, JsonElement::getAsDouble);
|
||||
}
|
||||
|
||||
public static boolean readBoolean(String path, boolean defaultValue) {
|
||||
return read(path, defaultValue, JsonElement::getAsBoolean);
|
||||
}
|
||||
|
||||
public static String readString(String path, String defaultValue) {
|
||||
return read(path, defaultValue, JsonElement::getAsString);
|
||||
}
|
||||
|
||||
public static void setInt(String path, int value) {
|
||||
set(path, new JsonPrimitive(value));
|
||||
}
|
||||
|
||||
public static void setFloat(String path, float value) {
|
||||
set(path, new JsonPrimitive(value));
|
||||
}
|
||||
|
||||
public static void setDouble(String path, double value) {
|
||||
set(path, new JsonPrimitive(value));
|
||||
}
|
||||
|
||||
public static void setBoolean(String path, boolean value) {
|
||||
set(path, new JsonPrimitive(value));
|
||||
}
|
||||
|
||||
public static void setString(String path, String value) {
|
||||
set(path, new JsonPrimitive(value));
|
||||
}
|
||||
|
||||
public static void save() {
|
||||
save(false);
|
||||
}
|
||||
|
||||
public static void save(boolean force) {
|
||||
ensureLoaded();
|
||||
if(!dirty && !force) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
Files.createDirectories(CONFIG_PATH.getParent());
|
||||
try(Writer writer = Files.newBufferedWriter(CONFIG_PATH)) {
|
||||
GSON.toJson(configCache, writer);
|
||||
}
|
||||
dirty = false;
|
||||
} catch(IOException exception) {
|
||||
LzxnoneTerraria.LOGGER.warn("Failed to save config to {}", CONFIG_PATH, exception);
|
||||
}
|
||||
}
|
||||
|
||||
public static void reload() {
|
||||
configCache = null;
|
||||
loaded = false;
|
||||
dirty = false;
|
||||
ensureLoaded();
|
||||
}
|
||||
|
||||
private static void ensureLoaded() {
|
||||
if(loaded) {
|
||||
return;
|
||||
}
|
||||
configCache = loadRoot();
|
||||
loaded = true;
|
||||
}
|
||||
|
||||
private static JsonObject loadRoot() {
|
||||
if(!Files.exists(CONFIG_PATH)) {
|
||||
return new JsonObject();
|
||||
}
|
||||
|
||||
try(Reader reader = Files.newBufferedReader(CONFIG_PATH)) {
|
||||
JsonElement element = JsonParser.parseReader(reader);
|
||||
return element != null && element.isJsonObject() ? element.getAsJsonObject() : new JsonObject();
|
||||
} catch(IOException | RuntimeException exception) {
|
||||
LzxnoneTerraria.LOGGER.warn("Failed to load config from {}", CONFIG_PATH, exception);
|
||||
return new JsonObject();
|
||||
}
|
||||
}
|
||||
|
||||
private static void set(String path, JsonElement value) {
|
||||
ensureLoaded();
|
||||
|
||||
String[] parts = splitPath(path);
|
||||
if(parts.length == 0) {
|
||||
LzxnoneTerraria.LOGGER.warn("Ignored config write with invalid path '{}'", path);
|
||||
return;
|
||||
}
|
||||
|
||||
JsonObject current = configCache;
|
||||
for(int i = 0; i < parts.length - 1; i++) {
|
||||
JsonElement child = current.get(parts[i]);
|
||||
if(child == null || !child.isJsonObject()) {
|
||||
JsonObject childObject = new JsonObject();
|
||||
current.add(parts[i], childObject);
|
||||
current = childObject;
|
||||
} else {
|
||||
current = child.getAsJsonObject();
|
||||
}
|
||||
}
|
||||
|
||||
current.add(parts[parts.length - 1], value);
|
||||
dirty = true;
|
||||
}
|
||||
|
||||
private static JsonElement findElement(JsonObject root, String path) {
|
||||
String[] parts = splitPath(path);
|
||||
if(parts.length == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
JsonElement current = root;
|
||||
for(String part : parts) {
|
||||
if(current == null || !current.isJsonObject()) {
|
||||
return null;
|
||||
}
|
||||
current = current.getAsJsonObject().get(part);
|
||||
}
|
||||
return current;
|
||||
}
|
||||
|
||||
private static String[] splitPath(String path) {
|
||||
if(path == null || path.isBlank()) {
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
String[] parts = path.split("\\.");
|
||||
for(String part : parts) {
|
||||
if(part.isBlank()) {
|
||||
return new String[0];
|
||||
}
|
||||
}
|
||||
return parts;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.lzxnone.terraria.ui.config;
|
||||
|
||||
public interface IConfigData {
|
||||
default void onConfigLoad() {}
|
||||
default void onConfigSave() {}
|
||||
}
|
||||
Reference in new issue
Block a user