v1.6.1
This commit is contained in:
1 parent
5758839e77
commit
fa21552d8d
208 files changed
+4554
-3238
No files matched your search
@@ -27,6 +27,10 @@ sourceSets.main.resources {
|
|||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
|
maven {
|
||||||
|
name = "Illusive Soulworks"
|
||||||
|
url = "https://maven.theillusivec4.top/"
|
||||||
|
}
|
||||||
maven {
|
maven {
|
||||||
name = "Gegy"
|
name = "Gegy"
|
||||||
url = "https://maven.gegy.dev"
|
url = "https://maven.gegy.dev"
|
||||||
@@ -131,6 +135,8 @@ dependencies {
|
|||||||
jarJar('net.objecthunter:exp4j:0.4.8')
|
jarJar('net.objecthunter:exp4j:0.4.8')
|
||||||
additionalRuntimeClasspath 'net.objecthunter:exp4j:0.4.8'
|
additionalRuntimeClasspath 'net.objecthunter:exp4j:0.4.8'
|
||||||
implementation("com.lowdragmc.ldlib2:ldlib2-neoforge-${minecraft_version}:${ldlib2_version}:all")
|
implementation("com.lowdragmc.ldlib2:ldlib2-neoforge-${minecraft_version}:${ldlib2_version}:all")
|
||||||
|
compileOnly("top.theillusivec4.curios:curios-neoforge:${curios_version}:api")
|
||||||
|
localRuntime("top.theillusivec4.curios:curios-neoforge:${curios_version}")
|
||||||
attributesSchema {
|
attributesSchema {
|
||||||
attribute(mappingsAttribute)
|
attribute(mappingsAttribute)
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-1
@@ -34,7 +34,7 @@ mod_name=Lzxnone Terraria
|
|||||||
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
|
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
|
||||||
mod_license=All Rights Reserved
|
mod_license=All Rights Reserved
|
||||||
# The mod version. See https://semver.org/
|
# The mod version. See https://semver.org/
|
||||||
mod_version=1.6.0
|
mod_version=1.6.1
|
||||||
## The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
|
## The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
|
||||||
# This should match the base package used for the mod sources.
|
# This should match the base package used for the mod sources.
|
||||||
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
|
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||||
@@ -42,3 +42,6 @@ mod_group_id=com.lzxnone.terraria
|
|||||||
|
|
||||||
# LDLib2
|
# LDLib2
|
||||||
ldlib2_version=2.2.29
|
ldlib2_version=2.2.29
|
||||||
|
|
||||||
|
# Curios
|
||||||
|
curios_version=9.5.1+1.21.1
|
||||||
@@ -43,6 +43,10 @@ public class ModSounds {
|
|||||||
SOUND_EVENTS.register("star_collide",
|
SOUND_EVENTS.register("star_collide",
|
||||||
() -> SoundEvent.createVariableRangeEvent(
|
() -> SoundEvent.createVariableRangeEvent(
|
||||||
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "star_collide")));
|
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "star_collide")));
|
||||||
|
public static final Supplier<SoundEvent> SNOW_BREAK =
|
||||||
|
SOUND_EVENTS.register("snow_break",
|
||||||
|
() -> SoundEvent.createVariableRangeEvent(
|
||||||
|
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "snow_break")));
|
||||||
public static final Supplier<SoundEvent> SUMMON_TERRAPRISMA =
|
public static final Supplier<SoundEvent> SUMMON_TERRAPRISMA =
|
||||||
SOUND_EVENTS.register("summon_terraprisma",
|
SOUND_EVENTS.register("summon_terraprisma",
|
||||||
() -> SoundEvent.createVariableRangeEvent(
|
() -> SoundEvent.createVariableRangeEvent(
|
||||||
@@ -79,6 +83,10 @@ public class ModSounds {
|
|||||||
SOUND_EVENTS.register("shot8",
|
SOUND_EVENTS.register("shot8",
|
||||||
() -> SoundEvent.createVariableRangeEvent(
|
() -> SoundEvent.createVariableRangeEvent(
|
||||||
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "shot8")));
|
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "shot8")));
|
||||||
|
public static final Supplier<SoundEvent> SHOT9 =
|
||||||
|
SOUND_EVENTS.register("shot9",
|
||||||
|
() -> SoundEvent.createVariableRangeEvent(
|
||||||
|
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "shot9")));
|
||||||
public static final Supplier<SoundEvent> BOOM =
|
public static final Supplier<SoundEvent> BOOM =
|
||||||
SOUND_EVENTS.register("boom",
|
SOUND_EVENTS.register("boom",
|
||||||
() -> SoundEvent.createVariableRangeEvent(
|
() -> SoundEvent.createVariableRangeEvent(
|
||||||
|
|||||||
@@ -30,4 +30,7 @@ public class ModAttachments {
|
|||||||
public static final Supplier<AttachmentType<Integer>> SUMMON_ATTACK_MODE =
|
public static final Supplier<AttachmentType<Integer>> SUMMON_ATTACK_MODE =
|
||||||
ATTACHMENT_TYPES.register("summon_attack_mode", () -> AttachmentType.builder(() -> 2).serialize(Codec.INT).build());
|
ATTACHMENT_TYPES.register("summon_attack_mode", () -> AttachmentType.builder(() -> 2).serialize(Codec.INT).build());
|
||||||
|
|
||||||
|
public static final Supplier<AttachmentType<PlayerMana>> PLAYER_MANA =
|
||||||
|
ATTACHMENT_TYPES.register("player_mana", () -> AttachmentType.builder(PlayerMana::new).serialize(PlayerMana.CODEC).copyOnDeath().build());
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,140 @@
|
|||||||
|
package com.lzxnone.terraria.attachment;
|
||||||
|
|
||||||
|
import com.mojang.serialization.Codec;
|
||||||
|
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||||
|
import net.minecraft.util.Mth;
|
||||||
|
|
||||||
|
public class PlayerMana {
|
||||||
|
public static final int DEFAULT_MAX_MANA = 20;
|
||||||
|
public static final double DEFAULT_RECOVER_RATE = 1.0D;
|
||||||
|
|
||||||
|
public static final Codec<PlayerMana> CODEC = RecordCodecBuilder.create(instance -> instance.group(
|
||||||
|
Codec.INT.optionalFieldOf("mana", DEFAULT_MAX_MANA).forGetter(PlayerMana::getMana),
|
||||||
|
Codec.INT.optionalFieldOf("max_mana", DEFAULT_MAX_MANA).forGetter(PlayerMana::getMaxMana),
|
||||||
|
Codec.DOUBLE.optionalFieldOf("consume_progress", 0.0D).forGetter(PlayerMana::getConsumeProgress),
|
||||||
|
Codec.DOUBLE.optionalFieldOf("recover_progress", 0.0D).forGetter(PlayerMana::getRecoverProgress),
|
||||||
|
Codec.INT.optionalFieldOf("recover_delay", 0).forGetter(PlayerMana::getRecoverDelay)
|
||||||
|
).apply(instance, PlayerMana::new));
|
||||||
|
|
||||||
|
private int mana;
|
||||||
|
private int maxMana;
|
||||||
|
private double consumeProgress;
|
||||||
|
private double recoverProgress;
|
||||||
|
private int recoverDelay;
|
||||||
|
|
||||||
|
public PlayerMana() {
|
||||||
|
this(DEFAULT_MAX_MANA, DEFAULT_MAX_MANA, 0.0D, 0.0D, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PlayerMana(int mana, int maxMana) {
|
||||||
|
this(mana, maxMana, 0.0D, 0.0D, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PlayerMana(int mana, int maxMana, double consumeProgress, double recoverProgress) {
|
||||||
|
this(mana, maxMana, consumeProgress, recoverProgress, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PlayerMana(int mana, int maxMana, double consumeProgress, double recoverProgress, int recoverDelay) {
|
||||||
|
this.maxMana = Math.max(0, maxMana);
|
||||||
|
this.mana = Mth.clamp(mana, 0, this.maxMana);
|
||||||
|
this.consumeProgress = Math.max(0.0D, consumeProgress);
|
||||||
|
this.recoverProgress = Math.max(0.0D, recoverProgress);
|
||||||
|
this.recoverDelay = Math.max(0, recoverDelay);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMana() {
|
||||||
|
return mana;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMana(int mana) {
|
||||||
|
this.mana = Mth.clamp(mana, 0, maxMana);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMaxMana() {
|
||||||
|
return maxMana;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMaxMana(int maxMana) {
|
||||||
|
this.maxMana = Math.max(0, maxMana);
|
||||||
|
this.mana = Math.min(mana, this.maxMana);
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getConsumeProgress() {
|
||||||
|
return consumeProgress;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getRecoverProgress() {
|
||||||
|
return recoverProgress;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getRecoverDelay() {
|
||||||
|
return recoverDelay;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasMana() {
|
||||||
|
return mana > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean recoverMana(double amount) {
|
||||||
|
if(amount <= 0.0D || mana >= maxMana) return false;
|
||||||
|
|
||||||
|
int recoverAmount = addManaProgress(false, amount);
|
||||||
|
if(recoverAmount <= 0) return true;
|
||||||
|
|
||||||
|
int oldMana = mana;
|
||||||
|
setMana(mana + recoverAmount);
|
||||||
|
return mana != oldMana;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean recoverManaImmediately(int amount) {
|
||||||
|
if(amount <= 0 || mana >= maxMana) return false;
|
||||||
|
|
||||||
|
int oldMana = mana;
|
||||||
|
setMana(mana + amount);
|
||||||
|
return mana != oldMana;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean consumeMana(double amount) {
|
||||||
|
if(amount <= 0.0D) return true;
|
||||||
|
if(mana <= 0) return false;
|
||||||
|
|
||||||
|
int consumeAmount = addManaProgress(true, amount);
|
||||||
|
if(consumeAmount <= 0) return mana > 0;
|
||||||
|
|
||||||
|
if(consumeAmount >= mana) {
|
||||||
|
mana = 0;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
mana -= consumeAmount;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void applyRecoverDelay() {
|
||||||
|
if(maxMana <= 0) return;
|
||||||
|
|
||||||
|
double emptyRatio = 1.0D - (double) mana / maxMana;
|
||||||
|
recoverDelay = Math.max(recoverDelay, (int) Math.ceil(0.7D * (emptyRatio * 240.0D + 45.0D)));
|
||||||
|
recoverProgress = 0.0D;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean tickRecoverDelay() {
|
||||||
|
if(recoverDelay <= 0) return false;
|
||||||
|
|
||||||
|
recoverDelay--;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int addManaProgress(boolean consume, double amount) {
|
||||||
|
double progress = (consume ? consumeProgress : recoverProgress) + amount;
|
||||||
|
int wholeAmount = (int)Math.floor(progress);
|
||||||
|
double nextProgress = progress - wholeAmount;
|
||||||
|
|
||||||
|
if(consume) {
|
||||||
|
consumeProgress = nextProgress;
|
||||||
|
}else {
|
||||||
|
recoverProgress = nextProgress;
|
||||||
|
}
|
||||||
|
return wholeAmount;
|
||||||
|
}
|
||||||
|
}
|
||||||
+4
-2
@@ -1,11 +1,12 @@
|
|||||||
package com.lzxnone.terraria.client.entity.projectile;
|
package com.lzxnone.terraria.client.entity.projectile;
|
||||||
|
|
||||||
import com.lzxnone.terraria.client.item.ammo.ClientCrystalFragment;
|
|
||||||
import com.lzxnone.terraria.client.item.melee.ClientBladeOfGrass;
|
import com.lzxnone.terraria.client.item.melee.ClientBladeOfGrass;
|
||||||
import com.lzxnone.terraria.client.item.melee.ClientDevilsDevastation;
|
import com.lzxnone.terraria.client.item.melee.ClientDevilsDevastation;
|
||||||
import com.lzxnone.terraria.client.item.melee.ClientMace;
|
import com.lzxnone.terraria.client.item.melee.ClientMace;
|
||||||
import com.lzxnone.terraria.client.item.melee.ClientMuramasa;
|
import com.lzxnone.terraria.client.item.melee.ClientMuramasa;
|
||||||
import com.lzxnone.terraria.client.item.melee.ClientZenith;
|
import com.lzxnone.terraria.client.item.melee.ClientZenith;
|
||||||
|
import com.lzxnone.terraria.client.item.ranged.ClientFlamethrower;
|
||||||
|
import com.lzxnone.terraria.client.item.ranged.ClientSuperStarShooter;
|
||||||
import com.lzxnone.terraria.entity.projectile.StaticProjectileBehaviors;
|
import com.lzxnone.terraria.entity.projectile.StaticProjectileBehaviors;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -28,7 +29,8 @@ public class ClientStaticProjectileRenderBehaviors {
|
|||||||
BEHAVIORS.put(StaticProjectileBehaviors.DEVILS_DEVASTATION_PROJECTILE, ClientDevilsDevastation.PROJECTILE_BEHAVIOR);
|
BEHAVIORS.put(StaticProjectileBehaviors.DEVILS_DEVASTATION_PROJECTILE, ClientDevilsDevastation.PROJECTILE_BEHAVIOR);
|
||||||
BEHAVIORS.put(StaticProjectileBehaviors.DEVILS_DEVASTATION_PROJECTILE2, ClientDevilsDevastation.PROJECTILE_BEHAVIOR2);
|
BEHAVIORS.put(StaticProjectileBehaviors.DEVILS_DEVASTATION_PROJECTILE2, ClientDevilsDevastation.PROJECTILE_BEHAVIOR2);
|
||||||
BEHAVIORS.put(StaticProjectileBehaviors.DEVILS_DEVASTATION_PROJECTILE3, ClientDevilsDevastation.PROJECTILE_BEHAVIOR3);
|
BEHAVIORS.put(StaticProjectileBehaviors.DEVILS_DEVASTATION_PROJECTILE3, ClientDevilsDevastation.PROJECTILE_BEHAVIOR3);
|
||||||
BEHAVIORS.put(StaticProjectileBehaviors.CRYSTAL_FRAGMENT, ClientCrystalFragment.PROJECTILE_BEHAVIOR);
|
BEHAVIORS.put(StaticProjectileBehaviors.CRYSTAL_FRAGMENT, DEFAULT_BEHAVIOR);
|
||||||
|
BEHAVIORS.put(StaticProjectileBehaviors.SUPER_STAR_PRISMATIC_BOLT, ClientSuperStarShooter.PROJECTILE_BEHAVIOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IStaticProjectileRenderBehavior getBehavior(String id) {
|
public static IStaticProjectileRenderBehavior getBehavior(String id) {
|
||||||
|
|||||||
+10
-2
@@ -1,7 +1,6 @@
|
|||||||
package com.lzxnone.terraria.client.entity.summon;
|
package com.lzxnone.terraria.client.entity.summon;
|
||||||
|
|
||||||
import com.lzxnone.terraria.client.item.ammo.ClientBulletAmmo;
|
import com.lzxnone.terraria.client.item.ranged.ClientBulletAmmo;
|
||||||
import com.lzxnone.terraria.client.item.ammo.ClientCrystalFragment;
|
|
||||||
import com.lzxnone.terraria.client.item.magic.ClientLastPrism;
|
import com.lzxnone.terraria.client.item.magic.ClientLastPrism;
|
||||||
import com.lzxnone.terraria.client.item.melee.ClientDevilsDevastation;
|
import com.lzxnone.terraria.client.item.melee.ClientDevilsDevastation;
|
||||||
import com.lzxnone.terraria.client.item.melee.ClientFirstFractal;
|
import com.lzxnone.terraria.client.item.melee.ClientFirstFractal;
|
||||||
@@ -12,6 +11,9 @@ import com.lzxnone.terraria.client.item.melee.ClientNightsEdge;
|
|||||||
import com.lzxnone.terraria.client.item.melee.ClientTerraBlade;
|
import com.lzxnone.terraria.client.item.melee.ClientTerraBlade;
|
||||||
import com.lzxnone.terraria.client.item.melee.ClientTerragrim;
|
import com.lzxnone.terraria.client.item.melee.ClientTerragrim;
|
||||||
import com.lzxnone.terraria.client.item.melee.ClientTrueNightsEdge;
|
import com.lzxnone.terraria.client.item.melee.ClientTrueNightsEdge;
|
||||||
|
import com.lzxnone.terraria.client.item.ranged.ClientFlamethrower;
|
||||||
|
import com.lzxnone.terraria.client.item.ranged.ClientStarCannon;
|
||||||
|
import com.lzxnone.terraria.client.item.ranged.ClientSuperStarShooter;
|
||||||
import com.lzxnone.terraria.client.item.summon.ClientTerraprisma;
|
import com.lzxnone.terraria.client.item.summon.ClientTerraprisma;
|
||||||
import com.lzxnone.terraria.entity.summon.StaticSummonBehaviors;
|
import com.lzxnone.terraria.entity.summon.StaticSummonBehaviors;
|
||||||
|
|
||||||
@@ -60,6 +62,12 @@ public class ClientStaticSummonRenderBehaviors {
|
|||||||
BEHAVIORS.put(StaticSummonBehaviors.GOLDEN_BULLET, ClientBulletAmmo.SUMMON_BEHAVIOR);
|
BEHAVIORS.put(StaticSummonBehaviors.GOLDEN_BULLET, ClientBulletAmmo.SUMMON_BEHAVIOR);
|
||||||
BEHAVIORS.put(StaticSummonBehaviors.LUMINITE_BULLET, ClientBulletAmmo.SUMMON_BEHAVIOR);
|
BEHAVIORS.put(StaticSummonBehaviors.LUMINITE_BULLET, ClientBulletAmmo.SUMMON_BEHAVIOR);
|
||||||
BEHAVIORS.put(StaticSummonBehaviors.TUNGSTEN_BULLET, ClientBulletAmmo.SUMMON_BEHAVIOR);
|
BEHAVIORS.put(StaticSummonBehaviors.TUNGSTEN_BULLET, ClientBulletAmmo.SUMMON_BEHAVIOR);
|
||||||
|
|
||||||
|
BEHAVIORS.put(StaticSummonBehaviors.SNOWBALL, DEFAULT_BEHAVIOR);
|
||||||
|
BEHAVIORS.put(StaticSummonBehaviors.FALLEN_STAR, ClientStarCannon.SUMMON_BEHAVIOR);
|
||||||
|
BEHAVIORS.put(StaticSummonBehaviors.FALLEN_STAR_SUPER, ClientSuperStarShooter.SUMMON_BEHAVIOR);
|
||||||
|
BEHAVIORS.put(StaticSummonBehaviors.FLAMETHROWER_FLAME, ClientFlamethrower.SUMMON_BEHAVIOR);
|
||||||
|
BEHAVIORS.put(StaticSummonBehaviors.ELF_MELTER_FLAME, ClientFlamethrower.SUMMON_BEHAVIOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IStaticSummonRenderBehavior getBehavior(String id) {
|
public static IStaticSummonRenderBehavior getBehavior(String id) {
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ public class GuiRenderHandler {
|
|||||||
LocalPlayer player = minecraft.player;
|
LocalPlayer player = minecraft.player;
|
||||||
if(player == null || minecraft.options.hideGui) return;
|
if(player == null || minecraft.options.hideGui) return;
|
||||||
|
|
||||||
|
ManaHudRenderer.render(event.getGuiGraphics(), player);
|
||||||
|
|
||||||
ItemStack stack = player.getMainHandItem();
|
ItemStack stack = player.getMainHandItem();
|
||||||
if(stack.is(ModItems.DEVILS_DEVASTATION.get()) && player.getEffect(ModEffects.KILL_MODE) != null) {
|
if(stack.is(ModItems.DEVILS_DEVASTATION.get()) && player.getEffect(ModEffects.KILL_MODE) != null) {
|
||||||
Component text = Component.translatable("tooltip.lzxnoneterraria.devils_devastation_kill_mode");
|
Component text = Component.translatable("tooltip.lzxnoneterraria.devils_devastation_kill_mode");
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import com.lzxnone.terraria.item.weapon.melee.DevilsDevastation;
|
|||||||
import com.lzxnone.terraria.item.weapon.melee.FirstFractal;
|
import com.lzxnone.terraria.item.weapon.melee.FirstFractal;
|
||||||
import com.lzxnone.terraria.item.weapon.melee.TrueCopperShortsword;
|
import com.lzxnone.terraria.item.weapon.melee.TrueCopperShortsword;
|
||||||
import com.lzxnone.terraria.item.weapon.melee.Zenith;
|
import com.lzxnone.terraria.item.weapon.melee.Zenith;
|
||||||
import com.lzxnone.terraria.item.weapon.ranged.SniperRifle;
|
import com.lzxnone.terraria.item.weapon.ranged.gun.SniperRifle;
|
||||||
import com.lzxnone.terraria.network.payload.ClearSummonPayload;
|
import com.lzxnone.terraria.network.payload.ClearSummonPayload;
|
||||||
import com.lzxnone.terraria.network.payload.DevilsDevastationKillModePayload;
|
import com.lzxnone.terraria.network.payload.DevilsDevastationKillModePayload;
|
||||||
import com.lzxnone.terraria.network.payload.FirstFractalScrollPayload;
|
import com.lzxnone.terraria.network.payload.FirstFractalScrollPayload;
|
||||||
|
|||||||
@@ -0,0 +1,98 @@
|
|||||||
|
package com.lzxnone.terraria.client.event;
|
||||||
|
|
||||||
|
import com.lzxnone.terraria.LzxnoneTerraria;
|
||||||
|
import com.lzxnone.terraria.attachment.ModAttachments;
|
||||||
|
import com.lzxnone.terraria.attachment.PlayerMana;
|
||||||
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.gui.Font;
|
||||||
|
import net.minecraft.client.gui.GuiGraphics;
|
||||||
|
import net.minecraft.client.player.LocalPlayer;
|
||||||
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
import net.minecraft.util.Mth;
|
||||||
|
|
||||||
|
public class ManaHudRenderer {
|
||||||
|
private static final ResourceLocation MANA_TEXTURE = ResourceLocation.fromNamespaceAndPath(
|
||||||
|
LzxnoneTerraria.MODID,
|
||||||
|
"textures/ui/mana.png"
|
||||||
|
);
|
||||||
|
private static final int TEXTURE_WIDTH = 22;
|
||||||
|
private static final int TEXTURE_HEIGHT = 24;
|
||||||
|
private static final int MAX_SEGMENT_COUNT = 10;
|
||||||
|
private static final int SLOT_WIDTH = 8;
|
||||||
|
private static final int SLOT_HEIGHT = 9;
|
||||||
|
private static final int SLOT_GAP = 1;
|
||||||
|
private static final int LEFT_MARGIN = 10;
|
||||||
|
private static final int TOP_MARGIN = 28;
|
||||||
|
|
||||||
|
public static int manaBarX;
|
||||||
|
public static int manaBarY = TOP_MARGIN;
|
||||||
|
|
||||||
|
public static void render(GuiGraphics guiGraphics, LocalPlayer player) {
|
||||||
|
PlayerMana mana = player.getData(ModAttachments.PLAYER_MANA);
|
||||||
|
int maxMana = Math.max(0, mana.getMaxMana());
|
||||||
|
if(maxMana <= 0) return;
|
||||||
|
|
||||||
|
int segmentCount = Math.min(MAX_SEGMENT_COUNT, maxMana);
|
||||||
|
float segmentMana = maxMana < MAX_SEGMENT_COUNT ? 1.0F : maxMana / (float)MAX_SEGMENT_COUNT;
|
||||||
|
int currentMana = Mth.clamp(mana.getMana(), 0, maxMana);
|
||||||
|
if(currentMana >= maxMana) return;
|
||||||
|
|
||||||
|
manaBarX = LEFT_MARGIN;
|
||||||
|
manaBarY = TOP_MARGIN;
|
||||||
|
|
||||||
|
RenderSystem.enableBlend();
|
||||||
|
RenderSystem.defaultBlendFunc();
|
||||||
|
float missingMana = maxMana - currentMana;
|
||||||
|
for(int i = 0; i < segmentCount; i++) {
|
||||||
|
int bottomIndex = segmentCount - 1 - i;
|
||||||
|
float drained = Mth.clamp(missingMana - bottomIndex * segmentMana, 0.0F, segmentMana);
|
||||||
|
float fill = 1.0F - drained / segmentMana;
|
||||||
|
int slotY = manaBarY + i * (SLOT_HEIGHT + SLOT_GAP);
|
||||||
|
renderSegment(guiGraphics, manaBarX, slotY, fill);
|
||||||
|
}
|
||||||
|
guiGraphics.setColor(1.0F, 1.0F, 1.0F, 1.0F);
|
||||||
|
renderManaText(guiGraphics, currentMana, maxMana, segmentCount);
|
||||||
|
RenderSystem.disableBlend();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void renderSegment(GuiGraphics guiGraphics, int slotX, int slotY, float fill) {
|
||||||
|
boolean empty = fill <= 0.0F;
|
||||||
|
float scale = empty ? 0.5F : 0.5F + fill * 0.5F;
|
||||||
|
int width = Math.max(1, Math.round(SLOT_WIDTH * scale));
|
||||||
|
int height = Math.max(1, Math.round(SLOT_HEIGHT * scale));
|
||||||
|
int x = slotX + (SLOT_WIDTH - width) / 2;
|
||||||
|
int y = slotY + (SLOT_HEIGHT - height) / 2;
|
||||||
|
|
||||||
|
if(empty) {
|
||||||
|
guiGraphics.setColor(0.0F, 0.0F, 0.0F, 0.8F);
|
||||||
|
} else {
|
||||||
|
guiGraphics.setColor(1.0F, 1.0F, 1.0F, 1.0F);
|
||||||
|
}
|
||||||
|
|
||||||
|
guiGraphics.blit(
|
||||||
|
MANA_TEXTURE,
|
||||||
|
x,
|
||||||
|
y,
|
||||||
|
width,
|
||||||
|
height,
|
||||||
|
0.0F,
|
||||||
|
0.0F,
|
||||||
|
TEXTURE_WIDTH,
|
||||||
|
TEXTURE_HEIGHT,
|
||||||
|
TEXTURE_WIDTH,
|
||||||
|
TEXTURE_HEIGHT
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void renderManaText(GuiGraphics guiGraphics, int currentMana, int maxMana, int segmentCount) {
|
||||||
|
Font font = Minecraft.getInstance().font;
|
||||||
|
String text = currentMana + "/" + maxMana;
|
||||||
|
int textWidth = font.width(text);
|
||||||
|
int barCenterX = manaBarX + SLOT_WIDTH / 2;
|
||||||
|
int textX = Mth.clamp(barCenterX - textWidth / 2, 2, guiGraphics.guiWidth() - textWidth - 2);
|
||||||
|
int textY = manaBarY + segmentCount * SLOT_HEIGHT + (segmentCount - 1) * SLOT_GAP + 2;
|
||||||
|
|
||||||
|
guiGraphics.drawString(font, text, textX, textY, 0x66CCFF, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -64,7 +64,8 @@ public class RangedWeaponGuiHandler {
|
|||||||
|
|
||||||
private static void renderAmmoDropHint(GuiGraphics guiGraphics, RangedWeapon rangedWeapon,
|
private static void renderAmmoDropHint(GuiGraphics guiGraphics, RangedWeapon rangedWeapon,
|
||||||
ItemStack weaponStack, ItemStack carriedStack, Slot slot) {
|
ItemStack weaponStack, ItemStack carriedStack, Slot slot) {
|
||||||
if(carriedStack.isEmpty() || !carriedStack.is(ModItemTags.BULLET_AMMO)) return;
|
if(carriedStack.isEmpty()) return;
|
||||||
|
if(!carriedStack.is(ModItemTags.AMMO)) return;
|
||||||
|
|
||||||
int color = rangedWeapon.canUseAmmo(weaponStack, carriedStack) ? VALID_AMMO_COLOR : INVALID_AMMO_COLOR;
|
int color = rangedWeapon.canUseAmmo(weaponStack, carriedStack) ? VALID_AMMO_COLOR : INVALID_AMMO_COLOR;
|
||||||
guiGraphics.fill(slot.x, slot.y, slot.x + 16, slot.y + 16, color);
|
guiGraphics.fill(slot.x, slot.y, slot.x + 16, slot.y + 16, color);
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package com.lzxnone.terraria.client.event;
|
|||||||
|
|
||||||
import com.lzxnone.terraria.LzxnoneTerraria;
|
import com.lzxnone.terraria.LzxnoneTerraria;
|
||||||
import com.lzxnone.terraria.item.ModItems;
|
import com.lzxnone.terraria.item.ModItems;
|
||||||
import com.lzxnone.terraria.item.weapon.ranged.SniperRifle;
|
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.Gui;
|
import net.minecraft.client.gui.Gui;
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
package com.lzxnone.terraria.client.item.ammo;
|
|
||||||
|
|
||||||
import com.lzxnone.terraria.client.entity.projectile.IStaticProjectileRenderBehavior;
|
|
||||||
|
|
||||||
public class ClientCrystalFragment {
|
|
||||||
public static final IStaticProjectileRenderBehavior PROJECTILE_BEHAVIOR = new IStaticProjectileRenderBehavior() {};
|
|
||||||
}
|
|
||||||
@@ -29,7 +29,7 @@ public class ClientFirstFractal {
|
|||||||
public static final IStaticSummonRenderBehavior SUMMON_BEHAVIOR = new IStaticSummonRenderBehavior() {
|
public static final IStaticSummonRenderBehavior SUMMON_BEHAVIOR = new IStaticSummonRenderBehavior() {
|
||||||
|
|
||||||
public static final ResourceLocation RES = ResourceLocation.parse("lzxnoneterraria:textures/vfx/beam_sparkle.png");
|
public static final ResourceLocation RES = ResourceLocation.parse("lzxnoneterraria:textures/vfx/beam_sparkle.png");
|
||||||
public static final ResourceLocation RES2 = ResourceLocation.parse("lzxnoneterraria:textures/vfx/first_fractal_star.png");
|
public static final ResourceLocation RES2 = ResourceLocation.parse("lzxnoneterraria:textures/vfx/star_wave.png");
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(Entity entity, float entityYaw, float partialTick, PoseStack poseStack, MultiBufferSource bufferSource, int packedLight) {
|
public void render(Entity entity, float entityYaw, float partialTick, PoseStack poseStack, MultiBufferSource bufferSource, int packedLight) {
|
||||||
|
|||||||
+1
-7
@@ -1,4 +1,4 @@
|
|||||||
package com.lzxnone.terraria.client.item.ammo;
|
package com.lzxnone.terraria.client.item.ranged;
|
||||||
|
|
||||||
import com.lzxnone.terraria.client.entity.summon.IStaticSummonRenderBehavior;
|
import com.lzxnone.terraria.client.entity.summon.IStaticSummonRenderBehavior;
|
||||||
import com.lzxnone.terraria.entity.summon.StaticSummon;
|
import com.lzxnone.terraria.entity.summon.StaticSummon;
|
||||||
@@ -8,7 +8,6 @@ import net.minecraft.client.Minecraft;
|
|||||||
import net.minecraft.client.renderer.LightTexture;
|
import net.minecraft.client.renderer.LightTexture;
|
||||||
import net.minecraft.client.renderer.MultiBufferSource;
|
import net.minecraft.client.renderer.MultiBufferSource;
|
||||||
import net.minecraft.client.renderer.texture.OverlayTexture;
|
import net.minecraft.client.renderer.texture.OverlayTexture;
|
||||||
import net.minecraft.util.Mth;
|
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.item.ItemDisplayContext;
|
import net.minecraft.world.item.ItemDisplayContext;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
@@ -23,8 +22,6 @@ public class ClientBulletAmmo {
|
|||||||
poseStack.pushPose();
|
poseStack.pushPose();
|
||||||
|
|
||||||
//旋转(方向修正)
|
//旋转(方向修正)
|
||||||
//poseStack.mulPose(Axis.YP.rotationDegrees(-Mth.lerp(partialTick, summon.yRotO, summon.getYRot())));
|
|
||||||
//poseStack.mulPose(Axis.XP.rotationDegrees(Mth.lerp(partialTick, summon.xRotO, summon.getXRot())));
|
|
||||||
poseStack.mulPose(Axis.YP.rotationDegrees(-summon.getYRot()));
|
poseStack.mulPose(Axis.YP.rotationDegrees(-summon.getYRot()));
|
||||||
poseStack.mulPose(Axis.XP.rotationDegrees(summon.getXRot()));
|
poseStack.mulPose(Axis.XP.rotationDegrees(summon.getXRot()));
|
||||||
|
|
||||||
@@ -51,9 +48,6 @@ public class ClientBulletAmmo {
|
|||||||
poseStack.pushPose();
|
poseStack.pushPose();
|
||||||
|
|
||||||
//旋转(方向修正)
|
//旋转(方向修正)
|
||||||
//poseStack.mulPose(Axis.YP.rotationDegrees(-Mth.lerp(partialTick, summon.yRotO, summon.getYRot())));
|
|
||||||
//poseStack.mulPose(Axis.XP.rotationDegrees(Mth.lerp(partialTick, summon.xRotO, summon.getXRot())));
|
|
||||||
|
|
||||||
poseStack.mulPose(Axis.YP.rotationDegrees(-summon.getYRot()));
|
poseStack.mulPose(Axis.YP.rotationDegrees(-summon.getYRot()));
|
||||||
poseStack.mulPose(Axis.XP.rotationDegrees(summon.getXRot()));
|
poseStack.mulPose(Axis.XP.rotationDegrees(summon.getXRot()));
|
||||||
|
|
||||||
@@ -0,0 +1,94 @@
|
|||||||
|
package com.lzxnone.terraria.client.item.ranged;
|
||||||
|
|
||||||
|
import com.lzxnone.terraria.client.entity.summon.IStaticSummonRenderBehavior;
|
||||||
|
import com.lzxnone.terraria.entity.ModRenderTypes;
|
||||||
|
import com.lzxnone.terraria.entity.summon.StaticSummon;
|
||||||
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
|
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||||
|
import com.mojang.math.Axis;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.renderer.LightTexture;
|
||||||
|
import net.minecraft.client.renderer.MultiBufferSource;
|
||||||
|
import net.minecraft.client.renderer.texture.OverlayTexture;
|
||||||
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
import net.minecraft.util.Mth;
|
||||||
|
import net.minecraft.world.entity.Entity;
|
||||||
|
import net.minecraft.world.phys.Vec3;
|
||||||
|
|
||||||
|
public class ClientFlamethrower {
|
||||||
|
private static final double RENDER_INTERVAL = 2.0D;
|
||||||
|
private static final float MIN_HALF_SIZE = 0.05f;
|
||||||
|
private static final float MAX_HALF_SIZE = 3.0f;
|
||||||
|
|
||||||
|
public static final IStaticSummonRenderBehavior SUMMON_BEHAVIOR = new IStaticSummonRenderBehavior() {
|
||||||
|
public static final ResourceLocation[] RES = {
|
||||||
|
ResourceLocation.parse("lzxnoneterraria:textures/vfx/flame_projectile0.png"),
|
||||||
|
ResourceLocation.parse("lzxnoneterraria:textures/vfx/flame_projectile1.png"),
|
||||||
|
ResourceLocation.parse("lzxnoneterraria:textures/vfx/flame_projectile2.png"),
|
||||||
|
ResourceLocation.parse("lzxnoneterraria:textures/vfx/flame_projectile3.png"),
|
||||||
|
ResourceLocation.parse("lzxnoneterraria:textures/vfx/flame_projectile4.png"),
|
||||||
|
ResourceLocation.parse("lzxnoneterraria:textures/vfx/flame_projectile5.png"),
|
||||||
|
ResourceLocation.parse("lzxnoneterraria:textures/vfx/flame_projectile6.png")
|
||||||
|
};
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void render(Entity entity, float entityYaw, float partialTick, PoseStack poseStack, MultiBufferSource bufferSource, int packedLight) {
|
||||||
|
if(!(entity instanceof StaticSummon summon)) return;
|
||||||
|
CompoundTag customData = summon.getEntityData().get(StaticSummon.CUSTOM_DATA);
|
||||||
|
float age = summon.getEntityData().get(StaticSummon.AGE) + partialTick;
|
||||||
|
float lifetime = Math.max(1.0f, summon.getEntityData().get(StaticSummon.LIFETIME));
|
||||||
|
Vec3 end = new Vec3(
|
||||||
|
Mth.lerp(partialTick, summon.xo, summon.getX()),
|
||||||
|
Mth.lerp(partialTick, summon.yo, summon.getY()),
|
||||||
|
Mth.lerp(partialTick, summon.zo, summon.getZ())
|
||||||
|
);
|
||||||
|
Vec3 start = new Vec3(
|
||||||
|
customData.contains("startX") ? customData.getFloat("startX") : end.x,
|
||||||
|
customData.contains("startY") ? customData.getFloat("startY") : end.y,
|
||||||
|
customData.contains("startZ") ? customData.getFloat("startZ") : end.z
|
||||||
|
);
|
||||||
|
|
||||||
|
float progress = Mth.clamp(age / lifetime, 0.0f, 1.0f);
|
||||||
|
int resIndex = Math.min(RES.length - 1, (int) (progress * RES.length));
|
||||||
|
float alpha = 1.0f - progress * 0.85f;
|
||||||
|
float flameRed = customData.contains("flameRed") ? customData.getFloat("flameRed") : 1.0f;
|
||||||
|
float flameGreen = customData.contains("flameGreen") ? customData.getFloat("flameGreen") : 0.55f;
|
||||||
|
float flameBlue = customData.contains("flameBlue") ? customData.getFloat("flameBlue") : 0.1f;
|
||||||
|
Vec3 span = end.subtract(start);
|
||||||
|
double length = span.length();
|
||||||
|
if(length <= 1.0E-4D) return;
|
||||||
|
Vec3 direction = span.scale(1.0D / length);
|
||||||
|
|
||||||
|
VertexConsumer consumer = bufferSource.getBuffer(ModRenderTypes.entityAdditiveEmissive(RES[resIndex]));
|
||||||
|
int index = 0;
|
||||||
|
for(double distance = Math.min(RENDER_INTERVAL, length); distance <= length + 1.0E-4D; distance += RENDER_INTERVAL) {
|
||||||
|
float segmentProgress = (float) (distance / length);
|
||||||
|
Vec3 localPos = start.add(direction.scale(distance)).subtract(end);
|
||||||
|
float halfSize = Mth.lerp(segmentProgress, MIN_HALF_SIZE, MAX_HALF_SIZE);
|
||||||
|
float rotationAge = age + index;
|
||||||
|
|
||||||
|
poseStack.pushPose();
|
||||||
|
poseStack.translate(localPos.x, localPos.y, localPos.z);
|
||||||
|
poseStack.mulPose(Minecraft.getInstance().getEntityRenderDispatcher().cameraOrientation());
|
||||||
|
poseStack.mulPose(Axis.ZP.rotationDegrees(rotationAge * 24.0f));
|
||||||
|
|
||||||
|
consumer.addVertex(poseStack.last().pose(), -halfSize, -halfSize, 0.0f)
|
||||||
|
.setColor(flameRed, Math.min(1.0f, flameGreen * 1.45f), Math.min(1.0f, flameBlue * 1.45f), alpha).setUv(0.0f, 1.0f)
|
||||||
|
.setOverlay(OverlayTexture.NO_OVERLAY).setLight(LightTexture.FULL_BRIGHT).setNormal(0.0f, 1.0f, 0.0f);
|
||||||
|
consumer.addVertex(poseStack.last().pose(), halfSize, -halfSize, 0.0f)
|
||||||
|
.setColor(flameRed, flameGreen, flameBlue, alpha).setUv(1.0f, 1.0f)
|
||||||
|
.setOverlay(OverlayTexture.NO_OVERLAY).setLight(LightTexture.FULL_BRIGHT).setNormal(0.0f, 1.0f, 0.0f);
|
||||||
|
consumer.addVertex(poseStack.last().pose(), halfSize, halfSize, 0.0f)
|
||||||
|
.setColor(flameRed, flameGreen * 0.35f, flameBlue * 0.35f, alpha).setUv(1.0f, 0.0f)
|
||||||
|
.setOverlay(OverlayTexture.NO_OVERLAY).setLight(LightTexture.FULL_BRIGHT).setNormal(0.0f, 1.0f, 0.0f);
|
||||||
|
consumer.addVertex(poseStack.last().pose(), -halfSize, halfSize, 0.0f)
|
||||||
|
.setColor(flameRed, flameGreen, flameBlue, alpha).setUv(0.0f, 0.0f)
|
||||||
|
.setOverlay(OverlayTexture.NO_OVERLAY).setLight(LightTexture.FULL_BRIGHT).setNormal(0.0f, 1.0f, 0.0f);
|
||||||
|
|
||||||
|
poseStack.popPose();
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -0,0 +1,97 @@
|
|||||||
|
package com.lzxnone.terraria.client.item.ranged;
|
||||||
|
|
||||||
|
import com.lzxnone.terraria.client.entity.summon.IStaticSummonRenderBehavior;
|
||||||
|
import com.lzxnone.terraria.entity.ModRenderTypes;
|
||||||
|
import com.lzxnone.terraria.entity.summon.StaticSummon;
|
||||||
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
|
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||||
|
import com.mojang.math.Axis;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.renderer.LightTexture;
|
||||||
|
import net.minecraft.client.renderer.MultiBufferSource;
|
||||||
|
import net.minecraft.client.renderer.texture.OverlayTexture;
|
||||||
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
import net.minecraft.world.entity.Entity;
|
||||||
|
import net.minecraft.world.item.ItemDisplayContext;
|
||||||
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
import net.minecraft.world.phys.Vec3;
|
||||||
|
import org.joml.Vector3f;
|
||||||
|
|
||||||
|
public class ClientStarCannon {
|
||||||
|
public static final IStaticSummonRenderBehavior SUMMON_BEHAVIOR = new IStaticSummonRenderBehavior() {
|
||||||
|
public static final ResourceLocation RES = ResourceLocation.parse("lzxnoneterraria:textures/vfx/star_wave.png");
|
||||||
|
|
||||||
|
public void render(Entity entity, float entityYaw, float partialTick, PoseStack poseStack, MultiBufferSource bufferSource, int packedLight) {
|
||||||
|
if(!(entity instanceof StaticSummon summon)) return;
|
||||||
|
ItemStack itemStack = summon.getEntityData().get(StaticSummon.ITEM);
|
||||||
|
if(itemStack == ItemStack.EMPTY) return;
|
||||||
|
|
||||||
|
float age = summon.getEntityData().get(StaticSummon.AGE) + partialTick;
|
||||||
|
|
||||||
|
poseStack.pushPose();
|
||||||
|
|
||||||
|
//旋转(方向修正)
|
||||||
|
poseStack.mulPose(Axis.YP.rotationDegrees(-summon.getYRot()));
|
||||||
|
poseStack.mulPose(Axis.XP.rotationDegrees(summon.getXRot()));
|
||||||
|
|
||||||
|
poseStack.mulPose(Axis.XP.rotationDegrees(age * 15));
|
||||||
|
poseStack.mulPose(Axis.YP.rotationDegrees(-90));
|
||||||
|
|
||||||
|
poseStack.scale(
|
||||||
|
summon.getEntityData().get(StaticSummon.SCALE_X),
|
||||||
|
summon.getEntityData().get(StaticSummon.SCALE_Y),
|
||||||
|
summon.getEntityData().get(StaticSummon.SCALE_Z)
|
||||||
|
);
|
||||||
|
|
||||||
|
Minecraft.getInstance().getItemRenderer().renderStatic(
|
||||||
|
itemStack,
|
||||||
|
ItemDisplayContext.NONE,
|
||||||
|
LightTexture.FULL_BRIGHT,
|
||||||
|
OverlayTexture.NO_OVERLAY,
|
||||||
|
poseStack,
|
||||||
|
bufferSource,
|
||||||
|
entity.level(),
|
||||||
|
0
|
||||||
|
);
|
||||||
|
poseStack.popPose();
|
||||||
|
|
||||||
|
poseStack.pushPose();
|
||||||
|
float starHalfWidth = 45 * 0.06f;
|
||||||
|
float starHalfHeight = 17 * 0.06f;
|
||||||
|
VertexConsumer starConsumer = bufferSource.getBuffer(ModRenderTypes.entityTranslucentEmissive(RES));
|
||||||
|
|
||||||
|
Vec3 dir = summon.getLookAngle().normalize();
|
||||||
|
double dist = -0.75;
|
||||||
|
poseStack.translate(dir.x * dist, dir.y * dist, dir.z * dist);
|
||||||
|
|
||||||
|
poseStack.mulPose(Axis.YP.rotationDegrees(-summon.getYRot()));
|
||||||
|
poseStack.mulPose(Axis.XP.rotationDegrees(summon.getXRot()));
|
||||||
|
|
||||||
|
poseStack.mulPose(Axis.YP.rotationDegrees(270));
|
||||||
|
|
||||||
|
poseStack.scale(
|
||||||
|
summon.getEntityData().get(StaticSummon.SCALE_X),
|
||||||
|
summon.getEntityData().get(StaticSummon.SCALE_Y),
|
||||||
|
summon.getEntityData().get(StaticSummon.SCALE_Z)
|
||||||
|
);
|
||||||
|
|
||||||
|
Vector3f color = new Vector3f(0.29f, 0.29f, 0.871f);
|
||||||
|
float alpha = 0.5f;
|
||||||
|
for(int i = 0; i < 1; i++) {
|
||||||
|
starConsumer.addVertex(poseStack.last().pose(), -starHalfWidth, -starHalfHeight, 0f)
|
||||||
|
.setColor(color.x, color.y, color.z, alpha).setUv(0.0f, 1.0f)
|
||||||
|
.setOverlay(OverlayTexture.NO_OVERLAY).setLight(LightTexture.FULL_BRIGHT).setNormal(0.0f, 1.0f, 0.0f);
|
||||||
|
starConsumer.addVertex(poseStack.last().pose(), starHalfWidth, -starHalfHeight, 0f)
|
||||||
|
.setColor(color.x, color.y, color.z, alpha).setUv(1.0f, 1.0f)
|
||||||
|
.setOverlay(OverlayTexture.NO_OVERLAY).setLight(LightTexture.FULL_BRIGHT).setNormal(0.0f, 1.0f, 0.0f);
|
||||||
|
starConsumer.addVertex(poseStack.last().pose(), starHalfWidth, starHalfHeight, 0f)
|
||||||
|
.setColor(color.x, color.y, color.z, alpha).setUv(1.0f, 0.0f)
|
||||||
|
.setOverlay(OverlayTexture.NO_OVERLAY).setLight(LightTexture.FULL_BRIGHT).setNormal(0.0f, 1.0f, 0.0f);
|
||||||
|
starConsumer.addVertex(poseStack.last().pose(), -starHalfWidth, starHalfHeight, 0f)
|
||||||
|
.setColor(color.x, color.y, color.z, alpha).setUv(0.0f, 0.0f)
|
||||||
|
.setOverlay(OverlayTexture.NO_OVERLAY).setLight(LightTexture.FULL_BRIGHT).setNormal(0.0f, 1.0f, 0.0f);
|
||||||
|
}
|
||||||
|
poseStack.popPose();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -0,0 +1,147 @@
|
|||||||
|
package com.lzxnone.terraria.client.item.ranged;
|
||||||
|
|
||||||
|
import com.lzxnone.terraria.client.entity.projectile.IStaticProjectileRenderBehavior;
|
||||||
|
import com.lzxnone.terraria.client.entity.summon.IStaticSummonRenderBehavior;
|
||||||
|
import com.lzxnone.terraria.entity.ModRenderTypes;
|
||||||
|
import com.lzxnone.terraria.entity.TintedVertexConsumer;
|
||||||
|
import com.lzxnone.terraria.entity.projectile.StaticProjectile;
|
||||||
|
import com.lzxnone.terraria.entity.summon.StaticSummon;
|
||||||
|
import com.lzxnone.terraria.utils.MathUtil;
|
||||||
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
|
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||||
|
import com.mojang.math.Axis;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.renderer.LightTexture;
|
||||||
|
import net.minecraft.client.renderer.MultiBufferSource;
|
||||||
|
import net.minecraft.client.renderer.texture.OverlayTexture;
|
||||||
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
import net.minecraft.world.entity.Entity;
|
||||||
|
import net.minecraft.world.inventory.InventoryMenu;
|
||||||
|
import net.minecraft.world.item.ItemDisplayContext;
|
||||||
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
import net.minecraft.world.phys.Vec3;
|
||||||
|
import org.joml.Vector3f;
|
||||||
|
|
||||||
|
public class ClientSuperStarShooter {
|
||||||
|
public static final IStaticSummonRenderBehavior SUMMON_BEHAVIOR = new IStaticSummonRenderBehavior() {
|
||||||
|
public static final ResourceLocation RES = ResourceLocation.parse("lzxnoneterraria:textures/vfx/star_wave.png");
|
||||||
|
|
||||||
|
public void render(Entity entity, float entityYaw, float partialTick, PoseStack poseStack, MultiBufferSource bufferSource, int packedLight) {
|
||||||
|
if(!(entity instanceof StaticSummon summon)) return;
|
||||||
|
ItemStack itemStack = summon.getEntityData().get(StaticSummon.ITEM);
|
||||||
|
if(itemStack == ItemStack.EMPTY) return;
|
||||||
|
|
||||||
|
float age = summon.getEntityData().get(StaticSummon.AGE) + partialTick;
|
||||||
|
|
||||||
|
poseStack.pushPose();
|
||||||
|
|
||||||
|
//旋转(方向修正)
|
||||||
|
poseStack.mulPose(Axis.YP.rotationDegrees(-summon.getYRot()));
|
||||||
|
poseStack.mulPose(Axis.XP.rotationDegrees(summon.getXRot()));
|
||||||
|
|
||||||
|
poseStack.mulPose(Axis.XP.rotationDegrees(age * 15));
|
||||||
|
poseStack.mulPose(Axis.YP.rotationDegrees(-90));
|
||||||
|
|
||||||
|
poseStack.scale(
|
||||||
|
summon.getEntityData().get(StaticSummon.SCALE_X),
|
||||||
|
summon.getEntityData().get(StaticSummon.SCALE_Y),
|
||||||
|
summon.getEntityData().get(StaticSummon.SCALE_Z)
|
||||||
|
);
|
||||||
|
|
||||||
|
Minecraft.getInstance().getItemRenderer().renderStatic(
|
||||||
|
itemStack,
|
||||||
|
ItemDisplayContext.NONE,
|
||||||
|
LightTexture.FULL_BRIGHT,
|
||||||
|
OverlayTexture.NO_OVERLAY,
|
||||||
|
poseStack,
|
||||||
|
renderType -> {
|
||||||
|
VertexConsumer vertexConsumer = bufferSource.getBuffer(ModRenderTypes.entityTranslucentEmissive(InventoryMenu.BLOCK_ATLAS));
|
||||||
|
return new TintedVertexConsumer(vertexConsumer,
|
||||||
|
1.0f,
|
||||||
|
0.95f,
|
||||||
|
0.2f,
|
||||||
|
1.0f);
|
||||||
|
},
|
||||||
|
entity.level(),
|
||||||
|
0
|
||||||
|
);
|
||||||
|
poseStack.popPose();
|
||||||
|
|
||||||
|
poseStack.pushPose();
|
||||||
|
float starHalfWidth = 45 * 0.06f;
|
||||||
|
float starHalfHeight = 17 * 0.06f;
|
||||||
|
VertexConsumer starConsumer = bufferSource.getBuffer(ModRenderTypes.entityTranslucentEmissive(RES));
|
||||||
|
|
||||||
|
Vec3 dir = summon.getLookAngle().normalize();
|
||||||
|
double dist = -0.75;
|
||||||
|
poseStack.translate(dir.x * dist, dir.y * dist, dir.z * dist);
|
||||||
|
|
||||||
|
poseStack.mulPose(Axis.YP.rotationDegrees(-summon.getYRot()));
|
||||||
|
poseStack.mulPose(Axis.XP.rotationDegrees(summon.getXRot()));
|
||||||
|
|
||||||
|
poseStack.mulPose(Axis.YP.rotationDegrees(270));
|
||||||
|
|
||||||
|
poseStack.scale(
|
||||||
|
summon.getEntityData().get(StaticSummon.SCALE_X),
|
||||||
|
summon.getEntityData().get(StaticSummon.SCALE_Y),
|
||||||
|
summon.getEntityData().get(StaticSummon.SCALE_Z)
|
||||||
|
);
|
||||||
|
|
||||||
|
Vector3f color = new Vector3f(1.0f, 0.72f, 0.35f);
|
||||||
|
float alpha = 0.5f;
|
||||||
|
for(int i = 0; i < 1; i++) {
|
||||||
|
starConsumer.addVertex(poseStack.last().pose(), -starHalfWidth, -starHalfHeight, 0f)
|
||||||
|
.setColor(color.x, color.y, color.z, alpha).setUv(0.0f, 1.0f)
|
||||||
|
.setOverlay(OverlayTexture.NO_OVERLAY).setLight(LightTexture.FULL_BRIGHT).setNormal(0.0f, 1.0f, 0.0f);
|
||||||
|
starConsumer.addVertex(poseStack.last().pose(), starHalfWidth, -starHalfHeight, 0f)
|
||||||
|
.setColor(color.x, color.y, color.z, alpha).setUv(1.0f, 1.0f)
|
||||||
|
.setOverlay(OverlayTexture.NO_OVERLAY).setLight(LightTexture.FULL_BRIGHT).setNormal(0.0f, 1.0f, 0.0f);
|
||||||
|
starConsumer.addVertex(poseStack.last().pose(), starHalfWidth, starHalfHeight, 0f)
|
||||||
|
.setColor(color.x, color.y, color.z, alpha).setUv(1.0f, 0.0f)
|
||||||
|
.setOverlay(OverlayTexture.NO_OVERLAY).setLight(LightTexture.FULL_BRIGHT).setNormal(0.0f, 1.0f, 0.0f);
|
||||||
|
starConsumer.addVertex(poseStack.last().pose(), -starHalfWidth, starHalfHeight, 0f)
|
||||||
|
.setColor(color.x, color.y, color.z, alpha).setUv(0.0f, 0.0f)
|
||||||
|
.setOverlay(OverlayTexture.NO_OVERLAY).setLight(LightTexture.FULL_BRIGHT).setNormal(0.0f, 1.0f, 0.0f);
|
||||||
|
}
|
||||||
|
poseStack.popPose();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
public static final IStaticProjectileRenderBehavior PROJECTILE_BEHAVIOR = new IStaticProjectileRenderBehavior() {
|
||||||
|
public static final ResourceLocation RES = ResourceLocation.parse("lzxnoneterraria:textures/vfx/prismatic_bolt.png");
|
||||||
|
|
||||||
|
public void render(Entity entity, float entityYaw, float partialTick, PoseStack poseStack, MultiBufferSource bufferSource, int packedLight) {
|
||||||
|
if(!(entity instanceof StaticProjectile projectile)) return;
|
||||||
|
|
||||||
|
poseStack.pushPose();
|
||||||
|
float starHalfWidth = 72 * 0.02f;
|
||||||
|
float starHalfHeight = 72 * 0.02f;
|
||||||
|
VertexConsumer starConsumer = bufferSource.getBuffer(ModRenderTypes.entityAdditiveEmissive(RES));
|
||||||
|
|
||||||
|
Vector3f[] dirs = MathUtil.computeCoordinateSystem(projectile.getDeltaMovement().toVector3f(), 0);
|
||||||
|
float[] xyRot = MathUtil.computeXYRot(dirs[0]);
|
||||||
|
poseStack.mulPose(Axis.YP.rotationDegrees(-xyRot[1]));
|
||||||
|
poseStack.mulPose(Axis.XP.rotationDegrees(xyRot[0]));
|
||||||
|
|
||||||
|
poseStack.mulPose(Axis.XP.rotationDegrees(90));
|
||||||
|
|
||||||
|
poseStack.scale(1.0f, 2.0f, 1.0f);
|
||||||
|
|
||||||
|
for(int i = 0; i < 3; i++) {
|
||||||
|
starConsumer.addVertex(poseStack.last().pose(), -starHalfWidth, -starHalfHeight, 0f)
|
||||||
|
.setColor(1.0f, 1.0f, 1.0f, 1.0f).setUv(0.0f, 1.0f)
|
||||||
|
.setOverlay(OverlayTexture.NO_OVERLAY).setLight(LightTexture.FULL_BRIGHT).setNormal(0.0f, 1.0f, 0.0f);
|
||||||
|
starConsumer.addVertex(poseStack.last().pose(), starHalfWidth, -starHalfHeight, 0f)
|
||||||
|
.setColor(1.0f, 1.0f, 1.0f, 1.0f).setUv(1.0f, 1.0f)
|
||||||
|
.setOverlay(OverlayTexture.NO_OVERLAY).setLight(LightTexture.FULL_BRIGHT).setNormal(0.0f, 1.0f, 0.0f);
|
||||||
|
starConsumer.addVertex(poseStack.last().pose(), starHalfWidth, starHalfHeight, 0f)
|
||||||
|
.setColor(1.0f, 1.0f, 1.0f, 1.0f).setUv(1.0f, 0.0f)
|
||||||
|
.setOverlay(OverlayTexture.NO_OVERLAY).setLight(LightTexture.FULL_BRIGHT).setNormal(0.0f, 1.0f, 0.0f);
|
||||||
|
starConsumer.addVertex(poseStack.last().pose(), -starHalfWidth, starHalfHeight, 0f)
|
||||||
|
.setColor(1.0f, 1.0f, 1.0f, 1.0f).setUv(0.0f, 0.0f)
|
||||||
|
.setOverlay(OverlayTexture.NO_OVERLAY).setLight(LightTexture.FULL_BRIGHT).setNormal(0.0f, 1.0f, 0.0f);
|
||||||
|
}
|
||||||
|
poseStack.popPose();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -55,6 +55,14 @@ public class ModCreativeModeTabs {
|
|||||||
output.accept(ModItems.LAST_PRISM.get());
|
output.accept(ModItems.LAST_PRISM.get());
|
||||||
}).build());
|
}).build());
|
||||||
|
|
||||||
|
public static final DeferredHolder<CreativeModeTab, CreativeModeTab> ACCESSORY_TAB = CREATIVE_MODE_TABS.register("lzxnoneterraria_accessory_0", () -> CreativeModeTab.builder()
|
||||||
|
.title(Component.translatable("itemGroup.lzxnoneterraria.accessory"))
|
||||||
|
.icon(() -> ModItems.MANA_FLOWER.get().getDefaultInstance())
|
||||||
|
.displayItems((parameters, output) -> {
|
||||||
|
output.accept(ModItems.NATURES_GIFT.get());
|
||||||
|
output.accept(ModItems.MANA_FLOWER.get());
|
||||||
|
}).build());
|
||||||
|
|
||||||
public static final DeferredHolder<CreativeModeTab, CreativeModeTab> RANGED_TAB = CREATIVE_MODE_TABS.register("lzxnoneterraria_ranged_0", () -> CreativeModeTab.builder()
|
public static final DeferredHolder<CreativeModeTab, CreativeModeTab> RANGED_TAB = CREATIVE_MODE_TABS.register("lzxnoneterraria_ranged_0", () -> CreativeModeTab.builder()
|
||||||
.title(Component.translatable("itemGroup.lzxnoneterraria.ranged"))
|
.title(Component.translatable("itemGroup.lzxnoneterraria.ranged"))
|
||||||
.icon(() -> ModItems.SDMG.get().getDefaultInstance())
|
.icon(() -> ModItems.SDMG.get().getDefaultInstance())
|
||||||
@@ -79,6 +87,11 @@ public class ModCreativeModeTabs {
|
|||||||
output.accept(ModItems.SNIPER_RIFLE.get());
|
output.accept(ModItems.SNIPER_RIFLE.get());
|
||||||
output.accept(ModItems.CHAIN_GUN.get());
|
output.accept(ModItems.CHAIN_GUN.get());
|
||||||
output.accept(ModItems.SDMG.get());
|
output.accept(ModItems.SDMG.get());
|
||||||
|
output.accept(ModItems.SNOWBALL_CANNON.get());
|
||||||
|
output.accept(ModItems.STAR_CANNON.get());
|
||||||
|
output.accept(ModItems.SUPER_STAR_SHOOTER.get());
|
||||||
|
output.accept(ModItems.FLAMETHROWER.get());
|
||||||
|
output.accept(ModItems.ELF_MELTER.get());
|
||||||
output.accept(ModItems.MUSKET_BALL.get());
|
output.accept(ModItems.MUSKET_BALL.get());
|
||||||
output.accept(ModItems.METEOR_SHOT.get());
|
output.accept(ModItems.METEOR_SHOT.get());
|
||||||
output.accept(ModItems.SILVER_BULLET.get());
|
output.accept(ModItems.SILVER_BULLET.get());
|
||||||
@@ -95,6 +108,7 @@ public class ModCreativeModeTabs {
|
|||||||
output.accept(ModItems.ENDLESS_MUSKET_POUCH.get());
|
output.accept(ModItems.ENDLESS_MUSKET_POUCH.get());
|
||||||
output.accept(ModItems.LUMINITE_BULLET.get());
|
output.accept(ModItems.LUMINITE_BULLET.get());
|
||||||
output.accept(ModItems.TUNGSTEN_BULLET.get());
|
output.accept(ModItems.TUNGSTEN_BULLET.get());
|
||||||
|
output.accept(ModItems.FALLEN_STAR.get());
|
||||||
}).build());
|
}).build());
|
||||||
|
|
||||||
public static final DeferredHolder<CreativeModeTab, CreativeModeTab> SUMMON_TAB = CREATIVE_MODE_TABS.register("lzxnoneterraria_summon_0", () -> CreativeModeTab.builder()
|
public static final DeferredHolder<CreativeModeTab, CreativeModeTab> SUMMON_TAB = CREATIVE_MODE_TABS.register("lzxnoneterraria_summon_0", () -> CreativeModeTab.builder()
|
||||||
|
|||||||
@@ -59,7 +59,9 @@ public class MEntityLuminance implements EntityLuminance {
|
|||||||
StaticSummonBehaviors.DEVILS_DEVASTATION_MARK_LIGHTNING,
|
StaticSummonBehaviors.DEVILS_DEVASTATION_MARK_LIGHTNING,
|
||||||
StaticSummonBehaviors.LAST_PRISM_TRI,
|
StaticSummonBehaviors.LAST_PRISM_TRI,
|
||||||
StaticSummonBehaviors.LAST_PRISM_BEAM,
|
StaticSummonBehaviors.LAST_PRISM_BEAM,
|
||||||
StaticSummonBehaviors.TERRAPRISMA -> {
|
StaticSummonBehaviors.TERRAPRISMA,
|
||||||
|
StaticSummonBehaviors.FLAMETHROWER_FLAME,
|
||||||
|
StaticSummonBehaviors.ELF_MELTER_FLAME -> {
|
||||||
return 15;
|
return 15;
|
||||||
}
|
}
|
||||||
case StaticSummonBehaviors.CHLOROPHYTE_BULLET,
|
case StaticSummonBehaviors.CHLOROPHYTE_BULLET,
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
package com.lzxnone.terraria.effect;
|
package com.lzxnone.terraria.effect;
|
||||||
|
|
||||||
import com.lzxnone.terraria.LzxnoneTerraria;
|
import com.lzxnone.terraria.LzxnoneTerraria;
|
||||||
import com.lzxnone.terraria.particle.DustParticleOptions;
|
|
||||||
import com.lzxnone.terraria.particle.ModParticles;
|
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.ConfigListItem;
|
||||||
import com.lzxnone.terraria.ui.config.ConfigUtil;
|
|
||||||
import com.lzxnone.terraria.ui.config.IConfigData;
|
import com.lzxnone.terraria.ui.config.IConfigData;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigFloat;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigStruct;
|
||||||
import com.lzxnone.terraria.utils.ParticleUtil;
|
import com.lzxnone.terraria.utils.ParticleUtil;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
@@ -15,39 +14,17 @@ import net.minecraft.world.effect.MobEffect;
|
|||||||
import net.minecraft.world.effect.MobEffectCategory;
|
import net.minecraft.world.effect.MobEffectCategory;
|
||||||
import net.minecraft.world.entity.LivingEntity;
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
import org.joml.Vector3f;
|
|
||||||
|
|
||||||
public class AcidVenomEffect extends MobEffect {
|
public class AcidVenomEffect extends MobEffect {
|
||||||
private static final String CONFIG_TRANSLATION_PREFIX = "lzxnoneterraria.configuration.";
|
public static final ConfigFloat DAMAGE_PER_LEVEL = new ConfigFloat("effect.acid_venom.damage_per_level", "acid_venom_damage_per_level", 2.0f, 0.0f, 8388600.0f);
|
||||||
|
|
||||||
public static final String DAMAGE_PER_LEVEL_PATH = "effect.acid_venom.damage_per_level";
|
|
||||||
public static final float DAMAGE_PER_LEVEL_DEFAULT = 2.0f;
|
|
||||||
public static final float DAMAGE_PER_LEVEL_MIN = 0.0f;
|
|
||||||
public static final float DAMAGE_PER_LEVEL_MAX = 8388600.0f;
|
|
||||||
|
|
||||||
public AcidVenomEffect() {
|
|
||||||
super(MobEffectCategory.HARMFUL, 0x8A2BE2);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
||||||
@Override
|
@Override
|
||||||
public void onConfigLoad() {
|
public void onConfigLoad() {
|
||||||
ConfigFactory.loadFloatConfig(DAMAGE_PER_LEVEL_PATH, configText("acid_venom_damage_per_level"), configTooltip("acid_venom_damage_per_level"), DAMAGE_PER_LEVEL_DEFAULT, DAMAGE_PER_LEVEL_MIN, DAMAGE_PER_LEVEL_MAX);
|
ConfigStruct.loadAll(DAMAGE_PER_LEVEL);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
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 float getDamagePerLevel() {
|
|
||||||
return Math.clamp(ConfigUtil.readFloat(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(
|
public static final ConfigListItem CONFIG_LIST_ITEM = new ConfigListItem(
|
||||||
"acid_venom",
|
"acid_venom",
|
||||||
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/mob_effect/acid_venom.png"),
|
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/mob_effect/acid_venom.png"),
|
||||||
@@ -55,6 +32,10 @@ public class AcidVenomEffect extends MobEffect {
|
|||||||
CONFIG_DATA
|
CONFIG_DATA
|
||||||
);
|
);
|
||||||
|
|
||||||
|
public AcidVenomEffect() {
|
||||||
|
super(MobEffectCategory.HARMFUL, 0x8A2BE2);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldApplyEffectTickThisTick(int duration, int amplifier) {
|
public boolean shouldApplyEffectTickThisTick(int duration, int amplifier) {
|
||||||
return true;
|
return true;
|
||||||
@@ -64,7 +45,7 @@ public class AcidVenomEffect extends MobEffect {
|
|||||||
public boolean applyEffectTick(LivingEntity entity, int amplifier) {
|
public boolean applyEffectTick(LivingEntity entity, int amplifier) {
|
||||||
if(entity.level() instanceof ServerLevel serverLevel) {
|
if(entity.level() instanceof ServerLevel serverLevel) {
|
||||||
if(entity.tickCount % 20 == 0) {
|
if(entity.tickCount % 20 == 0) {
|
||||||
if(entity.hurt(entity.damageSources().magic(), getDamagePerLevel() * (amplifier + 1))) entity.invulnerableTime = 10;
|
if(entity.hurt(entity.damageSources().magic(), DAMAGE_PER_LEVEL.get() * (amplifier + 1))) entity.invulnerableTime = 10;
|
||||||
}
|
}
|
||||||
ParticleUtil.addParticles(
|
ParticleUtil.addParticles(
|
||||||
serverLevel, ModParticles.BLACK_DUST_PARTICLE.get(),
|
serverLevel, ModParticles.BLACK_DUST_PARTICLE.get(),
|
||||||
|
|||||||
@@ -2,53 +2,29 @@ package com.lzxnone.terraria.effect;
|
|||||||
|
|
||||||
import com.lzxnone.terraria.LzxnoneTerraria;
|
import com.lzxnone.terraria.LzxnoneTerraria;
|
||||||
import com.lzxnone.terraria.particle.ModParticles;
|
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.ConfigListItem;
|
||||||
import com.lzxnone.terraria.ui.config.ConfigUtil;
|
|
||||||
import com.lzxnone.terraria.ui.config.IConfigData;
|
import com.lzxnone.terraria.ui.config.IConfigData;
|
||||||
import com.lzxnone.terraria.utils.MathUtil;
|
import com.lzxnone.terraria.ui.config.struct.ConfigFloat;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigStruct;
|
||||||
import com.lzxnone.terraria.utils.ParticleUtil;
|
import com.lzxnone.terraria.utils.ParticleUtil;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.world.effect.MobEffect;
|
import net.minecraft.world.effect.MobEffect;
|
||||||
import net.minecraft.world.effect.MobEffectCategory;
|
import net.minecraft.world.effect.MobEffectCategory;
|
||||||
import net.minecraft.world.effect.MobEffectInstance;
|
|
||||||
import net.minecraft.world.effect.MobEffects;
|
|
||||||
import net.minecraft.world.entity.LivingEntity;
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
|
|
||||||
public class BloodButcheredEffect extends MobEffect {
|
public class BloodButcheredEffect extends MobEffect {
|
||||||
private static final String CONFIG_TRANSLATION_PREFIX = "lzxnoneterraria.configuration.";
|
public static final ConfigFloat DAMAGE_PER_LEVEL = new ConfigFloat("effect.blood_butchered.damage_per_level", "blood_butcherer_damage_per_level", 0.5f, 0.0f, 8388600.0f);
|
||||||
|
|
||||||
public static final String DAMAGE_PER_LEVEL_PATH = "effect.blood_butchered.damage_per_level";
|
|
||||||
public static final float DAMAGE_PER_LEVEL_DEFAULT = 0.5f;
|
|
||||||
public static final float DAMAGE_PER_LEVEL_MIN = 0.0f;
|
|
||||||
public static final float DAMAGE_PER_LEVEL_MAX = 8388600.0f;
|
|
||||||
|
|
||||||
public BloodButcheredEffect() {
|
|
||||||
super(MobEffectCategory.HARMFUL, 0xFF0000);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
||||||
@Override
|
@Override
|
||||||
public void onConfigLoad() {
|
public void onConfigLoad() {
|
||||||
ConfigFactory.loadFloatConfig(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);
|
ConfigStruct.loadAll(DAMAGE_PER_LEVEL);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
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 float getDamagePerLevel() {
|
|
||||||
return Math.clamp(ConfigUtil.readFloat(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(
|
public static final ConfigListItem CONFIG_LIST_ITEM = new ConfigListItem(
|
||||||
"blood_butchered",
|
"blood_butchered",
|
||||||
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/mob_effect/blood_butchered.png"),
|
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/mob_effect/blood_butchered.png"),
|
||||||
@@ -56,6 +32,10 @@ public class BloodButcheredEffect extends MobEffect {
|
|||||||
CONFIG_DATA
|
CONFIG_DATA
|
||||||
);
|
);
|
||||||
|
|
||||||
|
public BloodButcheredEffect() {
|
||||||
|
super(MobEffectCategory.HARMFUL, 0xFF0000);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldApplyEffectTickThisTick(int duration, int amplifier) {
|
public boolean shouldApplyEffectTickThisTick(int duration, int amplifier) {
|
||||||
return true;
|
return true;
|
||||||
@@ -65,7 +45,7 @@ public class BloodButcheredEffect extends MobEffect {
|
|||||||
public boolean applyEffectTick(LivingEntity entity, int amplifier) {
|
public boolean applyEffectTick(LivingEntity entity, int amplifier) {
|
||||||
if(entity.level() instanceof ServerLevel serverLevel) {
|
if(entity.level() instanceof ServerLevel serverLevel) {
|
||||||
if(entity.tickCount % 20 == 0) {
|
if(entity.tickCount % 20 == 0) {
|
||||||
if(entity.hurt(entity.damageSources().magic(), (float) getDamagePerLevel() * (amplifier + 1))) entity.invulnerableTime = 10;
|
if(entity.hurt(entity.damageSources().magic(), (float) DAMAGE_PER_LEVEL.get() * (amplifier + 1))) entity.invulnerableTime = 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
ParticleUtil.addParticles(
|
ParticleUtil.addParticles(
|
||||||
|
|||||||
@@ -1,13 +1,11 @@
|
|||||||
package com.lzxnone.terraria.effect;
|
package com.lzxnone.terraria.effect;
|
||||||
|
|
||||||
import com.lzxnone.terraria.LzxnoneTerraria;
|
import com.lzxnone.terraria.LzxnoneTerraria;
|
||||||
import com.lzxnone.terraria.particle.CircleParticleOptions;
|
|
||||||
import com.lzxnone.terraria.particle.DustParticleOptions;
|
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.ConfigListItem;
|
||||||
import com.lzxnone.terraria.ui.config.ConfigUtil;
|
|
||||||
import com.lzxnone.terraria.ui.config.IConfigData;
|
import com.lzxnone.terraria.ui.config.IConfigData;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigFloat;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigStruct;
|
||||||
import com.lzxnone.terraria.utils.ParticleUtil;
|
import com.lzxnone.terraria.utils.ParticleUtil;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
@@ -19,36 +17,15 @@ import net.minecraft.world.phys.Vec3;
|
|||||||
import org.joml.Vector3f;
|
import org.joml.Vector3f;
|
||||||
|
|
||||||
public class CursedInfernoEffect extends MobEffect {
|
public class CursedInfernoEffect extends MobEffect {
|
||||||
private static final String CONFIG_TRANSLATION_PREFIX = "lzxnoneterraria.configuration.";
|
public static final ConfigFloat DAMAGE_PER_LEVEL = new ConfigFloat("effect.cursed_inferno.damage_per_level", "cursed_inferno_damage_per_level", 2.0f, 0.0f, 8388600.0f);
|
||||||
|
|
||||||
public static final String DAMAGE_PER_LEVEL_PATH = "effect.cursed_inferno.damage_per_level";
|
|
||||||
public static final float DAMAGE_PER_LEVEL_DEFAULT = 2.0f;
|
|
||||||
public static final float DAMAGE_PER_LEVEL_MIN = 0.0f;
|
|
||||||
public static final float DAMAGE_PER_LEVEL_MAX = 8388600.0f;
|
|
||||||
|
|
||||||
public CursedInfernoEffect() {
|
|
||||||
super(MobEffectCategory.HARMFUL, 0x66FF00);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
||||||
@Override
|
@Override
|
||||||
public void onConfigLoad() {
|
public void onConfigLoad() {
|
||||||
ConfigFactory.loadFloatConfig(DAMAGE_PER_LEVEL_PATH, configText("cursed_inferno_damage_per_level"), configTooltip("cursed_inferno_damage_per_level"), DAMAGE_PER_LEVEL_DEFAULT, DAMAGE_PER_LEVEL_MIN, DAMAGE_PER_LEVEL_MAX);
|
ConfigStruct.loadAll(DAMAGE_PER_LEVEL);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
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 float getDamagePerLevel() {
|
|
||||||
return Math.clamp(ConfigUtil.readFloat(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(
|
public static final ConfigListItem CONFIG_LIST_ITEM = new ConfigListItem(
|
||||||
"cursed_inferno",
|
"cursed_inferno",
|
||||||
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/mob_effect/cursed_inferno.png"),
|
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/mob_effect/cursed_inferno.png"),
|
||||||
@@ -56,6 +33,10 @@ public class CursedInfernoEffect extends MobEffect {
|
|||||||
CONFIG_DATA
|
CONFIG_DATA
|
||||||
);
|
);
|
||||||
|
|
||||||
|
public CursedInfernoEffect() {
|
||||||
|
super(MobEffectCategory.HARMFUL, 0x66FF00);
|
||||||
|
}
|
||||||
|
|
||||||
public static final DustParticleOptions PARTICLE = new DustParticleOptions(
|
public static final DustParticleOptions PARTICLE = new DustParticleOptions(
|
||||||
0.075f, 0.5f, 40, true, new Vector3f[]{
|
0.075f, 0.5f, 40, true, new Vector3f[]{
|
||||||
new Vector3f(0.5F, 1.0F, 0.5F),
|
new Vector3f(0.5F, 1.0F, 0.5F),
|
||||||
@@ -72,7 +53,7 @@ public class CursedInfernoEffect extends MobEffect {
|
|||||||
public boolean applyEffectTick(LivingEntity entity, int amplifier) {
|
public boolean applyEffectTick(LivingEntity entity, int amplifier) {
|
||||||
if(entity.level() instanceof ServerLevel serverLevel) {
|
if(entity.level() instanceof ServerLevel serverLevel) {
|
||||||
if(entity.tickCount % 20 == 0) {
|
if(entity.tickCount % 20 == 0) {
|
||||||
if(entity.hurt(entity.damageSources().magic(), getDamagePerLevel() * (amplifier + 1))) entity.invulnerableTime = 10;
|
if(entity.hurt(entity.damageSources().magic(), DAMAGE_PER_LEVEL.get() * (amplifier + 1))) entity.invulnerableTime = 10;
|
||||||
}
|
}
|
||||||
ParticleUtil.addParticles(
|
ParticleUtil.addParticles(
|
||||||
serverLevel, PARTICLE,
|
serverLevel, PARTICLE,
|
||||||
|
|||||||
@@ -2,10 +2,10 @@ package com.lzxnone.terraria.effect;
|
|||||||
|
|
||||||
import com.lzxnone.terraria.LzxnoneTerraria;
|
import com.lzxnone.terraria.LzxnoneTerraria;
|
||||||
import com.lzxnone.terraria.particle.CircleParticleOptions;
|
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.ConfigListItem;
|
||||||
import com.lzxnone.terraria.ui.config.ConfigUtil;
|
|
||||||
import com.lzxnone.terraria.ui.config.IConfigData;
|
import com.lzxnone.terraria.ui.config.IConfigData;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigFloat;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigStruct;
|
||||||
import com.lzxnone.terraria.utils.ParticleUtil;
|
import com.lzxnone.terraria.utils.ParticleUtil;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
@@ -18,36 +18,15 @@ import net.minecraft.world.phys.Vec3;
|
|||||||
import org.joml.Vector3f;
|
import org.joml.Vector3f;
|
||||||
|
|
||||||
public class DemonicFlamesEffect extends MobEffect {
|
public class DemonicFlamesEffect extends MobEffect {
|
||||||
private static final String CONFIG_TRANSLATION_PREFIX = "lzxnoneterraria.configuration.";
|
public static final ConfigFloat DAMAGE_PER_LEVEL = new ConfigFloat("effect.demonic_flames.damage_per_level", "demonic_flames_damage_per_level", 2.5f, 0.0f, 8388600.0f);
|
||||||
|
|
||||||
public static final String DAMAGE_PER_LEVEL_PATH = "effect.demonic_flames.damage_per_level";
|
|
||||||
public static final float DAMAGE_PER_LEVEL_DEFAULT = 2.5f;
|
|
||||||
public static final float DAMAGE_PER_LEVEL_MIN = 0.0f;
|
|
||||||
public static final float DAMAGE_PER_LEVEL_MAX = 8388600.0f;
|
|
||||||
|
|
||||||
public DemonicFlamesEffect() {
|
|
||||||
super(MobEffectCategory.HARMFUL, 0xCC2DC7);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
||||||
@Override
|
@Override
|
||||||
public void onConfigLoad() {
|
public void onConfigLoad() {
|
||||||
ConfigFactory.loadFloatConfig(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);
|
ConfigStruct.loadAll(DAMAGE_PER_LEVEL);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
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 float getDamagePerLevel() {
|
|
||||||
return Math.clamp(ConfigUtil.readFloat(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(
|
public static final ConfigListItem CONFIG_LIST_ITEM = new ConfigListItem(
|
||||||
"demonic_flames",
|
"demonic_flames",
|
||||||
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/mob_effect/demonic_flames.png"),
|
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/mob_effect/demonic_flames.png"),
|
||||||
@@ -55,6 +34,10 @@ public class DemonicFlamesEffect extends MobEffect {
|
|||||||
CONFIG_DATA
|
CONFIG_DATA
|
||||||
);
|
);
|
||||||
|
|
||||||
|
public DemonicFlamesEffect() {
|
||||||
|
super(MobEffectCategory.HARMFUL, 0xCC2DC7);
|
||||||
|
}
|
||||||
|
|
||||||
public static final CircleParticleOptions PARTICLE = new CircleParticleOptions(0.075f, 20, new Vector3f(0.8f, 0.176f, 0.78f));
|
public static final CircleParticleOptions PARTICLE = new CircleParticleOptions(0.075f, 20, new Vector3f(0.8f, 0.176f, 0.78f));
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -69,7 +52,7 @@ public class DemonicFlamesEffect extends MobEffect {
|
|||||||
if(instance != null) {
|
if(instance != null) {
|
||||||
if(entity.tickCount % 4 == 0) {
|
if(entity.tickCount % 4 == 0) {
|
||||||
entity.invulnerableTime = 5;
|
entity.invulnerableTime = 5;
|
||||||
entity.hurt(entity.damageSources().magic(), (float) getDamagePerLevel() * (amplifier + 1));
|
entity.hurt(entity.damageSources().magic(), (float) DAMAGE_PER_LEVEL.get() * (amplifier + 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,20 +3,15 @@ package com.lzxnone.terraria.effect;
|
|||||||
import com.lzxnone.terraria.LzxnoneTerraria;
|
import com.lzxnone.terraria.LzxnoneTerraria;
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.renderer.MultiBufferSource;
|
import net.minecraft.client.renderer.MultiBufferSource;
|
||||||
import net.minecraft.client.renderer.RenderType;
|
import net.minecraft.client.renderer.RenderType;
|
||||||
import net.minecraft.client.renderer.texture.OverlayTexture;
|
import net.minecraft.client.renderer.texture.OverlayTexture;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.world.effect.MobEffectInstance;
|
|
||||||
import net.minecraft.world.entity.LivingEntity;
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
import net.neoforged.api.distmarker.Dist;
|
|
||||||
import net.neoforged.bus.api.SubscribeEvent;
|
import net.neoforged.bus.api.SubscribeEvent;
|
||||||
import net.neoforged.fml.common.EventBusSubscriber;
|
|
||||||
import net.neoforged.neoforge.client.event.RenderLivingEvent;
|
import net.neoforged.neoforge.client.event.RenderLivingEvent;
|
||||||
import org.joml.Matrix4f;
|
import org.joml.Matrix4f;
|
||||||
|
|
||||||
@EventBusSubscriber(modid = LzxnoneTerraria.MODID, value = Dist.CLIENT)
|
|
||||||
public class EffectIconRenderer {
|
public class EffectIconRenderer {
|
||||||
private static final ResourceLocation CONFUSED_ICON =
|
private static final ResourceLocation CONFUSED_ICON =
|
||||||
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/mob_effect_display/confused.png");
|
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/mob_effect_display/confused.png");
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package com.lzxnone.terraria.effect;
|
package com.lzxnone.terraria.effect;
|
||||||
|
|
||||||
import com.lzxnone.terraria.LzxnoneTerraria;
|
|
||||||
import com.lzxnone.terraria.ModSounds;
|
import com.lzxnone.terraria.ModSounds;
|
||||||
import com.lzxnone.terraria.item.weapon.melee.DevilsDevastation;
|
import com.lzxnone.terraria.item.weapon.melee.DevilsDevastation;
|
||||||
import com.lzxnone.terraria.utils.SoundUtil;
|
import com.lzxnone.terraria.utils.SoundUtil;
|
||||||
@@ -12,10 +11,8 @@ import net.minecraft.world.effect.MobEffect;
|
|||||||
import net.minecraft.world.effect.MobEffectInstance;
|
import net.minecraft.world.effect.MobEffectInstance;
|
||||||
import net.minecraft.world.entity.LivingEntity;
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
import net.neoforged.bus.api.SubscribeEvent;
|
import net.neoforged.bus.api.SubscribeEvent;
|
||||||
import net.neoforged.fml.common.EventBusSubscriber;
|
|
||||||
import net.neoforged.neoforge.event.entity.living.MobEffectEvent;
|
import net.neoforged.neoforge.event.entity.living.MobEffectEvent;
|
||||||
|
|
||||||
@EventBusSubscriber(modid = LzxnoneTerraria.MODID)
|
|
||||||
public class EffectLogicHandler {
|
public class EffectLogicHandler {
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
|
|||||||
@@ -1,44 +1,28 @@
|
|||||||
package com.lzxnone.terraria.effect;
|
package com.lzxnone.terraria.effect;
|
||||||
|
|
||||||
import com.lzxnone.terraria.LzxnoneTerraria;
|
import com.lzxnone.terraria.LzxnoneTerraria;
|
||||||
import com.lzxnone.terraria.ui.config.ConfigFactory;
|
|
||||||
import com.lzxnone.terraria.ui.config.ConfigListItem;
|
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.ui.config.IConfigData;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigFloat;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigStruct;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.world.effect.MobEffect;
|
import net.minecraft.world.effect.MobEffect;
|
||||||
import net.minecraft.world.effect.MobEffectCategory;
|
import net.minecraft.world.effect.MobEffectCategory;
|
||||||
|
|
||||||
public class IchorEffect extends MobEffect {
|
public class IchorEffect extends MobEffect {
|
||||||
private static final String CONFIG_TRANSLATION_PREFIX = "lzxnoneterraria.configuration.";
|
public static final ConfigFloat DAMAGE_BONUS_PER_LEVEL = new ConfigFloat("effect.ichor.damage_bonus_per_level", "ichor_damage_bonus_per_level", 0.15f, 0.0f, 10.0f);
|
||||||
|
|
||||||
public static final String DAMAGE_BONUS_PER_LEVEL_PATH = "effect.ichor.damage_bonus_per_level";
|
|
||||||
public static final float DAMAGE_BONUS_PER_LEVEL_DEFAULT = 0.15f;
|
|
||||||
public static final float DAMAGE_BONUS_PER_LEVEL_MIN = 0.0f;
|
|
||||||
public static final float DAMAGE_BONUS_PER_LEVEL_MAX = 10.0f;
|
|
||||||
|
|
||||||
public IchorEffect() {
|
|
||||||
super(MobEffectCategory.HARMFUL, 0xFFFF00);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
||||||
@Override
|
@Override
|
||||||
public void onConfigLoad() {
|
public void onConfigLoad() {
|
||||||
ConfigFactory.loadFloatConfig(DAMAGE_BONUS_PER_LEVEL_PATH, configText("ichor_damage_bonus_per_level"), configTooltip("ichor_damage_bonus_per_level"), DAMAGE_BONUS_PER_LEVEL_DEFAULT, DAMAGE_BONUS_PER_LEVEL_MIN, DAMAGE_BONUS_PER_LEVEL_MAX);
|
ConfigStruct.loadAll(DAMAGE_BONUS_PER_LEVEL);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
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 float getDamageBonusPerLevel() {
|
public static float getDamageBonusPerLevel() {
|
||||||
return Math.clamp(ConfigUtil.readFloat(DAMAGE_BONUS_PER_LEVEL_PATH, DAMAGE_BONUS_PER_LEVEL_DEFAULT), DAMAGE_BONUS_PER_LEVEL_MIN, DAMAGE_BONUS_PER_LEVEL_MAX);
|
return DAMAGE_BONUS_PER_LEVEL.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final ConfigListItem CONFIG_LIST_ITEM = new ConfigListItem(
|
public static final ConfigListItem CONFIG_LIST_ITEM = new ConfigListItem(
|
||||||
@@ -47,4 +31,8 @@ public class IchorEffect extends MobEffect {
|
|||||||
Component.translatable("effect.lzxnoneterraria.ichor"),
|
Component.translatable("effect.lzxnoneterraria.ichor"),
|
||||||
CONFIG_DATA
|
CONFIG_DATA
|
||||||
);
|
);
|
||||||
|
|
||||||
|
public IchorEffect() {
|
||||||
|
super(MobEffectCategory.HARMFUL, 0xFFFF00);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
package com.lzxnone.terraria.effect;
|
||||||
|
|
||||||
|
import com.lzxnone.terraria.attachment.ModAttachments;
|
||||||
|
import com.lzxnone.terraria.attachment.PlayerMana;
|
||||||
|
import com.lzxnone.terraria.event.PlayerManaSyncEventHandler;
|
||||||
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
|
import net.minecraft.world.effect.MobEffect;
|
||||||
|
import net.minecraft.world.effect.MobEffectCategory;
|
||||||
|
import net.minecraft.world.entity.Entity;
|
||||||
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
|
|
||||||
|
public class ManaEffect extends MobEffect {
|
||||||
|
private static final int[] RECOVER_AMOUNTS = {50, 100, 200, 300};
|
||||||
|
|
||||||
|
public ManaEffect() {
|
||||||
|
super(MobEffectCategory.BENEFICIAL, 0x00D7FF);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isInstantenous() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void applyInstantenousEffect(Entity source, Entity indirectSource, LivingEntity livingEntity, int amplifier, double health) {
|
||||||
|
if(!(livingEntity instanceof ServerPlayer player)) return;
|
||||||
|
|
||||||
|
PlayerMana mana = player.getData(ModAttachments.PLAYER_MANA);
|
||||||
|
int oldMana = mana.getMana();
|
||||||
|
mana.recoverManaImmediately(getRecoverAmount(amplifier));
|
||||||
|
ManaSicknessEffect.applyTo(player);
|
||||||
|
player.setData(ModAttachments.PLAYER_MANA, mana);
|
||||||
|
if(mana.getMana() != oldMana) {
|
||||||
|
PlayerManaSyncEventHandler.sync(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getRecoverAmount(int amplifier) {
|
||||||
|
int index = Math.clamp(amplifier, 0, RECOVER_AMOUNTS.length - 1);
|
||||||
|
return RECOVER_AMOUNTS[index];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
package com.lzxnone.terraria.effect;
|
||||||
|
|
||||||
|
import com.lzxnone.terraria.LzxnoneTerraria;
|
||||||
|
import com.lzxnone.terraria.ui.config.ConfigListItem;
|
||||||
|
import com.lzxnone.terraria.ui.config.IConfigData;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigFloat;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigInt;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigStruct;
|
||||||
|
import net.minecraft.network.chat.Component;
|
||||||
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
import net.minecraft.world.effect.MobEffect;
|
||||||
|
import net.minecraft.world.effect.MobEffectCategory;
|
||||||
|
import net.minecraft.world.effect.MobEffectInstance;
|
||||||
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
|
|
||||||
|
public class ManaSicknessEffect extends MobEffect {
|
||||||
|
public static final ConfigInt DURATION_PER_USE = new ConfigInt("effect.mana_sickness.duration_per_use", "mana_sickness_duration_per_use", 100, 0, 1200);
|
||||||
|
public static final ConfigInt MAX_DURATION = new ConfigInt("effect.mana_sickness.max_duration", "mana_sickness_max_duration", 200, 0, 2400);
|
||||||
|
public static final ConfigFloat MAX_DAMAGE_REDUCTION = new ConfigFloat("effect.mana_sickness.max_damage_reduction", "mana_sickness_max_damage_reduction", 0.5F, 0.0F, 1.0F);
|
||||||
|
|
||||||
|
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
||||||
|
@Override
|
||||||
|
public void onConfigLoad() {
|
||||||
|
ConfigStruct.loadAll(DURATION_PER_USE, MAX_DURATION, MAX_DAMAGE_REDUCTION);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
public static final ConfigListItem CONFIG_LIST_ITEM = new ConfigListItem(
|
||||||
|
"mana_sickness",
|
||||||
|
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/mob_effect/mana_sickness.png"),
|
||||||
|
Component.translatable("effect.lzxnoneterraria.mana_sickness"),
|
||||||
|
CONFIG_DATA
|
||||||
|
);
|
||||||
|
|
||||||
|
public ManaSicknessEffect() {
|
||||||
|
super(MobEffectCategory.HARMFUL, 0x2BC4D8);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void applyTo(LivingEntity entity) {
|
||||||
|
int durationPerUse = DURATION_PER_USE.get();
|
||||||
|
int maxDuration = MAX_DURATION.get();
|
||||||
|
if(durationPerUse <= 0 || maxDuration <= 0) return;
|
||||||
|
|
||||||
|
MobEffectInstance current = entity.getEffect(ModEffects.MANA_SICKNESS);
|
||||||
|
int duration = Math.min(maxDuration, durationPerUse);
|
||||||
|
if(current != null) {
|
||||||
|
duration = Math.min(maxDuration, current.getDuration() + durationPerUse);
|
||||||
|
}
|
||||||
|
entity.addEffect(new MobEffectInstance(ModEffects.MANA_SICKNESS, duration, 0, false, true, true));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static float getMagicDamageMultiplier(LivingEntity entity) {
|
||||||
|
MobEffectInstance instance = entity.getEffect(ModEffects.MANA_SICKNESS);
|
||||||
|
if(instance == null) return 1.0F;
|
||||||
|
|
||||||
|
int maxDuration = MAX_DURATION.get();
|
||||||
|
if(maxDuration <= 0) return 1.0F;
|
||||||
|
|
||||||
|
float durationRatio = Math.min(1.0F, (float) instance.getDuration() / maxDuration);
|
||||||
|
float reduction = Math.min(1.0F, MAX_DAMAGE_REDUCTION.get()) * durationRatio;
|
||||||
|
return Math.max(0.0F, 1.0F - reduction);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,44 +1,27 @@
|
|||||||
package com.lzxnone.terraria.effect;
|
package com.lzxnone.terraria.effect;
|
||||||
|
|
||||||
import com.lzxnone.terraria.LzxnoneTerraria;
|
import com.lzxnone.terraria.LzxnoneTerraria;
|
||||||
import com.lzxnone.terraria.ui.config.ConfigFactory;
|
|
||||||
import com.lzxnone.terraria.ui.config.ConfigListItem;
|
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.ui.config.IConfigData;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigFloat;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigStruct;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.world.effect.MobEffect;
|
import net.minecraft.world.effect.MobEffect;
|
||||||
import net.minecraft.world.effect.MobEffectCategory;
|
import net.minecraft.world.effect.MobEffectCategory;
|
||||||
|
|
||||||
public class MidasEffect extends MobEffect {
|
public class MidasEffect extends MobEffect {
|
||||||
private static final String CONFIG_TRANSLATION_PREFIX = "lzxnoneterraria.configuration.";
|
public static final ConfigFloat DROP_CHANCE = new ConfigFloat("effect.midas.drop_chance", "midas_drop_chance", 0.25f, 0.0f, 1.0f);
|
||||||
|
|
||||||
public static final String DROP_CHANCE_PATH = "effect.midas.drop_chance";
|
|
||||||
public static final float DROP_CHANCE_DEFAULT = 0.25f;
|
|
||||||
public static final float DROP_CHANCE_MIN = 0.0f;
|
|
||||||
public static final float DROP_CHANCE_MAX = 1.0f;
|
|
||||||
|
|
||||||
public MidasEffect() {
|
|
||||||
super(MobEffectCategory.HARMFUL, 0xFFD700);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
||||||
@Override
|
@Override
|
||||||
public void onConfigLoad() {
|
public void onConfigLoad() {
|
||||||
ConfigFactory.loadFloatConfig(DROP_CHANCE_PATH, configText("midas_drop_chance"), configTooltip("midas_drop_chance"), DROP_CHANCE_DEFAULT, DROP_CHANCE_MIN, DROP_CHANCE_MAX);
|
ConfigStruct.loadAll(DROP_CHANCE);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
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 float getDropChance() {
|
public static float getDropChance() {
|
||||||
return Math.clamp(ConfigUtil.readFloat(DROP_CHANCE_PATH, DROP_CHANCE_DEFAULT), DROP_CHANCE_MIN, DROP_CHANCE_MAX);
|
return DROP_CHANCE.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final ConfigListItem CONFIG_LIST_ITEM = new ConfigListItem(
|
public static final ConfigListItem CONFIG_LIST_ITEM = new ConfigListItem(
|
||||||
@@ -47,4 +30,9 @@ public class MidasEffect extends MobEffect {
|
|||||||
Component.translatable("effect.lzxnoneterraria.midas"),
|
Component.translatable("effect.lzxnoneterraria.midas"),
|
||||||
CONFIG_DATA
|
CONFIG_DATA
|
||||||
);
|
);
|
||||||
|
|
||||||
|
public MidasEffect() {
|
||||||
|
super(MobEffectCategory.HARMFUL, 0xFFD700);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -28,6 +28,10 @@ public class ModEffects {
|
|||||||
MOB_EFFECTS.register("acid_venom", AcidVenomEffect::new);
|
MOB_EFFECTS.register("acid_venom", AcidVenomEffect::new);
|
||||||
public static final DeferredHolder<MobEffect, SummonEffect> SUMMON =
|
public static final DeferredHolder<MobEffect, SummonEffect> SUMMON =
|
||||||
MOB_EFFECTS.register("summon", SummonEffect::new);
|
MOB_EFFECTS.register("summon", SummonEffect::new);
|
||||||
|
public static final DeferredHolder<MobEffect, ManaEffect> MANA =
|
||||||
|
MOB_EFFECTS.register("mana", ManaEffect::new);
|
||||||
|
public static final DeferredHolder<MobEffect, ManaSicknessEffect> MANA_SICKNESS =
|
||||||
|
MOB_EFFECTS.register("mana_sickness", ManaSicknessEffect::new);
|
||||||
public static final DeferredHolder<MobEffect, MidasEffect> MIDAS =
|
public static final DeferredHolder<MobEffect, MidasEffect> MIDAS =
|
||||||
MOB_EFFECTS.register("midas", MidasEffect::new);
|
MOB_EFFECTS.register("midas", MidasEffect::new);
|
||||||
}
|
}
|
||||||
@@ -41,8 +41,20 @@ public class ModPotions {
|
|||||||
registerSummonPotion("medium_summon_4", 36000, 4);
|
registerSummonPotion("medium_summon_4", 36000, 4);
|
||||||
public static final DeferredHolder<Potion, Potion> LONG_SUMMON_4 =
|
public static final DeferredHolder<Potion, Potion> LONG_SUMMON_4 =
|
||||||
registerSummonPotion("long_summon_4", 216000, 4);
|
registerSummonPotion("long_summon_4", 216000, 4);
|
||||||
|
public static final DeferredHolder<Potion, Potion> MANA_0 =
|
||||||
|
registerManaPotion("mana_0", 0);
|
||||||
|
public static final DeferredHolder<Potion, Potion> MANA_1 =
|
||||||
|
registerManaPotion("mana_1", 1);
|
||||||
|
public static final DeferredHolder<Potion, Potion> MANA_2 =
|
||||||
|
registerManaPotion("mana_2", 2);
|
||||||
|
public static final DeferredHolder<Potion, Potion> MANA_3 =
|
||||||
|
registerManaPotion("mana_3", 3);
|
||||||
|
|
||||||
private static DeferredHolder<Potion, Potion> registerSummonPotion(String name, int duration, int amplifier) {
|
private static DeferredHolder<Potion, Potion> registerSummonPotion(String name, int duration, int amplifier) {
|
||||||
return POTIONS.register(name, () -> new Potion("summon", new MobEffectInstance(ModEffects.SUMMON, duration, amplifier)));
|
return POTIONS.register(name, () -> new Potion("summon", new MobEffectInstance(ModEffects.SUMMON, duration, amplifier)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static DeferredHolder<Potion, Potion> registerManaPotion(String name, int amplifier) {
|
||||||
|
return POTIONS.register(name, () -> new Potion("mana", new MobEffectInstance(ModEffects.MANA, 1, amplifier)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,44 +1,27 @@
|
|||||||
package com.lzxnone.terraria.effect;
|
package com.lzxnone.terraria.effect;
|
||||||
|
|
||||||
import com.lzxnone.terraria.LzxnoneTerraria;
|
import com.lzxnone.terraria.LzxnoneTerraria;
|
||||||
import com.lzxnone.terraria.ui.config.ConfigFactory;
|
|
||||||
import com.lzxnone.terraria.ui.config.ConfigListItem;
|
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.ui.config.IConfigData;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigInt;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigStruct;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.world.effect.MobEffect;
|
import net.minecraft.world.effect.MobEffect;
|
||||||
import net.minecraft.world.effect.MobEffectCategory;
|
import net.minecraft.world.effect.MobEffectCategory;
|
||||||
|
|
||||||
public class SummonEffect extends MobEffect {
|
public class SummonEffect extends MobEffect {
|
||||||
private static final String CONFIG_TRANSLATION_PREFIX = "lzxnoneterraria.configuration.";
|
public static final ConfigInt SUMMON_COUNT_PER_LEVEL = new ConfigInt("effect.summon.summon_count_per_level", "summon_summon_count_per_level", 1, 0, 10);
|
||||||
|
|
||||||
public static final String SUMMON_COUNT_PER_LEVEL_PATH = "effect.summon.summon_count_per_level";
|
|
||||||
public static final int SUMMON_COUNT_PER_LEVEL_DEFAULT = 1;
|
|
||||||
public static final int SUMMON_COUNT_PER_LEVEL_MIN = 0;
|
|
||||||
public static final int SUMMON_COUNT_PER_LEVEL_MAX = 10;
|
|
||||||
|
|
||||||
public SummonEffect() {
|
|
||||||
super(MobEffectCategory.BENEFICIAL, 0x34D95A);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
||||||
@Override
|
@Override
|
||||||
public void onConfigLoad() {
|
public void onConfigLoad() {
|
||||||
ConfigFactory.loadIntConfig(SUMMON_COUNT_PER_LEVEL_PATH, configText("summon_summon_count_per_level"), configTooltip("summon_summon_count_per_level"), SUMMON_COUNT_PER_LEVEL_DEFAULT, SUMMON_COUNT_PER_LEVEL_MIN, SUMMON_COUNT_PER_LEVEL_MAX);
|
ConfigStruct.loadAll(SUMMON_COUNT_PER_LEVEL);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
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 getSummonCountPerLevel() {
|
public static int getSummonCountPerLevel() {
|
||||||
return Math.clamp(ConfigUtil.readInt(SUMMON_COUNT_PER_LEVEL_PATH, SUMMON_COUNT_PER_LEVEL_DEFAULT), SUMMON_COUNT_PER_LEVEL_MIN, SUMMON_COUNT_PER_LEVEL_MAX);
|
return SUMMON_COUNT_PER_LEVEL.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final ConfigListItem CONFIG_LIST_ITEM = new ConfigListItem(
|
public static final ConfigListItem CONFIG_LIST_ITEM = new ConfigListItem(
|
||||||
@@ -47,4 +30,8 @@ public class SummonEffect extends MobEffect {
|
|||||||
Component.translatable("effect.lzxnoneterraria.summon"),
|
Component.translatable("effect.lzxnoneterraria.summon"),
|
||||||
CONFIG_DATA
|
CONFIG_DATA
|
||||||
);
|
);
|
||||||
|
|
||||||
|
public SummonEffect() {
|
||||||
|
super(MobEffectCategory.BENEFICIAL, 0x34D95A);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,165 +1,110 @@
|
|||||||
package com.lzxnone.terraria.enchantment;
|
package com.lzxnone.terraria.enchantment;
|
||||||
|
|
||||||
import com.lzxnone.terraria.LzxnoneTerraria;
|
import com.lzxnone.terraria.LzxnoneTerraria;
|
||||||
import com.lzxnone.terraria.ui.config.ConfigFactory;
|
|
||||||
import com.lzxnone.terraria.ui.config.ConfigListItem;
|
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.ui.config.IConfigData;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigDouble;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigInt;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
|
||||||
public class ModEnchantmentConfigs {
|
public class ModEnchantmentConfigs {
|
||||||
private static final String CONFIG_TRANSLATION_PREFIX = "lzxnoneterraria.configuration.";
|
|
||||||
private static final ResourceLocation ICON = ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/ui/nav_enchantment_icon.png");
|
private static final ResourceLocation ICON = ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/ui/nav_enchantment_icon.png");
|
||||||
|
|
||||||
public static final String MANA_LEAK_CONSUME_MULTIPLIER_PATH = "enchantment.mana_leak.consume_multiplier";
|
public static final ConfigDouble MANA_LEAK_CONSUME_MULTIPLIER = new ConfigDouble("enchantment.mana_leak.consume_multiplier", "mana_leak_consume_multiplier", 1.25D, 0.0D, 10.0D);
|
||||||
public static final double MANA_LEAK_CONSUME_MULTIPLIER_DEFAULT = 1.25D;
|
|
||||||
public static final double MANA_LEAK_CONSUME_MULTIPLIER_MIN = 0.0D;
|
|
||||||
public static final double MANA_LEAK_CONSUME_MULTIPLIER_MAX = 10.0D;
|
|
||||||
|
|
||||||
public static final String MANA_EFFICIENCY_CONSUME_MULTIPLIER_PATH = "enchantment.mana_efficiency.consume_multiplier";
|
public static final ConfigDouble MANA_EFFICIENCY_CONSUME_MULTIPLIER = new ConfigDouble("enchantment.mana_efficiency.consume_multiplier", "mana_efficiency_consume_multiplier", 0.85D, 0.0D, 10.0D);
|
||||||
public static final double MANA_EFFICIENCY_CONSUME_MULTIPLIER_DEFAULT = 0.85D;
|
|
||||||
public static final double MANA_EFFICIENCY_CONSUME_MULTIPLIER_MIN = 0.0D;
|
|
||||||
public static final double MANA_EFFICIENCY_CONSUME_MULTIPLIER_MAX = 10.0D;
|
|
||||||
|
|
||||||
public static final String MANA_GATHERING_RECOVER_MULTIPLIER_PATH = "enchantment.mana_gathering.recover_multiplier";
|
public static final ConfigDouble ARCANE_AMPLIFICATION_DAMAGE_MULTIPLIER = new ConfigDouble("enchantment.arcane_amplification.damage_multiplier", "arcane_amplification_damage_multiplier", 1.15D, 0.0D, 10.0D);
|
||||||
public static final double MANA_GATHERING_RECOVER_MULTIPLIER_DEFAULT = 1.25D;
|
|
||||||
public static final double MANA_GATHERING_RECOVER_MULTIPLIER_MIN = 0.0D;
|
|
||||||
public static final double MANA_GATHERING_RECOVER_MULTIPLIER_MAX = 10.0D;
|
|
||||||
|
|
||||||
public static final String MANA_GATHERING_CURSE_RECOVER_MULTIPLIER_PATH = "enchantment.mana_gathering_curse.recover_multiplier";
|
public static final ConfigDouble SUMMON_AMPLIFICATION_DAMAGE_MULTIPLIER = new ConfigDouble("enchantment.summon_amplification.damage_multiplier", "summon_amplification_damage_multiplier", 1.15D, 0.0D, 10.0D);
|
||||||
public static final double MANA_GATHERING_CURSE_RECOVER_MULTIPLIER_DEFAULT = 0.5D;
|
|
||||||
public static final double MANA_GATHERING_CURSE_RECOVER_MULTIPLIER_MIN = 0.0D;
|
|
||||||
public static final double MANA_GATHERING_CURSE_RECOVER_MULTIPLIER_MAX = 10.0D;
|
|
||||||
|
|
||||||
public static final String ARCANE_AMPLIFICATION_DAMAGE_MULTIPLIER_PATH = "enchantment.arcane_amplification.damage_multiplier";
|
public static final ConfigInt AMMO_EXHAUSTION_CONSUME_BONUS = new ConfigInt("enchantment.ammo_exhaustion.consume_bonus", "ammo_exhaustion_consume_bonus", 1, 0, 1024);
|
||||||
public static final double ARCANE_AMPLIFICATION_DAMAGE_MULTIPLIER_DEFAULT = 1.15D;
|
|
||||||
public static final double ARCANE_AMPLIFICATION_DAMAGE_MULTIPLIER_MIN = 0.0D;
|
|
||||||
public static final double ARCANE_AMPLIFICATION_DAMAGE_MULTIPLIER_MAX = 10.0D;
|
|
||||||
|
|
||||||
public static final String SUMMON_AMPLIFICATION_DAMAGE_MULTIPLIER_PATH = "enchantment.summon_amplification.damage_multiplier";
|
public static final ConfigDouble BULLET_HELL_NOT_CONSUME_CHANCE = new ConfigDouble("enchantment.bullet_hell.not_consume_chance", "bullet_hell_not_consume_chance", 0.5D, 0.0D, 1.0D);
|
||||||
public static final double SUMMON_AMPLIFICATION_DAMAGE_MULTIPLIER_DEFAULT = 1.15D;
|
|
||||||
public static final double SUMMON_AMPLIFICATION_DAMAGE_MULTIPLIER_MIN = 0.0D;
|
|
||||||
public static final double SUMMON_AMPLIFICATION_DAMAGE_MULTIPLIER_MAX = 10.0D;
|
|
||||||
|
|
||||||
public static final String AMMO_EXHAUSTION_CONSUME_BONUS_PATH = "enchantment.ammo_exhaustion.consume_bonus";
|
public static final ConfigDouble GUNPOWDER_DAMAGE_MULTIPLIER = new ConfigDouble("enchantment.gunpowder.damage_multiplier", "gunpowder_damage_multiplier", 1.15D, 0.0D, 10.0D);
|
||||||
public static final int AMMO_EXHAUSTION_CONSUME_BONUS_DEFAULT = 1;
|
|
||||||
public static final int AMMO_EXHAUSTION_CONSUME_BONUS_MIN = 0;
|
|
||||||
public static final int AMMO_EXHAUSTION_CONSUME_BONUS_MAX = 1024;
|
|
||||||
|
|
||||||
public static final String BULLET_HELL_NOT_CONSUME_CHANCE_PATH = "enchantment.bullet_hell.not_consume_chance";
|
public static final ConfigDouble STEADY_BREATH_SPREAD_MULTIPLIER = new ConfigDouble("enchantment.steady_breath.spread_multiplier", "steady_breath_spread_multiplier", 0.5D, 0.0D, 10.0D);
|
||||||
public static final double BULLET_HELL_NOT_CONSUME_CHANCE_DEFAULT = 0.5D;
|
|
||||||
public static final double BULLET_HELL_NOT_CONSUME_CHANCE_MIN = 0.0D;
|
|
||||||
public static final double BULLET_HELL_NOT_CONSUME_CHANCE_MAX = 1.0D;
|
|
||||||
|
|
||||||
public static final String GUNPOWDER_DAMAGE_MULTIPLIER_PATH = "enchantment.gunpowder.damage_multiplier";
|
|
||||||
public static final double GUNPOWDER_DAMAGE_MULTIPLIER_DEFAULT = 1.15D;
|
|
||||||
public static final double GUNPOWDER_DAMAGE_MULTIPLIER_MIN = 0.0D;
|
|
||||||
public static final double GUNPOWDER_DAMAGE_MULTIPLIER_MAX = 10.0D;
|
|
||||||
|
|
||||||
public static final String STEADY_BREATH_SPREAD_MULTIPLIER_PATH = "enchantment.steady_breath.spread_multiplier";
|
|
||||||
public static final double STEADY_BREATH_SPREAD_MULTIPLIER_DEFAULT = 0.5D;
|
|
||||||
public static final double STEADY_BREATH_SPREAD_MULTIPLIER_MIN = 0.0D;
|
|
||||||
public static final double STEADY_BREATH_SPREAD_MULTIPLIER_MAX = 10.0D;
|
|
||||||
|
|
||||||
public static final ConfigListItem MANA_LEAK_CONFIG_LIST_ITEM = createConfigListItem(
|
public static final ConfigListItem MANA_LEAK_CONFIG_LIST_ITEM = createConfigListItem(
|
||||||
"mana_leak",
|
"mana_leak",
|
||||||
"enchantment.lzxnoneterraria.mana_leak",
|
"enchantment.lzxnoneterraria.mana_leak",
|
||||||
() -> ConfigFactory.loadDoubleConfig(MANA_LEAK_CONSUME_MULTIPLIER_PATH, configText("mana_leak_consume_multiplier"), configTooltip("mana_leak_consume_multiplier"), MANA_LEAK_CONSUME_MULTIPLIER_DEFAULT, MANA_LEAK_CONSUME_MULTIPLIER_MIN, MANA_LEAK_CONSUME_MULTIPLIER_MAX)
|
() -> MANA_LEAK_CONSUME_MULTIPLIER.load()
|
||||||
);
|
);
|
||||||
|
|
||||||
public static final ConfigListItem MANA_EFFICIENCY_CONFIG_LIST_ITEM = createConfigListItem(
|
public static final ConfigListItem MANA_EFFICIENCY_CONFIG_LIST_ITEM = createConfigListItem(
|
||||||
"mana_efficiency",
|
"mana_efficiency",
|
||||||
"enchantment.lzxnoneterraria.mana_efficiency",
|
"enchantment.lzxnoneterraria.mana_efficiency",
|
||||||
() -> ConfigFactory.loadDoubleConfig(MANA_EFFICIENCY_CONSUME_MULTIPLIER_PATH, configText("mana_efficiency_consume_multiplier"), configTooltip("mana_efficiency_consume_multiplier"), MANA_EFFICIENCY_CONSUME_MULTIPLIER_DEFAULT, MANA_EFFICIENCY_CONSUME_MULTIPLIER_MIN, MANA_EFFICIENCY_CONSUME_MULTIPLIER_MAX)
|
() -> MANA_EFFICIENCY_CONSUME_MULTIPLIER.load()
|
||||||
);
|
|
||||||
|
|
||||||
public static final ConfigListItem MANA_GATHERING_CONFIG_LIST_ITEM = createConfigListItem(
|
|
||||||
"mana_gathering",
|
|
||||||
"enchantment.lzxnoneterraria.mana_gathering",
|
|
||||||
() -> ConfigFactory.loadDoubleConfig(MANA_GATHERING_RECOVER_MULTIPLIER_PATH, configText("mana_gathering_recover_multiplier"), configTooltip("mana_gathering_recover_multiplier"), MANA_GATHERING_RECOVER_MULTIPLIER_DEFAULT, MANA_GATHERING_RECOVER_MULTIPLIER_MIN, MANA_GATHERING_RECOVER_MULTIPLIER_MAX)
|
|
||||||
);
|
|
||||||
|
|
||||||
public static final ConfigListItem MANA_GATHERING_CURSE_CONFIG_LIST_ITEM = createConfigListItem(
|
|
||||||
"mana_gathering_curse",
|
|
||||||
"enchantment.lzxnoneterraria.mana_gathering_curse",
|
|
||||||
() -> ConfigFactory.loadDoubleConfig(MANA_GATHERING_CURSE_RECOVER_MULTIPLIER_PATH, configText("mana_gathering_curse_recover_multiplier"), configTooltip("mana_gathering_curse_recover_multiplier"), MANA_GATHERING_CURSE_RECOVER_MULTIPLIER_DEFAULT, MANA_GATHERING_CURSE_RECOVER_MULTIPLIER_MIN, MANA_GATHERING_CURSE_RECOVER_MULTIPLIER_MAX)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
public static final ConfigListItem ARCANE_AMPLIFICATION_CONFIG_LIST_ITEM = createConfigListItem(
|
public static final ConfigListItem ARCANE_AMPLIFICATION_CONFIG_LIST_ITEM = createConfigListItem(
|
||||||
"arcane_amplification",
|
"arcane_amplification",
|
||||||
"enchantment.lzxnoneterraria.arcane_amplification",
|
"enchantment.lzxnoneterraria.arcane_amplification",
|
||||||
() -> ConfigFactory.loadDoubleConfig(ARCANE_AMPLIFICATION_DAMAGE_MULTIPLIER_PATH, configText("arcane_amplification_damage_multiplier"), configTooltip("arcane_amplification_damage_multiplier"), ARCANE_AMPLIFICATION_DAMAGE_MULTIPLIER_DEFAULT, ARCANE_AMPLIFICATION_DAMAGE_MULTIPLIER_MIN, ARCANE_AMPLIFICATION_DAMAGE_MULTIPLIER_MAX)
|
() -> ARCANE_AMPLIFICATION_DAMAGE_MULTIPLIER.load()
|
||||||
);
|
);
|
||||||
|
|
||||||
public static final ConfigListItem SUMMON_AMPLIFICATION_CONFIG_LIST_ITEM = createConfigListItem(
|
public static final ConfigListItem SUMMON_AMPLIFICATION_CONFIG_LIST_ITEM = createConfigListItem(
|
||||||
"summon_amplification",
|
"summon_amplification",
|
||||||
"enchantment.lzxnoneterraria.summon_amplification",
|
"enchantment.lzxnoneterraria.summon_amplification",
|
||||||
() -> ConfigFactory.loadDoubleConfig(SUMMON_AMPLIFICATION_DAMAGE_MULTIPLIER_PATH, configText("summon_amplification_damage_multiplier"), configTooltip("summon_amplification_damage_multiplier"), SUMMON_AMPLIFICATION_DAMAGE_MULTIPLIER_DEFAULT, SUMMON_AMPLIFICATION_DAMAGE_MULTIPLIER_MIN, SUMMON_AMPLIFICATION_DAMAGE_MULTIPLIER_MAX)
|
() -> SUMMON_AMPLIFICATION_DAMAGE_MULTIPLIER.load()
|
||||||
);
|
);
|
||||||
|
|
||||||
public static final ConfigListItem AMMO_EXHAUSTION_CONFIG_LIST_ITEM = createConfigListItem(
|
public static final ConfigListItem AMMO_EXHAUSTION_CONFIG_LIST_ITEM = createConfigListItem(
|
||||||
"ammo_exhaustion",
|
"ammo_exhaustion",
|
||||||
"enchantment.lzxnoneterraria.ammo_exhaustion",
|
"enchantment.lzxnoneterraria.ammo_exhaustion",
|
||||||
() -> ConfigFactory.loadIntConfig(AMMO_EXHAUSTION_CONSUME_BONUS_PATH, configText("ammo_exhaustion_consume_bonus"), configTooltip("ammo_exhaustion_consume_bonus"), AMMO_EXHAUSTION_CONSUME_BONUS_DEFAULT, AMMO_EXHAUSTION_CONSUME_BONUS_MIN, AMMO_EXHAUSTION_CONSUME_BONUS_MAX)
|
() -> AMMO_EXHAUSTION_CONSUME_BONUS.load()
|
||||||
);
|
);
|
||||||
|
|
||||||
public static final ConfigListItem BULLET_HELL_CONFIG_LIST_ITEM = createConfigListItem(
|
public static final ConfigListItem BULLET_HELL_CONFIG_LIST_ITEM = createConfigListItem(
|
||||||
"bullet_hell",
|
"bullet_hell",
|
||||||
"enchantment.lzxnoneterraria.bullet_hell",
|
"enchantment.lzxnoneterraria.bullet_hell",
|
||||||
() -> ConfigFactory.loadDoubleConfig(BULLET_HELL_NOT_CONSUME_CHANCE_PATH, configText("bullet_hell_not_consume_chance"), configTooltip("bullet_hell_not_consume_chance"), BULLET_HELL_NOT_CONSUME_CHANCE_DEFAULT, BULLET_HELL_NOT_CONSUME_CHANCE_MIN, BULLET_HELL_NOT_CONSUME_CHANCE_MAX)
|
() -> BULLET_HELL_NOT_CONSUME_CHANCE.load()
|
||||||
);
|
);
|
||||||
|
|
||||||
public static final ConfigListItem GUNPOWDER_CONFIG_LIST_ITEM = createConfigListItem(
|
public static final ConfigListItem GUNPOWDER_CONFIG_LIST_ITEM = createConfigListItem(
|
||||||
"gunpowder",
|
"gunpowder",
|
||||||
"enchantment.lzxnoneterraria.gunpowder",
|
"enchantment.lzxnoneterraria.gunpowder",
|
||||||
() -> ConfigFactory.loadDoubleConfig(GUNPOWDER_DAMAGE_MULTIPLIER_PATH, configText("gunpowder_damage_multiplier"), configTooltip("gunpowder_damage_multiplier"), GUNPOWDER_DAMAGE_MULTIPLIER_DEFAULT, GUNPOWDER_DAMAGE_MULTIPLIER_MIN, GUNPOWDER_DAMAGE_MULTIPLIER_MAX)
|
() -> GUNPOWDER_DAMAGE_MULTIPLIER.load()
|
||||||
);
|
);
|
||||||
|
|
||||||
public static final ConfigListItem STEADY_BREATH_CONFIG_LIST_ITEM = createConfigListItem(
|
public static final ConfigListItem STEADY_BREATH_CONFIG_LIST_ITEM = createConfigListItem(
|
||||||
"steady_breath",
|
"steady_breath",
|
||||||
"enchantment.lzxnoneterraria.steady_breath",
|
"enchantment.lzxnoneterraria.steady_breath",
|
||||||
() -> ConfigFactory.loadDoubleConfig(STEADY_BREATH_SPREAD_MULTIPLIER_PATH, configText("steady_breath_spread_multiplier"), configTooltip("steady_breath_spread_multiplier"), STEADY_BREATH_SPREAD_MULTIPLIER_DEFAULT, STEADY_BREATH_SPREAD_MULTIPLIER_MIN, STEADY_BREATH_SPREAD_MULTIPLIER_MAX)
|
() -> STEADY_BREATH_SPREAD_MULTIPLIER.load()
|
||||||
);
|
);
|
||||||
|
|
||||||
public static double getManaLeakConsumeMultiplier() {
|
public static double getManaLeakConsumeMultiplier() {
|
||||||
return readDouble(MANA_LEAK_CONSUME_MULTIPLIER_PATH, MANA_LEAK_CONSUME_MULTIPLIER_DEFAULT, MANA_LEAK_CONSUME_MULTIPLIER_MIN, MANA_LEAK_CONSUME_MULTIPLIER_MAX);
|
return MANA_LEAK_CONSUME_MULTIPLIER.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double getManaEfficiencyConsumeMultiplier() {
|
public static double getManaEfficiencyConsumeMultiplier() {
|
||||||
return readDouble(MANA_EFFICIENCY_CONSUME_MULTIPLIER_PATH, MANA_EFFICIENCY_CONSUME_MULTIPLIER_DEFAULT, MANA_EFFICIENCY_CONSUME_MULTIPLIER_MIN, MANA_EFFICIENCY_CONSUME_MULTIPLIER_MAX);
|
return MANA_EFFICIENCY_CONSUME_MULTIPLIER.get();
|
||||||
}
|
|
||||||
|
|
||||||
public static double getManaGatheringRecoverMultiplier() {
|
|
||||||
return readDouble(MANA_GATHERING_RECOVER_MULTIPLIER_PATH, MANA_GATHERING_RECOVER_MULTIPLIER_DEFAULT, MANA_GATHERING_RECOVER_MULTIPLIER_MIN, MANA_GATHERING_RECOVER_MULTIPLIER_MAX);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static double getManaGatheringCurseRecoverMultiplier() {
|
|
||||||
return readDouble(MANA_GATHERING_CURSE_RECOVER_MULTIPLIER_PATH, MANA_GATHERING_CURSE_RECOVER_MULTIPLIER_DEFAULT, MANA_GATHERING_CURSE_RECOVER_MULTIPLIER_MIN, MANA_GATHERING_CURSE_RECOVER_MULTIPLIER_MAX);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double getArcaneAmplificationDamageMultiplier() {
|
public static double getArcaneAmplificationDamageMultiplier() {
|
||||||
return readDouble(ARCANE_AMPLIFICATION_DAMAGE_MULTIPLIER_PATH, ARCANE_AMPLIFICATION_DAMAGE_MULTIPLIER_DEFAULT, ARCANE_AMPLIFICATION_DAMAGE_MULTIPLIER_MIN, ARCANE_AMPLIFICATION_DAMAGE_MULTIPLIER_MAX);
|
return ARCANE_AMPLIFICATION_DAMAGE_MULTIPLIER.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double getSummonAmplificationDamageMultiplier() {
|
public static double getSummonAmplificationDamageMultiplier() {
|
||||||
return readDouble(SUMMON_AMPLIFICATION_DAMAGE_MULTIPLIER_PATH, SUMMON_AMPLIFICATION_DAMAGE_MULTIPLIER_DEFAULT, SUMMON_AMPLIFICATION_DAMAGE_MULTIPLIER_MIN, SUMMON_AMPLIFICATION_DAMAGE_MULTIPLIER_MAX);
|
return SUMMON_AMPLIFICATION_DAMAGE_MULTIPLIER.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getAmmoExhaustionConsumeBonus() {
|
public static int getAmmoExhaustionConsumeBonus() {
|
||||||
return Math.clamp(ConfigUtil.readInt(AMMO_EXHAUSTION_CONSUME_BONUS_PATH, AMMO_EXHAUSTION_CONSUME_BONUS_DEFAULT), AMMO_EXHAUSTION_CONSUME_BONUS_MIN, AMMO_EXHAUSTION_CONSUME_BONUS_MAX);
|
return AMMO_EXHAUSTION_CONSUME_BONUS.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double getBulletHellNotConsumeChance() {
|
public static double getBulletHellNotConsumeChance() {
|
||||||
return readDouble(BULLET_HELL_NOT_CONSUME_CHANCE_PATH, BULLET_HELL_NOT_CONSUME_CHANCE_DEFAULT, BULLET_HELL_NOT_CONSUME_CHANCE_MIN, BULLET_HELL_NOT_CONSUME_CHANCE_MAX);
|
return BULLET_HELL_NOT_CONSUME_CHANCE.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double getGunpowderDamageMultiplier() {
|
public static double getGunpowderDamageMultiplier() {
|
||||||
return readDouble(GUNPOWDER_DAMAGE_MULTIPLIER_PATH, GUNPOWDER_DAMAGE_MULTIPLIER_DEFAULT, GUNPOWDER_DAMAGE_MULTIPLIER_MIN, GUNPOWDER_DAMAGE_MULTIPLIER_MAX);
|
return GUNPOWDER_DAMAGE_MULTIPLIER.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double getSteadyBreathSpreadMultiplier() {
|
public static double getSteadyBreathSpreadMultiplier() {
|
||||||
return readDouble(STEADY_BREATH_SPREAD_MULTIPLIER_PATH, STEADY_BREATH_SPREAD_MULTIPLIER_DEFAULT, STEADY_BREATH_SPREAD_MULTIPLIER_MIN, STEADY_BREATH_SPREAD_MULTIPLIER_MAX);
|
return STEADY_BREATH_SPREAD_MULTIPLIER.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ConfigListItem createConfigListItem(String id, String nameKey, Runnable loader) {
|
private static ConfigListItem createConfigListItem(String id, String nameKey, Runnable loader) {
|
||||||
@@ -171,15 +116,5 @@ public class ModEnchantmentConfigs {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
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");
|
|
||||||
}
|
|
||||||
|
|
||||||
private static double readDouble(String path, double defaultValue, double minValue, double maxValue) {
|
|
||||||
return Math.clamp(ConfigUtil.readDouble(path, defaultValue), minValue, maxValue);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -9,8 +9,6 @@ import net.minecraft.world.item.enchantment.Enchantment;
|
|||||||
public class ModEnchantments {
|
public class ModEnchantments {
|
||||||
public static final ResourceKey<Enchantment> MANA_LEAK = create("mana_leak");
|
public static final ResourceKey<Enchantment> MANA_LEAK = create("mana_leak");
|
||||||
public static final ResourceKey<Enchantment> MANA_EFFICIENCY = create("mana_efficiency");
|
public static final ResourceKey<Enchantment> MANA_EFFICIENCY = create("mana_efficiency");
|
||||||
public static final ResourceKey<Enchantment> MANA_GATHERING = create("mana_gathering");
|
|
||||||
public static final ResourceKey<Enchantment> MANA_GATHERING_CURSE = create("mana_gathering_curse");
|
|
||||||
public static final ResourceKey<Enchantment> ARCANE_AMPLIFICATION = create("arcane_amplification");
|
public static final ResourceKey<Enchantment> ARCANE_AMPLIFICATION = create("arcane_amplification");
|
||||||
public static final ResourceKey<Enchantment> SUMMON_AMPLIFICATION = create("summon_amplification");
|
public static final ResourceKey<Enchantment> SUMMON_AMPLIFICATION = create("summon_amplification");
|
||||||
public static final ResourceKey<Enchantment> AMMO_EXHAUSTION = create("ammo_exhaustion");
|
public static final ResourceKey<Enchantment> AMMO_EXHAUSTION = create("ammo_exhaustion");
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ package com.lzxnone.terraria.entity.projectile;
|
|||||||
|
|
||||||
import com.lzxnone.terraria.item.ammo.CrystalBullet;
|
import com.lzxnone.terraria.item.ammo.CrystalBullet;
|
||||||
import com.lzxnone.terraria.item.weapon.melee.*;
|
import com.lzxnone.terraria.item.weapon.melee.*;
|
||||||
|
import com.lzxnone.terraria.item.weapon.ranged.Flamethrower;
|
||||||
|
import com.lzxnone.terraria.item.weapon.ranged.SuperStarShooter;
|
||||||
import net.minecraft.world.phys.BlockHitResult;
|
import net.minecraft.world.phys.BlockHitResult;
|
||||||
import net.minecraft.world.phys.EntityHitResult;
|
import net.minecraft.world.phys.EntityHitResult;
|
||||||
|
|
||||||
@@ -24,6 +26,7 @@ public class StaticProjectileBehaviors {
|
|||||||
public static final String DEVILS_DEVASTATION_PROJECTILE2 = "devils_devastation_projectile2";
|
public static final String DEVILS_DEVASTATION_PROJECTILE2 = "devils_devastation_projectile2";
|
||||||
public static final String DEVILS_DEVASTATION_PROJECTILE3 = "devils_devastation_projectile3";
|
public static final String DEVILS_DEVASTATION_PROJECTILE3 = "devils_devastation_projectile3";
|
||||||
public static final String CRYSTAL_FRAGMENT = "crystal_fragment";
|
public static final String CRYSTAL_FRAGMENT = "crystal_fragment";
|
||||||
|
public static final String SUPER_STAR_PRISMATIC_BOLT = "super_star_prismatic_blot";
|
||||||
|
|
||||||
static {
|
static {
|
||||||
BEHAVIORS.put(DEFAULT, new IStaticProjectileBehavior() {
|
BEHAVIORS.put(DEFAULT, new IStaticProjectileBehavior() {
|
||||||
@@ -52,6 +55,7 @@ public class StaticProjectileBehaviors {
|
|||||||
BEHAVIORS.put(DEVILS_DEVASTATION_PROJECTILE2, DevilsDevastation.PROJECTILE_BEHAVIOR2);
|
BEHAVIORS.put(DEVILS_DEVASTATION_PROJECTILE2, DevilsDevastation.PROJECTILE_BEHAVIOR2);
|
||||||
BEHAVIORS.put(DEVILS_DEVASTATION_PROJECTILE3, DevilsDevastation.PROJECTILE_BEHAVIOR3);
|
BEHAVIORS.put(DEVILS_DEVASTATION_PROJECTILE3, DevilsDevastation.PROJECTILE_BEHAVIOR3);
|
||||||
BEHAVIORS.put(CRYSTAL_FRAGMENT, CrystalBullet.PROJECTILE_BEHAVIOR);
|
BEHAVIORS.put(CRYSTAL_FRAGMENT, CrystalBullet.PROJECTILE_BEHAVIOR);
|
||||||
|
BEHAVIORS.put(SUPER_STAR_PRISMATIC_BOLT, SuperStarShooter.PROJECTILE_BEHAVIOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IStaticProjectileBehavior getBehavior(String id) {
|
public static IStaticProjectileBehavior getBehavior(String id) {
|
||||||
|
|||||||
@@ -1,8 +1,13 @@
|
|||||||
package com.lzxnone.terraria.entity.summon;
|
package com.lzxnone.terraria.entity.summon;
|
||||||
|
|
||||||
import com.lzxnone.terraria.item.ammo.*;
|
import com.lzxnone.terraria.item.ammo.*;
|
||||||
|
import com.lzxnone.terraria.item.weapon.ranged.ElfMelter;
|
||||||
import com.lzxnone.terraria.item.weapon.magic.LastPrism;
|
import com.lzxnone.terraria.item.weapon.magic.LastPrism;
|
||||||
import com.lzxnone.terraria.item.weapon.melee.*;
|
import com.lzxnone.terraria.item.weapon.melee.*;
|
||||||
|
import com.lzxnone.terraria.item.weapon.ranged.Flamethrower;
|
||||||
|
import com.lzxnone.terraria.item.weapon.ranged.SnowballCannon;
|
||||||
|
import com.lzxnone.terraria.item.weapon.ranged.StarCannon;
|
||||||
|
import com.lzxnone.terraria.item.weapon.ranged.SuperStarShooter;
|
||||||
import com.lzxnone.terraria.item.weapon.summon.Terraprisma;
|
import com.lzxnone.terraria.item.weapon.summon.Terraprisma;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -34,7 +39,7 @@ public class StaticSummonBehaviors {
|
|||||||
public static final String LAST_PRISM_BEAM = "last_prism_beam";
|
public static final String LAST_PRISM_BEAM = "last_prism_beam";
|
||||||
public static final String TERRAPRISMA = "terraprisma";
|
public static final String TERRAPRISMA = "terraprisma";
|
||||||
|
|
||||||
//弹药实体
|
//通用子弹实体
|
||||||
public static final String MUSKET_BALL = "musket_ball";
|
public static final String MUSKET_BALL = "musket_ball";
|
||||||
public static final String METEOR_SHOT = "meteor_shot";
|
public static final String METEOR_SHOT = "meteor_shot";
|
||||||
public static final String SILVER_BULLET = "silver_bullet";
|
public static final String SILVER_BULLET = "silver_bullet";
|
||||||
@@ -51,6 +56,13 @@ public class StaticSummonBehaviors {
|
|||||||
public static final String LUMINITE_BULLET = "luminite_bullet";
|
public static final String LUMINITE_BULLET = "luminite_bullet";
|
||||||
public static final String TUNGSTEN_BULLET = "tungsten_bullet";
|
public static final String TUNGSTEN_BULLET = "tungsten_bullet";
|
||||||
|
|
||||||
|
//特殊子弹实体
|
||||||
|
public static final String SNOWBALL = "snowball";
|
||||||
|
public static final String FALLEN_STAR = "fallen_star";
|
||||||
|
public static final String FALLEN_STAR_SUPER = "fallen_star_super";
|
||||||
|
public static final String FLAMETHROWER_FLAME = "flamethrower_flame";
|
||||||
|
public static final String ELF_MELTER_FLAME = "elf_melter_flame";
|
||||||
|
|
||||||
static {
|
static {
|
||||||
BEHAVIORS.put(DEFAULT, new IStaticSummonBehavior() {});
|
BEHAVIORS.put(DEFAULT, new IStaticSummonBehavior() {});
|
||||||
|
|
||||||
@@ -89,6 +101,12 @@ public class StaticSummonBehaviors {
|
|||||||
BEHAVIORS.put(GOLDEN_BULLET, GoldenBullet.SUMMON_BEHAVIOR);
|
BEHAVIORS.put(GOLDEN_BULLET, GoldenBullet.SUMMON_BEHAVIOR);
|
||||||
BEHAVIORS.put(LUMINITE_BULLET, LuminiteBullet.SUMMON_BEHAVIOR);
|
BEHAVIORS.put(LUMINITE_BULLET, LuminiteBullet.SUMMON_BEHAVIOR);
|
||||||
BEHAVIORS.put(TUNGSTEN_BULLET, TungstenBullet.SUMMON_BEHAVIOR);
|
BEHAVIORS.put(TUNGSTEN_BULLET, TungstenBullet.SUMMON_BEHAVIOR);
|
||||||
|
|
||||||
|
BEHAVIORS.put(SNOWBALL, SnowballCannon.SUMMON_BEHAVIOR);
|
||||||
|
BEHAVIORS.put(FALLEN_STAR, StarCannon.SUMMON_BEHAVIOR);
|
||||||
|
BEHAVIORS.put(FALLEN_STAR_SUPER, SuperStarShooter.SUMMON_BEHAVIOR);
|
||||||
|
BEHAVIORS.put(FLAMETHROWER_FLAME, Flamethrower.SUMMON_BEHAVIOR);
|
||||||
|
BEHAVIORS.put(ELF_MELTER_FLAME, ElfMelter.SUMMON_BEHAVIOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IStaticSummonBehavior getBehavior(String id) {
|
public static IStaticSummonBehavior getBehavior(String id) {
|
||||||
|
|||||||
@@ -24,12 +24,14 @@ public class EntityDeathEventHandler {
|
|||||||
public static void onEntityDeath(LivingDeathEvent event) {
|
public static void onEntityDeath(LivingDeathEvent event) {
|
||||||
LivingEntity livingEntity = event.getEntity();
|
LivingEntity livingEntity = event.getEntity();
|
||||||
|
|
||||||
//消耗插入的破灭魔王剑
|
|
||||||
if(livingEntity.level() instanceof ServerLevel serverLevel) {
|
if(livingEntity.level() instanceof ServerLevel serverLevel) {
|
||||||
|
//迈达斯生成绿宝石
|
||||||
if(livingEntity.hasEffect(ModEffects.MIDAS) && livingEntity.getRandom().nextFloat() < MidasEffect.getDropChance()) {
|
if(livingEntity.hasEffect(ModEffects.MIDAS) && livingEntity.getRandom().nextFloat() < MidasEffect.getDropChance()) {
|
||||||
livingEntity.spawnAtLocation(new ItemStack(Items.EMERALD));
|
livingEntity.spawnAtLocation(new ItemStack(Items.EMERALD));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//消耗插入的破灭魔王剑
|
||||||
List<UUID> stuckList = livingEntity.getData(ModAttachments.STUCK_DEVILS_DEVASTATION_PROJECTILE);
|
List<UUID> stuckList = livingEntity.getData(ModAttachments.STUCK_DEVILS_DEVASTATION_PROJECTILE);
|
||||||
while(!stuckList.isEmpty()) {
|
while(!stuckList.isEmpty()) {
|
||||||
UUID uuid = stuckList.getLast();
|
UUID uuid = stuckList.getLast();
|
||||||
|
|||||||
@@ -0,0 +1,70 @@
|
|||||||
|
package com.lzxnone.terraria.event;
|
||||||
|
|
||||||
|
import com.lzxnone.terraria.LzxnoneTerraria;
|
||||||
|
import com.lzxnone.terraria.attachment.ModAttachments;
|
||||||
|
import com.lzxnone.terraria.attachment.PlayerMana;
|
||||||
|
import com.lzxnone.terraria.item.weapon.MagicWeapon;
|
||||||
|
import com.lzxnone.terraria.network.payload.ManaSyncPayload;
|
||||||
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
import net.neoforged.bus.api.SubscribeEvent;
|
||||||
|
import net.neoforged.fml.common.EventBusSubscriber;
|
||||||
|
import net.neoforged.neoforge.event.entity.player.PlayerEvent;
|
||||||
|
import net.neoforged.neoforge.event.tick.PlayerTickEvent;
|
||||||
|
import net.neoforged.neoforge.network.PacketDistributor;
|
||||||
|
|
||||||
|
@EventBusSubscriber(modid = LzxnoneTerraria.MODID)
|
||||||
|
public class PlayerManaSyncEventHandler {
|
||||||
|
@SubscribeEvent
|
||||||
|
public static void onPlayerLoggedIn(PlayerEvent.PlayerLoggedInEvent event) {
|
||||||
|
if(event.getEntity() instanceof ServerPlayer player) {
|
||||||
|
sync(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public static void onPlayerRespawn(PlayerEvent.PlayerRespawnEvent event) {
|
||||||
|
if(event.getEntity() instanceof ServerPlayer player) {
|
||||||
|
sync(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public static void onPlayerChangedDimension(PlayerEvent.PlayerChangedDimensionEvent event) {
|
||||||
|
if(event.getEntity() instanceof ServerPlayer player) {
|
||||||
|
sync(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public static void onPlayerTick(PlayerTickEvent.Post event) {
|
||||||
|
if(!(event.getEntity() instanceof ServerPlayer player)) return;
|
||||||
|
if(isUsingMagicWeapon(player)) return;
|
||||||
|
|
||||||
|
PlayerMana mana = player.getData(ModAttachments.PLAYER_MANA);
|
||||||
|
if(mana.tickRecoverDelay()) {
|
||||||
|
player.setData(ModAttachments.PLAYER_MANA, mana);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int oldMana = mana.getMana();
|
||||||
|
if(!mana.recoverMana(PlayerMana.DEFAULT_RECOVER_RATE)) return;
|
||||||
|
|
||||||
|
player.setData(ModAttachments.PLAYER_MANA, mana);
|
||||||
|
if(mana.getMana() != oldMana) {
|
||||||
|
sync(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void sync(ServerPlayer player) {
|
||||||
|
PlayerMana mana = player.getData(ModAttachments.PLAYER_MANA);
|
||||||
|
PacketDistributor.sendToPlayer(player, new ManaSyncPayload(mana.getMana(), mana.getMaxMana()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean isUsingMagicWeapon(ServerPlayer player) {
|
||||||
|
if(!player.isUsingItem()) return false;
|
||||||
|
|
||||||
|
ItemStack stack = player.getUseItem();
|
||||||
|
return stack.getItem() instanceof MagicWeapon;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,6 +7,7 @@ import net.minecraft.tags.TagKey;
|
|||||||
import net.minecraft.world.item.Item;
|
import net.minecraft.world.item.Item;
|
||||||
|
|
||||||
public class ModItemTags {
|
public class ModItemTags {
|
||||||
|
public static final TagKey<Item> AMMO = create("ammo");
|
||||||
public static final TagKey<Item> BULLET_AMMO = create("bullet_ammo");
|
public static final TagKey<Item> BULLET_AMMO = create("bullet_ammo");
|
||||||
|
|
||||||
private static TagKey<Item> create(String name) {
|
private static TagKey<Item> create(String name) {
|
||||||
|
|||||||
@@ -2,11 +2,16 @@ package com.lzxnone.terraria.item;
|
|||||||
|
|
||||||
import com.lzxnone.terraria.LzxnoneTerraria;
|
import com.lzxnone.terraria.LzxnoneTerraria;
|
||||||
import com.lzxnone.terraria.item.ammo.*;
|
import com.lzxnone.terraria.item.ammo.*;
|
||||||
import com.lzxnone.terraria.item.projectile.*;
|
import com.lzxnone.terraria.item.accessory.ManaFlower;
|
||||||
import com.lzxnone.terraria.item.projectile.first_fractal.*;
|
import com.lzxnone.terraria.item.accessory.NaturesGift;
|
||||||
|
import com.lzxnone.terraria.item.weapon.ranged.ElfMelter;
|
||||||
import com.lzxnone.terraria.item.weapon.magic.*;
|
import com.lzxnone.terraria.item.weapon.magic.*;
|
||||||
import com.lzxnone.terraria.item.weapon.melee.*;
|
import com.lzxnone.terraria.item.weapon.melee.*;
|
||||||
import com.lzxnone.terraria.item.weapon.ranged.*;
|
import com.lzxnone.terraria.item.weapon.ranged.Flamethrower;
|
||||||
|
import com.lzxnone.terraria.item.weapon.ranged.SnowballCannon;
|
||||||
|
import com.lzxnone.terraria.item.weapon.ranged.StarCannon;
|
||||||
|
import com.lzxnone.terraria.item.weapon.ranged.SuperStarShooter;
|
||||||
|
import com.lzxnone.terraria.item.weapon.ranged.gun.*;
|
||||||
import com.lzxnone.terraria.item.weapon.summon.*;
|
import com.lzxnone.terraria.item.weapon.summon.*;
|
||||||
import net.minecraft.world.item.Item;
|
import net.minecraft.world.item.Item;
|
||||||
import net.neoforged.neoforge.registries.DeferredItem;
|
import net.neoforged.neoforge.registries.DeferredItem;
|
||||||
@@ -65,6 +70,11 @@ public class ModItems {
|
|||||||
public static final DeferredItem<Item> SNIPER_RIFLE = ITEMS.register("sniper_rifle", SniperRifle::new);
|
public static final DeferredItem<Item> SNIPER_RIFLE = ITEMS.register("sniper_rifle", SniperRifle::new);
|
||||||
public static final DeferredItem<Item> CHAIN_GUN = ITEMS.register("chain_gun", ChainGun::new);
|
public static final DeferredItem<Item> CHAIN_GUN = ITEMS.register("chain_gun", ChainGun::new);
|
||||||
public static final DeferredItem<Item> SDMG = ITEMS.register("sdmg", SDMG::new);
|
public static final DeferredItem<Item> SDMG = ITEMS.register("sdmg", SDMG::new);
|
||||||
|
public static final DeferredItem<Item> SNOWBALL_CANNON = ITEMS.register("snowball_cannon", SnowballCannon::new);
|
||||||
|
public static final DeferredItem<Item> STAR_CANNON = ITEMS.register("star_cannon", StarCannon::new);
|
||||||
|
public static final DeferredItem<Item> SUPER_STAR_SHOOTER = ITEMS.register("super_star_shooter", SuperStarShooter::new);
|
||||||
|
public static final DeferredItem<Item> FLAMETHROWER = ITEMS.register("flamethrower", Flamethrower::new);
|
||||||
|
public static final DeferredItem<Item> ELF_MELTER = ITEMS.register("elf_melter", ElfMelter::new);
|
||||||
|
|
||||||
//召唤武器
|
//召唤武器
|
||||||
public static final DeferredItem<Item> TERRAPRISMA = ITEMS.register("terraprisma", Terraprisma::new);
|
public static final DeferredItem<Item> TERRAPRISMA = ITEMS.register("terraprisma", Terraprisma::new);
|
||||||
@@ -89,6 +99,11 @@ public class ModItems {
|
|||||||
public static final DeferredItem<Item> ENDLESS_MUSKET_POUCH = ITEMS.register("endless_musket_pouch", EndlessMusketPouch::new);
|
public static final DeferredItem<Item> ENDLESS_MUSKET_POUCH = ITEMS.register("endless_musket_pouch", EndlessMusketPouch::new);
|
||||||
public static final DeferredItem<Item> LUMINITE_BULLET = ITEMS.register("luminite_bullet", LuminiteBullet::new);
|
public static final DeferredItem<Item> LUMINITE_BULLET = ITEMS.register("luminite_bullet", LuminiteBullet::new);
|
||||||
public static final DeferredItem<Item> TUNGSTEN_BULLET = ITEMS.register("tungsten_bullet", TungstenBullet::new);
|
public static final DeferredItem<Item> TUNGSTEN_BULLET = ITEMS.register("tungsten_bullet", TungstenBullet::new);
|
||||||
|
public static final DeferredItem<Item> FALLEN_STAR = ITEMS.register("fallen_star", FallenStar::new);
|
||||||
|
|
||||||
|
//饰品
|
||||||
|
public static final DeferredItem<Item> NATURES_GIFT = ITEMS.register("natures_gift", NaturesGift::new);
|
||||||
|
public static final DeferredItem<Item> MANA_FLOWER = ITEMS.register("mana_flower", ManaFlower::new);
|
||||||
|
|
||||||
//弹射物
|
//弹射物
|
||||||
public static final DeferredItem<Item> BULLET_PROJECTILE = ITEMS.register("bullet_projectile", () -> new Item(new Item.Properties()));
|
public static final DeferredItem<Item> BULLET_PROJECTILE = ITEMS.register("bullet_projectile", () -> new Item(new Item.Properties()));
|
||||||
@@ -106,6 +121,7 @@ public class ModItems {
|
|||||||
public static final DeferredItem<Item> EXPLODING_BULLET_PROJECTILE = ITEMS.register("exploding_bullet_projectile", () -> new Item(new Item.Properties()));
|
public static final DeferredItem<Item> EXPLODING_BULLET_PROJECTILE = ITEMS.register("exploding_bullet_projectile", () -> new Item(new Item.Properties()));
|
||||||
public static final DeferredItem<Item> GOLDEN_BULLET_PROJECTILE = ITEMS.register("golden_bullet_projectile", () -> new Item(new Item.Properties()));
|
public static final DeferredItem<Item> GOLDEN_BULLET_PROJECTILE = ITEMS.register("golden_bullet_projectile", () -> new Item(new Item.Properties()));
|
||||||
public static final DeferredItem<Item> LUMINITE_BULLET_PROJECTILE = ITEMS.register("luminite_bullet_projectile", () -> new Item(new Item.Properties()));
|
public static final DeferredItem<Item> LUMINITE_BULLET_PROJECTILE = ITEMS.register("luminite_bullet_projectile", () -> new Item(new Item.Properties()));
|
||||||
|
public static final DeferredItem<Item> WHITE_STAR = ITEMS.register("white_star", () -> new Item(new Item.Properties()));
|
||||||
|
|
||||||
public static final DeferredItem<Item> ENCHANTED_SWORD_BEAM = ITEMS.register("enchanted_sword_beam", () -> new Item(new Item.Properties()));
|
public static final DeferredItem<Item> ENCHANTED_SWORD_BEAM = ITEMS.register("enchanted_sword_beam", () -> new Item(new Item.Properties()));
|
||||||
public static final DeferredItem<Item> STARFURY_STAR = ITEMS.register("starfury_star", () -> new Item(new Item.Properties()));
|
public static final DeferredItem<Item> STARFURY_STAR = ITEMS.register("starfury_star", () -> new Item(new Item.Properties()));
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package com.lzxnone.terraria.item.accessory;
|
||||||
|
|
||||||
|
import net.minecraft.world.item.Item;
|
||||||
|
import top.theillusivec4.curios.api.type.capability.ICurioItem;
|
||||||
|
|
||||||
|
public class AccessoryItem extends Item implements ICurioItem {
|
||||||
|
public AccessoryItem(Properties properties) {
|
||||||
|
super(properties);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package com.lzxnone.terraria.item.accessory;
|
||||||
|
|
||||||
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
import top.theillusivec4.curios.api.CuriosApi;
|
||||||
|
import top.theillusivec4.curios.api.type.inventory.IDynamicStackHandler;
|
||||||
|
|
||||||
|
import java.util.function.BiConsumer;
|
||||||
|
|
||||||
|
public class AccessoryUtil {
|
||||||
|
public static final String TERRARIA_ACCESSORY_SLOT = "terraria_accessory";
|
||||||
|
|
||||||
|
public static void forEachAccessory(LivingEntity entity, BiConsumer<AccessoryItem, ItemStack> consumer) {
|
||||||
|
CuriosApi.getCuriosInventory(entity)
|
||||||
|
.flatMap(handler -> handler.getStacksHandler(TERRARIA_ACCESSORY_SLOT))
|
||||||
|
.ifPresent(stacksHandler -> {
|
||||||
|
IDynamicStackHandler stacks = stacksHandler.getStacks();
|
||||||
|
for(int i = 0; i < stacks.getSlots(); i++) {
|
||||||
|
ItemStack stack = stacks.getStackInSlot(i);
|
||||||
|
if(stack.getItem() instanceof AccessoryItem accessory) {
|
||||||
|
consumer.accept(accessory, stack);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
package com.lzxnone.terraria.item.accessory;
|
||||||
|
|
||||||
|
import com.lzxnone.terraria.item.accessory.effect.AutoManaPotionUser;
|
||||||
|
import com.lzxnone.terraria.item.accessory.effect.ManaCostModifier;
|
||||||
|
import net.minecraft.ChatFormatting;
|
||||||
|
import net.minecraft.network.chat.Component;
|
||||||
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
|
import net.minecraft.world.item.Item;
|
||||||
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
import net.minecraft.world.item.Rarity;
|
||||||
|
import net.minecraft.world.item.TooltipFlag;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ManaFlower extends AccessoryItem implements ManaCostModifier, AutoManaPotionUser {
|
||||||
|
private static final double MANA_COST_MULTIPLIER = 0.92D;
|
||||||
|
|
||||||
|
public ManaFlower() {
|
||||||
|
super(new Item.Properties().stacksTo(1).rarity(Rarity.RARE));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getManaCostMultiplier(ItemStack stack, LivingEntity entity) {
|
||||||
|
return MANA_COST_MULTIPLIER;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canAutoUseManaPotion(ItemStack stack, LivingEntity entity) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void appendHoverText(ItemStack stack, Item.TooltipContext context, List<Component> tooltipComponents, TooltipFlag tooltipFlag) {
|
||||||
|
super.appendHoverText(stack, context, tooltipComponents, tooltipFlag);
|
||||||
|
tooltipComponents.add(Component.translatable("tooltip.lzxnoneterraria.mana_flower.0").withStyle(ChatFormatting.GRAY));
|
||||||
|
tooltipComponents.add(Component.translatable("tooltip.lzxnoneterraria.mana_flower.1").withStyle(ChatFormatting.GRAY));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package com.lzxnone.terraria.item.accessory;
|
||||||
|
|
||||||
|
import com.lzxnone.terraria.item.accessory.effect.ManaCostModifier;
|
||||||
|
import net.minecraft.ChatFormatting;
|
||||||
|
import net.minecraft.network.chat.Component;
|
||||||
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
|
import net.minecraft.world.item.Item;
|
||||||
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
import net.minecraft.world.item.Rarity;
|
||||||
|
import net.minecraft.world.item.TooltipFlag;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class NaturesGift extends AccessoryItem implements ManaCostModifier {
|
||||||
|
private static final double MANA_COST_MULTIPLIER = 0.94D;
|
||||||
|
|
||||||
|
public NaturesGift() {
|
||||||
|
super(new Item.Properties().stacksTo(1).rarity(Rarity.UNCOMMON));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getManaCostMultiplier(ItemStack stack, LivingEntity entity) {
|
||||||
|
return MANA_COST_MULTIPLIER;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void appendHoverText(ItemStack stack, Item.TooltipContext context, List<Component> tooltipComponents, TooltipFlag tooltipFlag) {
|
||||||
|
super.appendHoverText(stack, context, tooltipComponents, tooltipFlag);
|
||||||
|
tooltipComponents.add(Component.translatable("tooltip.lzxnoneterraria.natures_gift.0").withStyle(ChatFormatting.GRAY));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package com.lzxnone.terraria.item.accessory.effect;
|
||||||
|
|
||||||
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
|
||||||
|
public interface AutoManaPotionUser {
|
||||||
|
boolean canAutoUseManaPotion(ItemStack stack, LivingEntity entity);
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package com.lzxnone.terraria.item.accessory.effect;
|
||||||
|
|
||||||
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
|
||||||
|
public interface ManaCostModifier {
|
||||||
|
double getManaCostMultiplier(ItemStack stack, LivingEntity entity);
|
||||||
|
}
|
||||||
@@ -1,86 +0,0 @@
|
|||||||
package com.lzxnone.terraria.item.ammo;
|
|
||||||
|
|
||||||
import com.lzxnone.terraria.LzxnoneTerraria;
|
|
||||||
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 net.minecraft.resources.ResourceLocation;
|
|
||||||
|
|
||||||
public class AmmoConfig {
|
|
||||||
private static final String CONFIG_TRANSLATION_PREFIX = "lzxnoneterraria.configuration.";
|
|
||||||
|
|
||||||
private AmmoConfig() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String path(String id, String key) {
|
|
||||||
return "ammo." + id + "." + key;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String translationKey(String id, String key) {
|
|
||||||
return id + "_" + key;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void loadFloat(String id, String key, float defaultValue, float minValue, float maxValue) {
|
|
||||||
ConfigFactory.loadFloatConfig(
|
|
||||||
path(id, key),
|
|
||||||
configText(translationKey(id, key)),
|
|
||||||
configTooltip(translationKey(id, key)),
|
|
||||||
defaultValue,
|
|
||||||
minValue,
|
|
||||||
maxValue
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void loadDouble(String id, String key, double defaultValue, double minValue, double maxValue) {
|
|
||||||
ConfigFactory.loadDoubleConfig(
|
|
||||||
path(id, key),
|
|
||||||
configText(translationKey(id, key)),
|
|
||||||
configTooltip(translationKey(id, key)),
|
|
||||||
defaultValue,
|
|
||||||
minValue,
|
|
||||||
maxValue
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void loadInt(String id, String key, int defaultValue, int minValue, int maxValue) {
|
|
||||||
ConfigFactory.loadIntConfig(
|
|
||||||
path(id, key),
|
|
||||||
configText(translationKey(id, key)),
|
|
||||||
configTooltip(translationKey(id, key)),
|
|
||||||
defaultValue,
|
|
||||||
minValue,
|
|
||||||
maxValue
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static float readFloat(String id, String key, float defaultValue, float minValue, float maxValue) {
|
|
||||||
return Math.clamp(ConfigUtil.readFloat(path(id, key), defaultValue), minValue, maxValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static double readDouble(String id, String key, double defaultValue, double minValue, double maxValue) {
|
|
||||||
return Math.clamp(ConfigUtil.readDouble(path(id, key), defaultValue), minValue, maxValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int readInt(String id, String key, int defaultValue, int minValue, int maxValue) {
|
|
||||||
return Math.clamp(ConfigUtil.readInt(path(id, key), defaultValue), minValue, maxValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ConfigListItem createListItem(String id, IConfigData configData) {
|
|
||||||
return new ConfigListItem(
|
|
||||||
id,
|
|
||||||
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/item/" + id + ".png"),
|
|
||||||
Component.translatable("item.lzxnoneterraria." + id),
|
|
||||||
configData
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
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");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,13 +1,19 @@
|
|||||||
package com.lzxnone.terraria.item.ammo;
|
package com.lzxnone.terraria.item.ammo;
|
||||||
|
|
||||||
|
import com.lzxnone.terraria.LzxnoneTerraria;
|
||||||
import com.lzxnone.terraria.entity.summon.IStaticSummonBehavior;
|
import com.lzxnone.terraria.entity.summon.IStaticSummonBehavior;
|
||||||
import com.lzxnone.terraria.entity.summon.StaticSummon;
|
import com.lzxnone.terraria.entity.summon.StaticSummon;
|
||||||
import com.lzxnone.terraria.particle.DustParticleOptions;
|
import com.lzxnone.terraria.particle.DustParticleOptions;
|
||||||
import com.lzxnone.terraria.particle.ModParticles;
|
|
||||||
import com.lzxnone.terraria.ui.config.ConfigListItem;
|
import com.lzxnone.terraria.ui.config.ConfigListItem;
|
||||||
import com.lzxnone.terraria.ui.config.IConfigData;
|
import com.lzxnone.terraria.ui.config.IConfigData;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigDouble;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigFloat;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigStruct;
|
||||||
import com.lzxnone.terraria.utils.*;
|
import com.lzxnone.terraria.utils.*;
|
||||||
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
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.Entity;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.level.ClipContext;
|
import net.minecraft.world.level.ClipContext;
|
||||||
@@ -16,15 +22,13 @@ import net.minecraft.world.phys.AABB;
|
|||||||
import net.minecraft.world.phys.BlockHitResult;
|
import net.minecraft.world.phys.BlockHitResult;
|
||||||
import net.minecraft.world.phys.HitResult;
|
import net.minecraft.world.phys.HitResult;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
|
|
||||||
import org.joml.Vector3f;
|
import org.joml.Vector3f;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ChlorophyteBullet extends BulletAmmo {
|
public class ChlorophyteBullet extends BulletAmmo {
|
||||||
public static final String ID = "chlorophyte_bullet";
|
public static final String ID = "chlorophyte_bullet";
|
||||||
public static final float BASE_DAMAGE_DEFAULT = 1.5f;
|
|
||||||
public static final double SPEED_DEFAULT = 3.0D;
|
|
||||||
public static final double TARGET_RANGE_DEFAULT = 24.0D;
|
|
||||||
|
|
||||||
public static final double AVOID_CHECK_DISTANCE = 3.0D;
|
public static final double AVOID_CHECK_DISTANCE = 3.0D;
|
||||||
public static final double TURN_RATE = 0.35D;
|
public static final double TURN_RATE = 0.35D;
|
||||||
@@ -33,28 +37,23 @@ public class ChlorophyteBullet extends BulletAmmo {
|
|||||||
public static final double TARGET_WEIGHT = 1.0D;
|
public static final double TARGET_WEIGHT = 1.0D;
|
||||||
public static final double AVOID_WEIGHT = 0.8D;
|
public static final double AVOID_WEIGHT = 0.8D;
|
||||||
|
|
||||||
|
public static final ConfigFloat BASE_DAMAGE = new ConfigFloat("ammo.chlorophyte_bullet.base_damage", "chlorophyte_bullet_base_damage", 1.5f, 0.0f, 8388600.0f);
|
||||||
|
public static final ConfigDouble SPEED = new ConfigDouble("ammo.chlorophyte_bullet.speed", "chlorophyte_bullet_speed", 3.0D, 0.0D, 24.0D);
|
||||||
|
public static final ConfigDouble TARGET_RANGE = new ConfigDouble("ammo.chlorophyte_bullet.target_range", "chlorophyte_bullet_target_range", 24.0D, 0.0D, 128.0D);
|
||||||
|
|
||||||
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
||||||
@Override
|
@Override
|
||||||
public void onConfigLoad() {
|
public void onConfigLoad() {
|
||||||
AmmoConfig.loadFloat(ID, "base_damage", BASE_DAMAGE_DEFAULT, 0.0f, 8388600.0f);
|
ConfigStruct.loadAll(BASE_DAMAGE, SPEED, TARGET_RANGE);
|
||||||
AmmoConfig.loadDouble(ID, "speed", SPEED_DEFAULT, 0.0D, 24.0D);
|
|
||||||
AmmoConfig.loadDouble(ID, "target_range", TARGET_RANGE_DEFAULT, 0.0D, 128.0D);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public static final ConfigListItem CONFIG_LIST_ITEM = AmmoConfig.createListItem(ID, CONFIG_DATA);
|
public static final ConfigListItem CONFIG_LIST_ITEM = new ConfigListItem(
|
||||||
|
ID,
|
||||||
public static float getBaseDamage() {
|
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/item/" + ID + ".png"),
|
||||||
return AmmoConfig.readFloat(ID, "base_damage", BASE_DAMAGE_DEFAULT, 0.0f, 8388600.0f);
|
Component.translatable("item.lzxnoneterraria." + ID),
|
||||||
}
|
CONFIG_DATA
|
||||||
|
);
|
||||||
public static double getSpeed() {
|
|
||||||
return AmmoConfig.readDouble(ID, "speed", SPEED_DEFAULT, 0.0D, 24.0D);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static double getTargetRange() {
|
|
||||||
return AmmoConfig.readDouble(ID, "target_range", TARGET_RANGE_DEFAULT, 0.0D, 128.0D);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final double[][] CANDIDATE_OFFSETS = new double[][]{
|
private static final double[][] CANDIDATE_OFFSETS = new double[][]{
|
||||||
{0.0D, 0.0D},
|
{0.0D, 0.0D},
|
||||||
@@ -85,7 +84,7 @@ public class ChlorophyteBullet extends BulletAmmo {
|
|||||||
this.checkBeforeTick(summon);
|
this.checkBeforeTick(summon);
|
||||||
|
|
||||||
Vec3 currentDir = getCurrentDirection(summon);
|
Vec3 currentDir = getCurrentDirection(summon);
|
||||||
Vec3 oldMotion = currentDir.normalize().scale(getSpeed());
|
Vec3 oldMotion = currentDir.normalize().scale(SPEED.get());
|
||||||
|
|
||||||
Entity target = findTarget(summon);
|
Entity target = findTarget(summon);
|
||||||
Vec3 nextDir = currentDir;
|
Vec3 nextDir = currentDir;
|
||||||
@@ -102,7 +101,7 @@ public class ChlorophyteBullet extends BulletAmmo {
|
|||||||
nextDir = steer(currentDir, findBestClearDirection(summon, currentDir, currentDir));
|
nextDir = steer(currentDir, findBestClearDirection(summon, currentDir, currentDir));
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec3 motion = nextDir.normalize().scale(getSpeed());
|
Vec3 motion = nextDir.normalize().scale(SPEED.get());
|
||||||
Vec3 start = summon.position();
|
Vec3 start = summon.position();
|
||||||
Vec3 end = start.add(motion);
|
Vec3 end = start.add(motion);
|
||||||
|
|
||||||
@@ -145,7 +144,7 @@ public class ChlorophyteBullet extends BulletAmmo {
|
|||||||
|
|
||||||
ItemStack sourceStack = summon.getEntityData().get(StaticSummon.STACK_SOURCE);
|
ItemStack sourceStack = summon.getEntityData().get(StaticSummon.STACK_SOURCE);
|
||||||
Entity hitTarget = targets.getFirst();
|
Entity hitTarget = targets.getFirst();
|
||||||
if(DamageUtil.rangedAttack(summon, hitTarget, sourceStack, getBaseDamage() + damage, knockbackScale)) {
|
if(DamageUtil.rangedAttack(summon, hitTarget, sourceStack, BASE_DAMAGE.get() + damage, knockbackScale)) {
|
||||||
hitTarget.invulnerableTime = invulnerableTime;
|
hitTarget.invulnerableTime = invulnerableTime;
|
||||||
this.onDied(summon);
|
this.onDied(summon);
|
||||||
return;
|
return;
|
||||||
@@ -162,7 +161,7 @@ public class ChlorophyteBullet extends BulletAmmo {
|
|||||||
};
|
};
|
||||||
|
|
||||||
private static Entity findTarget(StaticSummon summon) {
|
private static Entity findTarget(StaticSummon summon) {
|
||||||
AABB searchBox = summon.getBoundingBox().inflate(getTargetRange());
|
AABB searchBox = summon.getBoundingBox().inflate(TARGET_RANGE.get());
|
||||||
List<Entity> targets = CollisionUtil.searchEnemies(summon.level(), searchBox, summon, summon.getOwner());
|
List<Entity> targets = CollisionUtil.searchEnemies(summon.level(), searchBox, summon, summon.getOwner());
|
||||||
Entity bestTarget = null;
|
Entity bestTarget = null;
|
||||||
double bestDistance = Double.MAX_VALUE;
|
double bestDistance = Double.MAX_VALUE;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.lzxnone.terraria.item.ammo;
|
package com.lzxnone.terraria.item.ammo;
|
||||||
|
|
||||||
|
import com.lzxnone.terraria.LzxnoneTerraria;
|
||||||
import com.lzxnone.terraria.entity.ModEntities;
|
import com.lzxnone.terraria.entity.ModEntities;
|
||||||
import com.lzxnone.terraria.entity.projectile.IStaticProjectileBehavior;
|
import com.lzxnone.terraria.entity.projectile.IStaticProjectileBehavior;
|
||||||
import com.lzxnone.terraria.entity.projectile.StaticProjectile;
|
import com.lzxnone.terraria.entity.projectile.StaticProjectile;
|
||||||
@@ -10,76 +11,55 @@ import com.lzxnone.terraria.item.ModItems;
|
|||||||
import com.lzxnone.terraria.particle.ModParticles;
|
import com.lzxnone.terraria.particle.ModParticles;
|
||||||
import com.lzxnone.terraria.ui.config.ConfigListItem;
|
import com.lzxnone.terraria.ui.config.ConfigListItem;
|
||||||
import com.lzxnone.terraria.ui.config.IConfigData;
|
import com.lzxnone.terraria.ui.config.IConfigData;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigDouble;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigFloat;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigInt;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigStruct;
|
||||||
import com.lzxnone.terraria.utils.*;
|
import com.lzxnone.terraria.utils.*;
|
||||||
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
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.ServerLevel;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.phys.*;
|
import net.minecraft.world.phys.*;
|
||||||
|
|
||||||
import org.joml.Vector3f;
|
import org.joml.Vector3f;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class CrystalBullet extends BulletAmmo {
|
public class CrystalBullet extends BulletAmmo {
|
||||||
public static final String ID = "crystal_bullet";
|
public static final String ID = "crystal_bullet";
|
||||||
public static final float BASE_DAMAGE_DEFAULT = 1.2f;
|
|
||||||
public static final double SPEED_DEFAULT = 3.0D;
|
|
||||||
|
|
||||||
public static final float FRAGMENT_DAMAGE_MUL_DEFAULT = 0.5f;
|
public static final ConfigFloat BASE_DAMAGE = new ConfigFloat("ammo.crystal_bullet.base_damage", "crystal_bullet_base_damage", 1.2f, 0.0f, 8388600.0f);
|
||||||
public static final double FRAGMENT_SPEED_DEFAULT = 1.0;
|
public static final ConfigDouble SPEED = new ConfigDouble("ammo.crystal_bullet.speed", "crystal_bullet_speed", 3.0D, 0.0D, 24.0D);
|
||||||
public static final int FRAGMENT_TIME_DEFAULT = 60;
|
public static final ConfigFloat FRAGMENT_DAMAGE_MULTIPLIER = new ConfigFloat("ammo.crystal_bullet.fragment_damage_multiplier", "crystal_bullet_fragment_damage_multiplier", 0.5f, 0.0f, 100.0f);
|
||||||
public static final int FRAGMENT_COUNT_DEFAULT = 3;
|
public static final ConfigDouble FRAGMENT_SPEED = new ConfigDouble("ammo.crystal_bullet.fragment_speed", "crystal_bullet_fragment_speed", 1.0, 0.0D, 24.0D);
|
||||||
public static final int PARTICLE_COUNT_DEFAULT = 5;
|
public static final ConfigInt FRAGMENT_TIME = new ConfigInt("ammo.crystal_bullet.fragment_time", "crystal_bullet_fragment_time", 60, 0, 72000);
|
||||||
|
public static final ConfigInt FRAGMENT_COUNT = new ConfigInt("ammo.crystal_bullet.fragment_count", "crystal_bullet_fragment_count", 3, 0, 100);
|
||||||
|
public static final ConfigInt PARTICLE_COUNT = new ConfigInt("ammo.crystal_bullet.particle_count", "crystal_bullet_particle_count", 5, 0, 1000);
|
||||||
|
|
||||||
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
||||||
@Override
|
@Override
|
||||||
public void onConfigLoad() {
|
public void onConfigLoad() {
|
||||||
AmmoConfig.loadFloat(ID, "base_damage", BASE_DAMAGE_DEFAULT, 0.0f, 8388600.0f);
|
ConfigStruct.loadAll(BASE_DAMAGE, SPEED, FRAGMENT_DAMAGE_MULTIPLIER, FRAGMENT_SPEED, FRAGMENT_TIME, FRAGMENT_COUNT, PARTICLE_COUNT);
|
||||||
AmmoConfig.loadDouble(ID, "speed", SPEED_DEFAULT, 0.0D, 24.0D);
|
|
||||||
AmmoConfig.loadFloat(ID, "fragment_damage_multiplier", FRAGMENT_DAMAGE_MUL_DEFAULT, 0.0f, 100.0f);
|
|
||||||
AmmoConfig.loadDouble(ID, "fragment_speed", FRAGMENT_SPEED_DEFAULT, 0.0D, 24.0D);
|
|
||||||
AmmoConfig.loadInt(ID, "fragment_time", FRAGMENT_TIME_DEFAULT, 0, 72000);
|
|
||||||
AmmoConfig.loadInt(ID, "fragment_count", FRAGMENT_COUNT_DEFAULT, 0, 100);
|
|
||||||
AmmoConfig.loadInt(ID, "particle_count", PARTICLE_COUNT_DEFAULT, 0, 1000);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public static final ConfigListItem CONFIG_LIST_ITEM = AmmoConfig.createListItem(ID, CONFIG_DATA);
|
public static final ConfigListItem CONFIG_LIST_ITEM = new ConfigListItem(
|
||||||
|
ID,
|
||||||
public static float getBaseDamage() {
|
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/item/" + ID + ".png"),
|
||||||
return AmmoConfig.readFloat(ID, "base_damage", BASE_DAMAGE_DEFAULT, 0.0f, 8388600.0f);
|
Component.translatable("item.lzxnoneterraria." + ID),
|
||||||
}
|
CONFIG_DATA
|
||||||
|
);
|
||||||
public static double getSpeed() {
|
|
||||||
return AmmoConfig.readDouble(ID, "speed", SPEED_DEFAULT, 0.0D, 24.0D);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static float getFragmentDamageMultiplier() {
|
|
||||||
return AmmoConfig.readFloat(ID, "fragment_damage_multiplier", FRAGMENT_DAMAGE_MUL_DEFAULT, 0.0f, 100.0f);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static double getFragmentSpeed() {
|
|
||||||
return AmmoConfig.readDouble(ID, "fragment_speed", FRAGMENT_SPEED_DEFAULT, 0.0D, 24.0D);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getFragmentTime() {
|
|
||||||
return AmmoConfig.readInt(ID, "fragment_time", FRAGMENT_TIME_DEFAULT, 0, 72000);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getFragmentCount() {
|
|
||||||
return AmmoConfig.readInt(ID, "fragment_count", FRAGMENT_COUNT_DEFAULT, 0, 100);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getParticleCount() {
|
|
||||||
return AmmoConfig.readInt(ID, "particle_count", PARTICLE_COUNT_DEFAULT, 0, 1000);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final IStaticSummonBehavior SUMMON_BEHAVIOR = new IStaticSummonBehavior() {
|
public static final IStaticSummonBehavior SUMMON_BEHAVIOR = new IStaticSummonBehavior() {
|
||||||
@Override
|
@Override
|
||||||
public void tick(StaticSummon summon) {
|
public void tick(StaticSummon summon) {
|
||||||
this.checkBeforeTick(summon);
|
this.checkBeforeTick(summon);
|
||||||
Vec3 motion = summon.getLookAngle().normalize().scale(getSpeed());
|
Vec3 motion = summon.getLookAngle().normalize().scale(SPEED.get());
|
||||||
Vec3 start = summon.position();
|
Vec3 start = summon.position();
|
||||||
Vec3 end = start.add(motion);
|
Vec3 end = start.add(motion);
|
||||||
|
|
||||||
@@ -103,16 +83,16 @@ public class CrystalBullet extends BulletAmmo {
|
|||||||
|
|
||||||
ItemStack sourceStack = summon.getEntityData().get(StaticSummon.STACK_SOURCE);
|
ItemStack sourceStack = summon.getEntityData().get(StaticSummon.STACK_SOURCE);
|
||||||
Entity target = targets.getFirst();
|
Entity target = targets.getFirst();
|
||||||
if(DamageUtil.rangedAttack(summon, target, sourceStack, getBaseDamage() + damage, knockbackScale)) {
|
if(DamageUtil.rangedAttack(summon, target, sourceStack, BASE_DAMAGE.get() + damage, knockbackScale)) {
|
||||||
target.invulnerableTime = invulnerableTime;
|
target.invulnerableTime = invulnerableTime;
|
||||||
summon.setPos(end);
|
summon.setPos(end);
|
||||||
for(int i = 0;i < getFragmentCount();i++) {
|
for(int i = 0;i < FRAGMENT_COUNT.get();i++) {
|
||||||
summonProjectile(summon, (getBaseDamage() + damage) * getFragmentDamageMultiplier());
|
summonProjectile(summon, (BASE_DAMAGE.get() + damage) * FRAGMENT_DAMAGE_MULTIPLIER.get());
|
||||||
}
|
}
|
||||||
ParticleUtil.addParticles(
|
ParticleUtil.addParticles(
|
||||||
(ServerLevel) summon.level(), ModParticles.CRYSTAL_FRAGMENT_PARTICLE.get(),
|
(ServerLevel) summon.level(), ModParticles.CRYSTAL_FRAGMENT_PARTICLE.get(),
|
||||||
summon.position(), new Vec3(0.2, 0.2, 0.2),
|
summon.position(), new Vec3(0.2, 0.2, 0.2),
|
||||||
0.2, getParticleCount()
|
0.2, PARTICLE_COUNT.get()
|
||||||
);
|
);
|
||||||
this.onDied(summon);
|
this.onDied(summon);
|
||||||
return;
|
return;
|
||||||
@@ -125,13 +105,13 @@ public class CrystalBullet extends BulletAmmo {
|
|||||||
summon.setPos(blockHitResult.getLocation());
|
summon.setPos(blockHitResult.getLocation());
|
||||||
CompoundTag customData = summon.getEntityData().get(StaticSummon.CUSTOM_DATA);
|
CompoundTag customData = summon.getEntityData().get(StaticSummon.CUSTOM_DATA);
|
||||||
float damage = customData.contains("damage") ? customData.getFloat("damage") : 0;
|
float damage = customData.contains("damage") ? customData.getFloat("damage") : 0;
|
||||||
for(int i = 0;i < getFragmentCount();i++) {
|
for(int i = 0;i < FRAGMENT_COUNT.get();i++) {
|
||||||
summonProjectile(summon, (getBaseDamage() + damage) * getFragmentDamageMultiplier());
|
summonProjectile(summon, (BASE_DAMAGE.get() + damage) * FRAGMENT_DAMAGE_MULTIPLIER.get());
|
||||||
}
|
}
|
||||||
ParticleUtil.addParticles(
|
ParticleUtil.addParticles(
|
||||||
(ServerLevel) summon.level(), ModParticles.CRYSTAL_FRAGMENT_PARTICLE.get(),
|
(ServerLevel) summon.level(), ModParticles.CRYSTAL_FRAGMENT_PARTICLE.get(),
|
||||||
summon.position(), new Vec3(0.2, 0.2, 0.2),
|
summon.position(), new Vec3(0.2, 0.2, 0.2),
|
||||||
0.2, getParticleCount()
|
0.2, PARTICLE_COUNT.get()
|
||||||
);
|
);
|
||||||
this.onDied(summon);
|
this.onDied(summon);
|
||||||
return;
|
return;
|
||||||
@@ -188,8 +168,8 @@ public class CrystalBullet extends BulletAmmo {
|
|||||||
projectile.getEntityData().set(StaticProjectile.SCALE_Y, 0.5f);
|
projectile.getEntityData().set(StaticProjectile.SCALE_Y, 0.5f);
|
||||||
projectile.getEntityData().set(StaticProjectile.SCALE_Z, 0.5f);
|
projectile.getEntityData().set(StaticProjectile.SCALE_Z, 0.5f);
|
||||||
projectile.getEntityData().set(StaticProjectile.RXPS, 10);
|
projectile.getEntityData().set(StaticProjectile.RXPS, 10);
|
||||||
projectile.getEntityData().set(StaticProjectile.LIFETIME, getFragmentTime());
|
projectile.getEntityData().set(StaticProjectile.LIFETIME, FRAGMENT_TIME.get());
|
||||||
projectile.getEntityData().set(StaticProjectile.EXPRESSION_Z, String.format("%.3f*t", getFragmentSpeed()));
|
projectile.getEntityData().set(StaticProjectile.EXPRESSION_Z, String.format("%.3f*t", FRAGMENT_SPEED.get()));
|
||||||
|
|
||||||
CompoundTag customData = new CompoundTag();
|
CompoundTag customData = new CompoundTag();
|
||||||
customData.putFloat("damage", damage);
|
customData.putFloat("damage", damage);
|
||||||
|
|||||||
@@ -1,14 +1,22 @@
|
|||||||
package com.lzxnone.terraria.item.ammo;
|
package com.lzxnone.terraria.item.ammo;
|
||||||
|
|
||||||
|
import com.lzxnone.terraria.LzxnoneTerraria;
|
||||||
import com.lzxnone.terraria.effect.ModEffects;
|
import com.lzxnone.terraria.effect.ModEffects;
|
||||||
import com.lzxnone.terraria.entity.summon.IStaticSummonBehavior;
|
import com.lzxnone.terraria.entity.summon.IStaticSummonBehavior;
|
||||||
import com.lzxnone.terraria.entity.summon.StaticSummon;
|
import com.lzxnone.terraria.entity.summon.StaticSummon;
|
||||||
import com.lzxnone.terraria.ui.config.ConfigListItem;
|
import com.lzxnone.terraria.ui.config.ConfigListItem;
|
||||||
import com.lzxnone.terraria.ui.config.IConfigData;
|
import com.lzxnone.terraria.ui.config.IConfigData;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigDouble;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigFloat;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigInt;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigStruct;
|
||||||
import com.lzxnone.terraria.utils.CollisionUtil;
|
import com.lzxnone.terraria.utils.CollisionUtil;
|
||||||
import com.lzxnone.terraria.utils.DamageUtil;
|
import com.lzxnone.terraria.utils.DamageUtil;
|
||||||
import com.lzxnone.terraria.utils.FilterUtil;
|
import com.lzxnone.terraria.utils.FilterUtil;
|
||||||
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
import net.minecraft.network.chat.Component;
|
||||||
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.world.effect.MobEffectInstance;
|
import net.minecraft.world.effect.MobEffectInstance;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.entity.LivingEntity;
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
@@ -22,38 +30,30 @@ import java.util.List;
|
|||||||
|
|
||||||
public class CursedBullet extends BulletAmmo {
|
public class CursedBullet extends BulletAmmo {
|
||||||
public static final String ID = "cursed_bullet";
|
public static final String ID = "cursed_bullet";
|
||||||
public static final float BASE_DAMAGE_DEFAULT = 2.0f;
|
|
||||||
public static final double SPEED_DEFAULT = 3.0D;
|
public static final ConfigFloat BASE_DAMAGE = new ConfigFloat("ammo.cursed_bullet.base_damage", "cursed_bullet_base_damage", 2.0f, 0.0f, 8388600.0f);
|
||||||
public static final int EFFECT_TIME_DEFAULT = 140;
|
public static final ConfigDouble SPEED = new ConfigDouble("ammo.cursed_bullet.speed", "cursed_bullet_speed", 3.0D, 0.0D, 24.0D);
|
||||||
|
public static final ConfigInt EFFECT_TIME = new ConfigInt("ammo.cursed_bullet.effect_time", "cursed_bullet_effect_time", 140, 0, 72000);
|
||||||
|
|
||||||
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
||||||
@Override
|
@Override
|
||||||
public void onConfigLoad() {
|
public void onConfigLoad() {
|
||||||
AmmoConfig.loadFloat(ID, "base_damage", BASE_DAMAGE_DEFAULT, 0.0f, 8388600.0f);
|
ConfigStruct.loadAll(BASE_DAMAGE, SPEED, EFFECT_TIME);
|
||||||
AmmoConfig.loadDouble(ID, "speed", SPEED_DEFAULT, 0.0D, 24.0D);
|
|
||||||
AmmoConfig.loadInt(ID, "effect_time", EFFECT_TIME_DEFAULT, 0, 72000);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public static final ConfigListItem CONFIG_LIST_ITEM = AmmoConfig.createListItem(ID, CONFIG_DATA);
|
public static final ConfigListItem CONFIG_LIST_ITEM = new ConfigListItem(
|
||||||
|
ID,
|
||||||
public static float getBaseDamage() {
|
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/item/" + ID + ".png"),
|
||||||
return AmmoConfig.readFloat(ID, "base_damage", BASE_DAMAGE_DEFAULT, 0.0f, 8388600.0f);
|
Component.translatable("item.lzxnoneterraria." + ID),
|
||||||
}
|
CONFIG_DATA
|
||||||
|
);
|
||||||
public static double getSpeed() {
|
|
||||||
return AmmoConfig.readDouble(ID, "speed", SPEED_DEFAULT, 0.0D, 24.0D);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getEffectTime() {
|
|
||||||
return AmmoConfig.readInt(ID, "effect_time", EFFECT_TIME_DEFAULT, 0, 72000);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final IStaticSummonBehavior SUMMON_BEHAVIOR = new IStaticSummonBehavior() {
|
public static final IStaticSummonBehavior SUMMON_BEHAVIOR = new IStaticSummonBehavior() {
|
||||||
@Override
|
@Override
|
||||||
public void tick(StaticSummon summon) {
|
public void tick(StaticSummon summon) {
|
||||||
this.checkBeforeTick(summon);
|
this.checkBeforeTick(summon);
|
||||||
Vec3 motion = summon.getLookAngle().normalize().scale(getSpeed());
|
Vec3 motion = summon.getLookAngle().normalize().scale(SPEED.get());
|
||||||
Vec3 start = summon.position();
|
Vec3 start = summon.position();
|
||||||
Vec3 end = start.add(motion);
|
Vec3 end = start.add(motion);
|
||||||
|
|
||||||
@@ -77,10 +77,10 @@ public class CursedBullet extends BulletAmmo {
|
|||||||
|
|
||||||
ItemStack sourceStack = summon.getEntityData().get(StaticSummon.STACK_SOURCE);
|
ItemStack sourceStack = summon.getEntityData().get(StaticSummon.STACK_SOURCE);
|
||||||
Entity target = targets.getFirst();
|
Entity target = targets.getFirst();
|
||||||
if(DamageUtil.rangedAttack(summon, target, sourceStack, getBaseDamage() + damage, knockbackScale)) {
|
if(DamageUtil.rangedAttack(summon, target, sourceStack, BASE_DAMAGE.get() + damage, knockbackScale)) {
|
||||||
target.invulnerableTime = invulnerableTime;
|
target.invulnerableTime = invulnerableTime;
|
||||||
if(target instanceof LivingEntity livingEntity) {
|
if(target instanceof LivingEntity livingEntity) {
|
||||||
MobEffectInstance effectInstance = new MobEffectInstance(ModEffects.CURSED_INFERNO, getEffectTime(), 0);
|
MobEffectInstance effectInstance = new MobEffectInstance(ModEffects.CURSED_INFERNO, EFFECT_TIME.get(), 0);
|
||||||
livingEntity.addEffect(effectInstance);
|
livingEntity.addEffect(effectInstance);
|
||||||
}
|
}
|
||||||
this.onDied(summon);
|
this.onDied(summon);
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.lzxnone.terraria.item.ammo;
|
package com.lzxnone.terraria.item.ammo;
|
||||||
|
|
||||||
|
import com.lzxnone.terraria.LzxnoneTerraria;
|
||||||
import com.lzxnone.terraria.ModSounds;
|
import com.lzxnone.terraria.ModSounds;
|
||||||
import com.lzxnone.terraria.entity.summon.IStaticSummonBehavior;
|
import com.lzxnone.terraria.entity.summon.IStaticSummonBehavior;
|
||||||
import com.lzxnone.terraria.entity.summon.StaticSummon;
|
import com.lzxnone.terraria.entity.summon.StaticSummon;
|
||||||
@@ -7,8 +8,15 @@ import com.lzxnone.terraria.particle.DustParticleOptions;
|
|||||||
import com.lzxnone.terraria.particle.ModParticles;
|
import com.lzxnone.terraria.particle.ModParticles;
|
||||||
import com.lzxnone.terraria.ui.config.ConfigListItem;
|
import com.lzxnone.terraria.ui.config.ConfigListItem;
|
||||||
import com.lzxnone.terraria.ui.config.IConfigData;
|
import com.lzxnone.terraria.ui.config.IConfigData;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigDouble;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigFloat;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigInt;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigStruct;
|
||||||
import com.lzxnone.terraria.utils.*;
|
import com.lzxnone.terraria.utils.*;
|
||||||
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
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.ServerLevel;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
@@ -16,44 +24,32 @@ import net.minecraft.world.phys.AABB;
|
|||||||
import net.minecraft.world.phys.BlockHitResult;
|
import net.minecraft.world.phys.BlockHitResult;
|
||||||
import net.minecraft.world.phys.HitResult;
|
import net.minecraft.world.phys.HitResult;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
|
|
||||||
import org.joml.Vector3f;
|
import org.joml.Vector3f;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ExplodingBullet extends BulletAmmo {
|
public class ExplodingBullet extends BulletAmmo {
|
||||||
public static final String ID = "exploding_bullet";
|
public static final String ID = "exploding_bullet";
|
||||||
public static final float BASE_DAMAGE_DEFAULT = 1.5f;
|
|
||||||
public static final double SPEED_DEFAULT = 3.0D;
|
public static final ConfigFloat BASE_DAMAGE = new ConfigFloat("ammo.exploding_bullet.base_damage", "exploding_bullet_base_damage", 1.5f, 0.0f, 8388600.0f);
|
||||||
public static final float KNOCKBACK_MULTIPLIER_DEFAULT = 2.0f;
|
public static final ConfigDouble SPEED = new ConfigDouble("ammo.exploding_bullet.speed", "exploding_bullet_speed", 3.0D, 0.0D, 24.0D);
|
||||||
public static final int DUST_COUNT_DEFAULT = 10;
|
public static final ConfigFloat KNOCKBACK_MULTIPLIER = new ConfigFloat("ammo.exploding_bullet.knockback_multiplier", "exploding_bullet_knockback_multiplier", 2.0f, 0.0f, 100.0f);
|
||||||
|
public static final ConfigInt DUST_COUNT = new ConfigInt("ammo.exploding_bullet.dust_count", "exploding_bullet_dust_count", 10, 0, 1000);
|
||||||
|
|
||||||
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
||||||
@Override
|
@Override
|
||||||
public void onConfigLoad() {
|
public void onConfigLoad() {
|
||||||
AmmoConfig.loadFloat(ID, "base_damage", BASE_DAMAGE_DEFAULT, 0.0f, 8388600.0f);
|
ConfigStruct.loadAll(BASE_DAMAGE, SPEED, KNOCKBACK_MULTIPLIER, DUST_COUNT);
|
||||||
AmmoConfig.loadDouble(ID, "speed", SPEED_DEFAULT, 0.0D, 24.0D);
|
|
||||||
AmmoConfig.loadFloat(ID, "knockback_multiplier", KNOCKBACK_MULTIPLIER_DEFAULT, 0.0f, 100.0f);
|
|
||||||
AmmoConfig.loadInt(ID, "dust_count", DUST_COUNT_DEFAULT, 0, 1000);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public static final ConfigListItem CONFIG_LIST_ITEM = AmmoConfig.createListItem(ID, CONFIG_DATA);
|
public static final ConfigListItem CONFIG_LIST_ITEM = new ConfigListItem(
|
||||||
|
ID,
|
||||||
public static float getBaseDamage() {
|
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/item/" + ID + ".png"),
|
||||||
return AmmoConfig.readFloat(ID, "base_damage", BASE_DAMAGE_DEFAULT, 0.0f, 8388600.0f);
|
Component.translatable("item.lzxnoneterraria." + ID),
|
||||||
}
|
CONFIG_DATA
|
||||||
|
);
|
||||||
public static double getSpeed() {
|
|
||||||
return AmmoConfig.readDouble(ID, "speed", SPEED_DEFAULT, 0.0D, 24.0D);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static float getKnockbackMultiplier() {
|
|
||||||
return AmmoConfig.readFloat(ID, "knockback_multiplier", KNOCKBACK_MULTIPLIER_DEFAULT, 0.0f, 100.0f);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getDustCount() {
|
|
||||||
return AmmoConfig.readInt(ID, "dust_count", DUST_COUNT_DEFAULT, 0, 1000);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final DustParticleOptions PARTICLE = new DustParticleOptions(
|
public static final DustParticleOptions PARTICLE = new DustParticleOptions(
|
||||||
0.075f, 0.5f, 40, true, new Vector3f[]{
|
0.075f, 0.5f, 40, true, new Vector3f[]{
|
||||||
@@ -67,7 +63,7 @@ public class ExplodingBullet extends BulletAmmo {
|
|||||||
@Override
|
@Override
|
||||||
public void tick(StaticSummon summon) {
|
public void tick(StaticSummon summon) {
|
||||||
this.checkBeforeTick(summon);
|
this.checkBeforeTick(summon);
|
||||||
Vec3 motion = summon.getLookAngle().normalize().scale(getSpeed());
|
Vec3 motion = summon.getLookAngle().normalize().scale(SPEED.get());
|
||||||
Vec3 start = summon.position();
|
Vec3 start = summon.position();
|
||||||
Vec3 end = start.add(motion);
|
Vec3 end = start.add(motion);
|
||||||
|
|
||||||
@@ -92,7 +88,7 @@ public class ExplodingBullet extends BulletAmmo {
|
|||||||
ItemStack sourceStack = summon.getEntityData().get(StaticSummon.STACK_SOURCE);
|
ItemStack sourceStack = summon.getEntityData().get(StaticSummon.STACK_SOURCE);
|
||||||
boolean dead = false;
|
boolean dead = false;
|
||||||
for(Entity target : targets) {
|
for(Entity target : targets) {
|
||||||
if(DamageUtil.rangedAttack(summon, target, sourceStack, getBaseDamage() + damage, knockbackScale * getKnockbackMultiplier())) {
|
if(DamageUtil.rangedAttack(summon, target, sourceStack, BASE_DAMAGE.get() + damage, knockbackScale * KNOCKBACK_MULTIPLIER.get())) {
|
||||||
dead = true;
|
dead = true;
|
||||||
target.invulnerableTime = invulnerableTime;
|
target.invulnerableTime = invulnerableTime;
|
||||||
SoundUtil.playServerSound(summon.level(), ModSounds.BOOM.get(), summon.position());
|
SoundUtil.playServerSound(summon.level(), ModSounds.BOOM.get(), summon.position());
|
||||||
@@ -109,7 +105,7 @@ public class ExplodingBullet extends BulletAmmo {
|
|||||||
ParticleUtil.addParticles(
|
ParticleUtil.addParticles(
|
||||||
(ServerLevel) summon.level(), PARTICLE,
|
(ServerLevel) summon.level(), PARTICLE,
|
||||||
summon.position(), new Vec3(0, 0, 0),
|
summon.position(), new Vec3(0, 0, 0),
|
||||||
0.2, getDustCount()
|
0.2, DUST_COUNT.get()
|
||||||
);
|
);
|
||||||
this.onDied(summon);
|
this.onDied(summon);
|
||||||
return;
|
return;
|
||||||
@@ -129,7 +125,7 @@ public class ExplodingBullet extends BulletAmmo {
|
|||||||
ParticleUtil.addParticles(
|
ParticleUtil.addParticles(
|
||||||
(ServerLevel) summon.level(), PARTICLE,
|
(ServerLevel) summon.level(), PARTICLE,
|
||||||
summon.position(), new Vec3(0, 0, 0),
|
summon.position(), new Vec3(0, 0, 0),
|
||||||
0.2, getDustCount()
|
0.2, DUST_COUNT.get()
|
||||||
);
|
);
|
||||||
this.onDied(summon);
|
this.onDied(summon);
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
package com.lzxnone.terraria.item.ammo;
|
||||||
|
|
||||||
|
public class FallenStar extends BulletAmmo {
|
||||||
|
}
|
||||||
@@ -4,13 +4,16 @@ import com.lzxnone.terraria.LzxnoneTerraria;
|
|||||||
import com.lzxnone.terraria.effect.ModEffects;
|
import com.lzxnone.terraria.effect.ModEffects;
|
||||||
import com.lzxnone.terraria.entity.summon.IStaticSummonBehavior;
|
import com.lzxnone.terraria.entity.summon.IStaticSummonBehavior;
|
||||||
import com.lzxnone.terraria.entity.summon.StaticSummon;
|
import com.lzxnone.terraria.entity.summon.StaticSummon;
|
||||||
import com.lzxnone.terraria.ui.config.ConfigFactory;
|
|
||||||
import com.lzxnone.terraria.ui.config.ConfigListItem;
|
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.ui.config.IConfigData;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigDouble;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigFloat;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigInt;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigStruct;
|
||||||
import com.lzxnone.terraria.utils.CollisionUtil;
|
import com.lzxnone.terraria.utils.CollisionUtil;
|
||||||
import com.lzxnone.terraria.utils.DamageUtil;
|
import com.lzxnone.terraria.utils.DamageUtil;
|
||||||
import com.lzxnone.terraria.utils.FilterUtil;
|
import com.lzxnone.terraria.utils.FilterUtil;
|
||||||
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
@@ -26,52 +29,19 @@ import net.minecraft.world.phys.Vec3;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class GoldenBullet extends BulletAmmo {
|
public class GoldenBullet extends BulletAmmo {
|
||||||
private static final String CONFIG_TRANSLATION_PREFIX = "lzxnoneterraria.configuration.";
|
public static final ConfigFloat BASE_DAMAGE = new ConfigFloat("ammo.golden_bullet.base_damage", "golden_bullet_base_damage", 1.5f, 0.0f, 8388600.0f);
|
||||||
|
|
||||||
public static final String BASE_DAMAGE_PATH = "ammo.golden_bullet.base_damage";
|
public static final ConfigDouble SPEED = new ConfigDouble("ammo.golden_bullet.speed", "golden_bullet_speed", 3.0D, 0.0D, 24.0D);
|
||||||
public static final float BASE_DAMAGE_DEFAULT = 1.5f;
|
|
||||||
public static final float BASE_DAMAGE_MIN = 0.0f;
|
|
||||||
public static final float BASE_DAMAGE_MAX = 8388600.0f;
|
|
||||||
|
|
||||||
public static final String SPEED_PATH = "ammo.golden_bullet.speed";
|
public static final ConfigInt EFFECT_TIME = new ConfigInt("ammo.golden_bullet.effect_time", "golden_bullet_effect_time", 40, 0, 72000);
|
||||||
public static final double SPEED_DEFAULT = 3.0D;
|
|
||||||
public static final double SPEED_MIN = 0.0D;
|
|
||||||
public static final double SPEED_MAX = 24.0D;
|
|
||||||
|
|
||||||
public static final String EFFECT_TIME_PATH = "ammo.golden_bullet.effect_time";
|
|
||||||
public static final int EFFECT_TIME_DEFAULT = 40;
|
|
||||||
public static final int EFFECT_TIME_MIN = 0;
|
|
||||||
public static final int EFFECT_TIME_MAX = 72000;
|
|
||||||
|
|
||||||
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
||||||
@Override
|
@Override
|
||||||
public void onConfigLoad() {
|
public void onConfigLoad() {
|
||||||
ConfigFactory.loadFloatConfig(BASE_DAMAGE_PATH, configText("golden_bullet_base_damage"), configTooltip("golden_bullet_base_damage"), BASE_DAMAGE_DEFAULT, BASE_DAMAGE_MIN, BASE_DAMAGE_MAX);
|
ConfigStruct.loadAll(BASE_DAMAGE, SPEED, EFFECT_TIME);
|
||||||
ConfigFactory.loadDoubleConfig(SPEED_PATH, configText("golden_bullet_speed"), configTooltip("golden_bullet_speed"), SPEED_DEFAULT, SPEED_MIN, SPEED_MAX);
|
|
||||||
ConfigFactory.loadIntConfig(EFFECT_TIME_PATH, configText("golden_bullet_effect_time"), configTooltip("golden_bullet_effect_time"), EFFECT_TIME_DEFAULT, EFFECT_TIME_MIN, EFFECT_TIME_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 float getBaseDamage() {
|
|
||||||
return Math.clamp(ConfigUtil.readFloat(BASE_DAMAGE_PATH, BASE_DAMAGE_DEFAULT), BASE_DAMAGE_MIN, BASE_DAMAGE_MAX);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static double getSpeed() {
|
|
||||||
return Math.clamp(ConfigUtil.readDouble(SPEED_PATH, SPEED_DEFAULT), SPEED_MIN, SPEED_MAX);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getEffectTime() {
|
|
||||||
return Math.clamp(ConfigUtil.readInt(EFFECT_TIME_PATH, EFFECT_TIME_DEFAULT), EFFECT_TIME_MIN, EFFECT_TIME_MAX);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final ConfigListItem CONFIG_LIST_ITEM = new ConfigListItem(
|
public static final ConfigListItem CONFIG_LIST_ITEM = new ConfigListItem(
|
||||||
"golden_bullet",
|
"golden_bullet",
|
||||||
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/item/golden_bullet.png"),
|
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/item/golden_bullet.png"),
|
||||||
@@ -83,7 +53,7 @@ public class GoldenBullet extends BulletAmmo {
|
|||||||
@Override
|
@Override
|
||||||
public void tick(StaticSummon summon) {
|
public void tick(StaticSummon summon) {
|
||||||
this.checkBeforeTick(summon);
|
this.checkBeforeTick(summon);
|
||||||
Vec3 motion = summon.getLookAngle().normalize().scale(getSpeed());
|
Vec3 motion = summon.getLookAngle().normalize().scale(SPEED.get());
|
||||||
Vec3 start = summon.position();
|
Vec3 start = summon.position();
|
||||||
Vec3 end = start.add(motion);
|
Vec3 end = start.add(motion);
|
||||||
|
|
||||||
@@ -107,10 +77,10 @@ public class GoldenBullet extends BulletAmmo {
|
|||||||
|
|
||||||
ItemStack sourceStack = summon.getEntityData().get(StaticSummon.STACK_SOURCE);
|
ItemStack sourceStack = summon.getEntityData().get(StaticSummon.STACK_SOURCE);
|
||||||
Entity target = targets.getFirst();
|
Entity target = targets.getFirst();
|
||||||
if(DamageUtil.rangedAttack(summon, target, sourceStack, getBaseDamage() + damage, knockbackScale)) {
|
if(DamageUtil.rangedAttack(summon, target, sourceStack, BASE_DAMAGE.get() + damage, knockbackScale)) {
|
||||||
target.invulnerableTime = invulnerableTime;
|
target.invulnerableTime = invulnerableTime;
|
||||||
if(target instanceof LivingEntity livingEntity) {
|
if(target instanceof LivingEntity livingEntity) {
|
||||||
MobEffectInstance effectInstance = new MobEffectInstance(ModEffects.MIDAS, getEffectTime(), 0);
|
MobEffectInstance effectInstance = new MobEffectInstance(ModEffects.MIDAS, EFFECT_TIME.get(), 0);
|
||||||
livingEntity.addEffect(effectInstance);
|
livingEntity.addEffect(effectInstance);
|
||||||
}
|
}
|
||||||
this.onDied(summon);
|
this.onDied(summon);
|
||||||
|
|||||||
@@ -1,13 +1,21 @@
|
|||||||
package com.lzxnone.terraria.item.ammo;
|
package com.lzxnone.terraria.item.ammo;
|
||||||
|
|
||||||
|
import com.lzxnone.terraria.LzxnoneTerraria;
|
||||||
import com.lzxnone.terraria.entity.summon.IStaticSummonBehavior;
|
import com.lzxnone.terraria.entity.summon.IStaticSummonBehavior;
|
||||||
import com.lzxnone.terraria.entity.summon.StaticSummon;
|
import com.lzxnone.terraria.entity.summon.StaticSummon;
|
||||||
import com.lzxnone.terraria.ui.config.ConfigListItem;
|
import com.lzxnone.terraria.ui.config.ConfigListItem;
|
||||||
import com.lzxnone.terraria.ui.config.IConfigData;
|
import com.lzxnone.terraria.ui.config.IConfigData;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigDouble;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigFloat;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigInt;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigStruct;
|
||||||
import com.lzxnone.terraria.utils.CollisionUtil;
|
import com.lzxnone.terraria.utils.CollisionUtil;
|
||||||
import com.lzxnone.terraria.utils.DamageUtil;
|
import com.lzxnone.terraria.utils.DamageUtil;
|
||||||
import com.lzxnone.terraria.utils.FilterUtil;
|
import com.lzxnone.terraria.utils.FilterUtil;
|
||||||
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
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.Entity;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.phys.AABB;
|
import net.minecraft.world.phys.AABB;
|
||||||
@@ -19,44 +27,31 @@ import java.util.List;
|
|||||||
|
|
||||||
public class HighVelocityBullet extends BulletAmmo {
|
public class HighVelocityBullet extends BulletAmmo {
|
||||||
public static final String ID = "high_velocity_bullet";
|
public static final String ID = "high_velocity_bullet";
|
||||||
public static final float BASE_DAMAGE_DEFAULT = 1.5f;
|
|
||||||
public static final double SPEED_DEFAULT = 4.0D;
|
public static final ConfigFloat BASE_DAMAGE = new ConfigFloat("ammo.high_velocity_bullet.base_damage", "high_velocity_bullet_base_damage", 1.5f, 0.0f, 8388600.0f);
|
||||||
public static final float DAMAGE_DECAY_DEFAULT = 0.85f;
|
public static final ConfigDouble SPEED = new ConfigDouble("ammo.high_velocity_bullet.speed", "high_velocity_bullet_speed", 4.0D, 0.0D, 24.0D);
|
||||||
public static final int MAX_HIT_DEFAULT = 3;
|
public static final ConfigFloat DAMAGE_DECAY = new ConfigFloat("ammo.high_velocity_bullet.damage_decay", "high_velocity_bullet_damage_decay", 0.85f, 0.0f, 1.0f);
|
||||||
|
public static final ConfigInt MAX_HIT = new ConfigInt("ammo.high_velocity_bullet.max_hit", "high_velocity_bullet_max_hit", 3, 1, 100);
|
||||||
|
|
||||||
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
||||||
@Override
|
@Override
|
||||||
public void onConfigLoad() {
|
public void onConfigLoad() {
|
||||||
AmmoConfig.loadFloat(ID, "base_damage", BASE_DAMAGE_DEFAULT, 0.0f, 8388600.0f);
|
ConfigStruct.loadAll(BASE_DAMAGE, SPEED, DAMAGE_DECAY, MAX_HIT);
|
||||||
AmmoConfig.loadDouble(ID, "speed", SPEED_DEFAULT, 0.0D, 24.0D);
|
|
||||||
AmmoConfig.loadFloat(ID, "damage_decay", DAMAGE_DECAY_DEFAULT, 0.0f, 1.0f);
|
|
||||||
AmmoConfig.loadInt(ID, "max_hit", MAX_HIT_DEFAULT, 1, 100);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public static final ConfigListItem CONFIG_LIST_ITEM = AmmoConfig.createListItem(ID, CONFIG_DATA);
|
public static final ConfigListItem CONFIG_LIST_ITEM = new ConfigListItem(
|
||||||
|
ID,
|
||||||
public static float getBaseDamage() {
|
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/item/" + ID + ".png"),
|
||||||
return AmmoConfig.readFloat(ID, "base_damage", BASE_DAMAGE_DEFAULT, 0.0f, 8388600.0f);
|
Component.translatable("item.lzxnoneterraria." + ID),
|
||||||
}
|
CONFIG_DATA
|
||||||
|
);
|
||||||
public static double getSpeed() {
|
|
||||||
return AmmoConfig.readDouble(ID, "speed", SPEED_DEFAULT, 0.0D, 24.0D);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static float getDamageDecay() {
|
|
||||||
return AmmoConfig.readFloat(ID, "damage_decay", DAMAGE_DECAY_DEFAULT, 0.0f, 1.0f);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getMaxHit() {
|
|
||||||
return AmmoConfig.readInt(ID, "max_hit", MAX_HIT_DEFAULT, 1, 100);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final IStaticSummonBehavior SUMMON_BEHAVIOR = new IStaticSummonBehavior() {
|
public static final IStaticSummonBehavior SUMMON_BEHAVIOR = new IStaticSummonBehavior() {
|
||||||
@Override
|
@Override
|
||||||
public void tick(StaticSummon summon) {
|
public void tick(StaticSummon summon) {
|
||||||
this.checkBeforeTick(summon);
|
this.checkBeforeTick(summon);
|
||||||
Vec3 motion = summon.getLookAngle().normalize().scale(getSpeed());
|
Vec3 motion = summon.getLookAngle().normalize().scale(SPEED.get());
|
||||||
Vec3 start = summon.position();
|
Vec3 start = summon.position();
|
||||||
Vec3 end = start.add(motion);
|
Vec3 end = start.add(motion);
|
||||||
|
|
||||||
@@ -82,9 +77,9 @@ public class HighVelocityBullet extends BulletAmmo {
|
|||||||
|
|
||||||
for(Entity target : targets) {
|
for(Entity target : targets) {
|
||||||
int hit = customData.getInt("hit");
|
int hit = customData.getInt("hit");
|
||||||
if(DamageUtil.rangedAttack(summon, target, sourceStack, (getBaseDamage() + damage) * (float) Math.pow(getDamageDecay(), hit), knockbackScale)) {
|
if(DamageUtil.rangedAttack(summon, target, sourceStack, (BASE_DAMAGE.get() + damage) * (float) Math.pow(DAMAGE_DECAY.get(), hit), knockbackScale)) {
|
||||||
target.invulnerableTime = invulnerableTime;
|
target.invulnerableTime = invulnerableTime;
|
||||||
if(incrementHit(summon) >= getMaxHit()) {
|
if(incrementHit(summon) >= MAX_HIT.get()) {
|
||||||
this.onDied(summon);
|
this.onDied(summon);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,22 @@
|
|||||||
package com.lzxnone.terraria.item.ammo;
|
package com.lzxnone.terraria.item.ammo;
|
||||||
|
|
||||||
|
import com.lzxnone.terraria.LzxnoneTerraria;
|
||||||
import com.lzxnone.terraria.effect.ModEffects;
|
import com.lzxnone.terraria.effect.ModEffects;
|
||||||
import com.lzxnone.terraria.entity.summon.IStaticSummonBehavior;
|
import com.lzxnone.terraria.entity.summon.IStaticSummonBehavior;
|
||||||
import com.lzxnone.terraria.entity.summon.StaticSummon;
|
import com.lzxnone.terraria.entity.summon.StaticSummon;
|
||||||
import com.lzxnone.terraria.ui.config.ConfigListItem;
|
import com.lzxnone.terraria.ui.config.ConfigListItem;
|
||||||
import com.lzxnone.terraria.ui.config.IConfigData;
|
import com.lzxnone.terraria.ui.config.IConfigData;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigDouble;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigFloat;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigInt;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigStruct;
|
||||||
import com.lzxnone.terraria.utils.CollisionUtil;
|
import com.lzxnone.terraria.utils.CollisionUtil;
|
||||||
import com.lzxnone.terraria.utils.DamageUtil;
|
import com.lzxnone.terraria.utils.DamageUtil;
|
||||||
import com.lzxnone.terraria.utils.FilterUtil;
|
import com.lzxnone.terraria.utils.FilterUtil;
|
||||||
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
import net.minecraft.network.chat.Component;
|
||||||
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.world.effect.MobEffectInstance;
|
import net.minecraft.world.effect.MobEffectInstance;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.entity.LivingEntity;
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
@@ -22,38 +30,30 @@ import java.util.List;
|
|||||||
|
|
||||||
public class IchorBullet extends BulletAmmo {
|
public class IchorBullet extends BulletAmmo {
|
||||||
public static final String ID = "ichor_bullet";
|
public static final String ID = "ichor_bullet";
|
||||||
public static final float BASE_DAMAGE_DEFAULT = 2.25f;
|
|
||||||
public static final double SPEED_DEFAULT = 3.0D;
|
public static final ConfigFloat BASE_DAMAGE = new ConfigFloat("ammo.ichor_bullet.base_damage", "ichor_bullet_base_damage", 2.25f, 0.0f, 8388600.0f);
|
||||||
public static final int EFFECT_TIME_DEFAULT = 200;
|
public static final ConfigDouble SPEED = new ConfigDouble("ammo.ichor_bullet.speed", "ichor_bullet_speed", 3.0D, 0.0D, 24.0D);
|
||||||
|
public static final ConfigInt EFFECT_TIME = new ConfigInt("ammo.ichor_bullet.effect_time", "ichor_bullet_effect_time", 200, 0, 72000);
|
||||||
|
|
||||||
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
||||||
@Override
|
@Override
|
||||||
public void onConfigLoad() {
|
public void onConfigLoad() {
|
||||||
AmmoConfig.loadFloat(ID, "base_damage", BASE_DAMAGE_DEFAULT, 0.0f, 8388600.0f);
|
ConfigStruct.loadAll(BASE_DAMAGE, SPEED, EFFECT_TIME);
|
||||||
AmmoConfig.loadDouble(ID, "speed", SPEED_DEFAULT, 0.0D, 24.0D);
|
|
||||||
AmmoConfig.loadInt(ID, "effect_time", EFFECT_TIME_DEFAULT, 0, 72000);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public static final ConfigListItem CONFIG_LIST_ITEM = AmmoConfig.createListItem(ID, CONFIG_DATA);
|
public static final ConfigListItem CONFIG_LIST_ITEM = new ConfigListItem(
|
||||||
|
ID,
|
||||||
public static float getBaseDamage() {
|
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/item/" + ID + ".png"),
|
||||||
return AmmoConfig.readFloat(ID, "base_damage", BASE_DAMAGE_DEFAULT, 0.0f, 8388600.0f);
|
Component.translatable("item.lzxnoneterraria." + ID),
|
||||||
}
|
CONFIG_DATA
|
||||||
|
);
|
||||||
public static double getSpeed() {
|
|
||||||
return AmmoConfig.readDouble(ID, "speed", SPEED_DEFAULT, 0.0D, 24.0D);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getEffectTime() {
|
|
||||||
return AmmoConfig.readInt(ID, "effect_time", EFFECT_TIME_DEFAULT, 0, 72000);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final IStaticSummonBehavior SUMMON_BEHAVIOR = new IStaticSummonBehavior() {
|
public static final IStaticSummonBehavior SUMMON_BEHAVIOR = new IStaticSummonBehavior() {
|
||||||
@Override
|
@Override
|
||||||
public void tick(StaticSummon summon) {
|
public void tick(StaticSummon summon) {
|
||||||
this.checkBeforeTick(summon);
|
this.checkBeforeTick(summon);
|
||||||
Vec3 motion = summon.getLookAngle().normalize().scale(getSpeed());
|
Vec3 motion = summon.getLookAngle().normalize().scale(SPEED.get());
|
||||||
Vec3 start = summon.position();
|
Vec3 start = summon.position();
|
||||||
Vec3 end = start.add(motion);
|
Vec3 end = start.add(motion);
|
||||||
|
|
||||||
@@ -77,10 +77,10 @@ public class IchorBullet extends BulletAmmo {
|
|||||||
|
|
||||||
ItemStack sourceStack = summon.getEntityData().get(StaticSummon.STACK_SOURCE);
|
ItemStack sourceStack = summon.getEntityData().get(StaticSummon.STACK_SOURCE);
|
||||||
Entity target = targets.getFirst();
|
Entity target = targets.getFirst();
|
||||||
if(DamageUtil.rangedAttack(summon, target, sourceStack, getBaseDamage() + damage, knockbackScale)) {
|
if(DamageUtil.rangedAttack(summon, target, sourceStack, BASE_DAMAGE.get() + damage, knockbackScale)) {
|
||||||
target.invulnerableTime = invulnerableTime;
|
target.invulnerableTime = invulnerableTime;
|
||||||
if(target instanceof LivingEntity livingEntity) {
|
if(target instanceof LivingEntity livingEntity) {
|
||||||
MobEffectInstance effectInstance = new MobEffectInstance(ModEffects.ICHOR, getEffectTime(), 0);
|
MobEffectInstance effectInstance = new MobEffectInstance(ModEffects.ICHOR, EFFECT_TIME.get(), 0);
|
||||||
livingEntity.addEffect(effectInstance);
|
livingEntity.addEffect(effectInstance);
|
||||||
}
|
}
|
||||||
this.onDied(summon);
|
this.onDied(summon);
|
||||||
|
|||||||
@@ -1,15 +1,22 @@
|
|||||||
package com.lzxnone.terraria.item.ammo;
|
package com.lzxnone.terraria.item.ammo;
|
||||||
|
|
||||||
|
import com.lzxnone.terraria.LzxnoneTerraria;
|
||||||
import com.lzxnone.terraria.entity.summon.IStaticSummonBehavior;
|
import com.lzxnone.terraria.entity.summon.IStaticSummonBehavior;
|
||||||
import com.lzxnone.terraria.entity.summon.StaticSummon;
|
import com.lzxnone.terraria.entity.summon.StaticSummon;
|
||||||
import com.lzxnone.terraria.particle.DustParticleOptions;
|
import com.lzxnone.terraria.particle.DustParticleOptions;
|
||||||
import com.lzxnone.terraria.ui.config.ConfigListItem;
|
import com.lzxnone.terraria.ui.config.ConfigListItem;
|
||||||
import com.lzxnone.terraria.ui.config.IConfigData;
|
import com.lzxnone.terraria.ui.config.IConfigData;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigDouble;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigFloat;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigStruct;
|
||||||
import com.lzxnone.terraria.utils.CollisionUtil;
|
import com.lzxnone.terraria.utils.CollisionUtil;
|
||||||
import com.lzxnone.terraria.utils.DamageUtil;
|
import com.lzxnone.terraria.utils.DamageUtil;
|
||||||
import com.lzxnone.terraria.utils.FilterUtil;
|
import com.lzxnone.terraria.utils.FilterUtil;
|
||||||
import com.lzxnone.terraria.utils.ParticleUtil;
|
import com.lzxnone.terraria.utils.ParticleUtil;
|
||||||
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
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.ServerLevel;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
@@ -17,38 +24,31 @@ import net.minecraft.world.phys.AABB;
|
|||||||
import net.minecraft.world.phys.BlockHitResult;
|
import net.minecraft.world.phys.BlockHitResult;
|
||||||
import net.minecraft.world.phys.HitResult;
|
import net.minecraft.world.phys.HitResult;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
|
|
||||||
import org.joml.Vector3f;
|
import org.joml.Vector3f;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class LuminiteBullet extends BulletAmmo {
|
public class LuminiteBullet extends BulletAmmo {
|
||||||
public static final String ID = "luminite_bullet";
|
public static final String ID = "luminite_bullet";
|
||||||
public static final float BASE_DAMAGE_DEFAULT = 3.0f;
|
|
||||||
public static final double SPEED_DEFAULT = 3.5D;
|
public static final ConfigFloat BASE_DAMAGE = new ConfigFloat("ammo.luminite_bullet.base_damage", "luminite_bullet_base_damage", 3.0f, 0.0f, 8388600.0f);
|
||||||
public static final float DAMAGE_DECAY_DEFAULT = 0.96f;
|
public static final ConfigDouble SPEED = new ConfigDouble("ammo.luminite_bullet.speed", "luminite_bullet_speed", 3.5D, 0.0D, 24.0D);
|
||||||
|
public static final ConfigFloat DAMAGE_DECAY = new ConfigFloat("ammo.luminite_bullet.damage_decay", "luminite_bullet_damage_decay", 0.96f, 0.0f, 1.0f);
|
||||||
|
|
||||||
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
||||||
@Override
|
@Override
|
||||||
public void onConfigLoad() {
|
public void onConfigLoad() {
|
||||||
AmmoConfig.loadFloat(ID, "base_damage", BASE_DAMAGE_DEFAULT, 0.0f, 8388600.0f);
|
ConfigStruct.loadAll(BASE_DAMAGE, SPEED, DAMAGE_DECAY);
|
||||||
AmmoConfig.loadDouble(ID, "speed", SPEED_DEFAULT, 0.0D, 24.0D);
|
|
||||||
AmmoConfig.loadFloat(ID, "damage_decay", DAMAGE_DECAY_DEFAULT, 0.0f, 1.0f);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public static final ConfigListItem CONFIG_LIST_ITEM = AmmoConfig.createListItem(ID, CONFIG_DATA);
|
public static final ConfigListItem CONFIG_LIST_ITEM = new ConfigListItem(
|
||||||
|
ID,
|
||||||
public static float getBaseDamage() {
|
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/item/" + ID + ".png"),
|
||||||
return AmmoConfig.readFloat(ID, "base_damage", BASE_DAMAGE_DEFAULT, 0.0f, 8388600.0f);
|
Component.translatable("item.lzxnoneterraria." + ID),
|
||||||
}
|
CONFIG_DATA
|
||||||
|
);
|
||||||
public static double getSpeed() {
|
|
||||||
return AmmoConfig.readDouble(ID, "speed", SPEED_DEFAULT, 0.0D, 24.0D);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static float getDamageDecay() {
|
|
||||||
return AmmoConfig.readFloat(ID, "damage_decay", DAMAGE_DECAY_DEFAULT, 0.0f, 1.0f);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final DustParticleOptions PARTICLE = new DustParticleOptions(
|
public static final DustParticleOptions PARTICLE = new DustParticleOptions(
|
||||||
0.025f, 0.5f, 40, true, new Vector3f[]{
|
0.025f, 0.5f, 40, true, new Vector3f[]{
|
||||||
@@ -61,7 +61,7 @@ public class LuminiteBullet extends BulletAmmo {
|
|||||||
@Override
|
@Override
|
||||||
public void tick(StaticSummon summon) {
|
public void tick(StaticSummon summon) {
|
||||||
this.checkBeforeTick(summon);
|
this.checkBeforeTick(summon);
|
||||||
Vec3 motion = summon.getLookAngle().normalize().scale(getSpeed());
|
Vec3 motion = summon.getLookAngle().normalize().scale(SPEED.get());
|
||||||
Vec3 start = summon.position();
|
Vec3 start = summon.position();
|
||||||
Vec3 end = start.add(motion);
|
Vec3 end = start.add(motion);
|
||||||
|
|
||||||
@@ -87,7 +87,7 @@ public class LuminiteBullet extends BulletAmmo {
|
|||||||
|
|
||||||
for(Entity target : targets) {
|
for(Entity target : targets) {
|
||||||
int hit = customData.getInt("hit");
|
int hit = customData.getInt("hit");
|
||||||
if(DamageUtil.rangedAttack(summon, target, sourceStack, (getBaseDamage() + damage) * (float) Math.pow(getDamageDecay(), hit), knockbackScale)) {
|
if(DamageUtil.rangedAttack(summon, target, sourceStack, (BASE_DAMAGE.get() + damage) * (float) Math.pow(DAMAGE_DECAY.get(), hit), knockbackScale)) {
|
||||||
target.invulnerableTime = invulnerableTime;
|
target.invulnerableTime = invulnerableTime;
|
||||||
hit++;
|
hit++;
|
||||||
customData.putInt("hit", hit);
|
customData.putInt("hit", hit);
|
||||||
|
|||||||
@@ -3,14 +3,17 @@ package com.lzxnone.terraria.item.ammo;
|
|||||||
import com.lzxnone.terraria.LzxnoneTerraria;
|
import com.lzxnone.terraria.LzxnoneTerraria;
|
||||||
import com.lzxnone.terraria.entity.summon.IStaticSummonBehavior;
|
import com.lzxnone.terraria.entity.summon.IStaticSummonBehavior;
|
||||||
import com.lzxnone.terraria.entity.summon.StaticSummon;
|
import com.lzxnone.terraria.entity.summon.StaticSummon;
|
||||||
import com.lzxnone.terraria.ui.config.ConfigFactory;
|
|
||||||
import com.lzxnone.terraria.ui.config.ConfigListItem;
|
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.ui.config.IConfigData;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigDouble;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigFloat;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigInt;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigStruct;
|
||||||
import com.lzxnone.terraria.utils.CollisionUtil;
|
import com.lzxnone.terraria.utils.CollisionUtil;
|
||||||
import com.lzxnone.terraria.utils.DamageUtil;
|
import com.lzxnone.terraria.utils.DamageUtil;
|
||||||
import com.lzxnone.terraria.utils.FilterUtil;
|
import com.lzxnone.terraria.utils.FilterUtil;
|
||||||
import com.lzxnone.terraria.utils.MathUtil;
|
import com.lzxnone.terraria.utils.MathUtil;
|
||||||
|
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
@@ -25,52 +28,19 @@ import net.minecraft.world.phys.Vec3;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class MeteorShot extends BulletAmmo {
|
public class MeteorShot extends BulletAmmo {
|
||||||
private static final String CONFIG_TRANSLATION_PREFIX = "lzxnoneterraria.configuration.";
|
public static final ConfigFloat BASE_DAMAGE = new ConfigFloat("ammo.meteor_shot.base_damage", "meteor_shot_base_damage", 1.0f, 0.0f, 8388600.0f);
|
||||||
|
|
||||||
public static final String BASE_DAMAGE_PATH = "ammo.meteor_shot.base_damage";
|
public static final ConfigDouble SPEED = new ConfigDouble("ammo.meteor_shot.speed", "meteor_shot_speed", 3.0D, 0.0D, 24.0D);
|
||||||
public static final float BASE_DAMAGE_DEFAULT = 1.0f;
|
|
||||||
public static final float BASE_DAMAGE_MIN = 0.0f;
|
|
||||||
public static final float BASE_DAMAGE_MAX = 8388600.0f;
|
|
||||||
|
|
||||||
public static final String SPEED_PATH = "ammo.meteor_shot.speed";
|
public static final ConfigInt MAX_HIT = new ConfigInt("ammo.meteor_shot.max_hit", "meteor_shot_max_hit", 2, 1, 256);
|
||||||
public static final double SPEED_DEFAULT = 3.0D;
|
|
||||||
public static final double SPEED_MIN = 0.0D;
|
|
||||||
public static final double SPEED_MAX = 24.0D;
|
|
||||||
|
|
||||||
public static final String MAX_HIT_PATH = "ammo.meteor_shot.max_hit";
|
|
||||||
public static final int MAX_HIT_DEFAULT = 2;
|
|
||||||
public static final int MAX_HIT_MIN = 1;
|
|
||||||
public static final int MAX_HIT_MAX = 256;
|
|
||||||
|
|
||||||
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
||||||
@Override
|
@Override
|
||||||
public void onConfigLoad() {
|
public void onConfigLoad() {
|
||||||
ConfigFactory.loadFloatConfig(BASE_DAMAGE_PATH, configText("meteor_shot_base_damage"), configTooltip("meteor_shot_base_damage"), BASE_DAMAGE_DEFAULT, BASE_DAMAGE_MIN, BASE_DAMAGE_MAX);
|
ConfigStruct.loadAll(BASE_DAMAGE, SPEED, MAX_HIT);
|
||||||
ConfigFactory.loadDoubleConfig(SPEED_PATH, configText("meteor_shot_speed"), configTooltip("meteor_shot_speed"), SPEED_DEFAULT, SPEED_MIN, SPEED_MAX);
|
|
||||||
ConfigFactory.loadIntConfig(MAX_HIT_PATH, configText("meteor_shot_max_hit"), configTooltip("meteor_shot_max_hit"), MAX_HIT_DEFAULT, MAX_HIT_MIN, MAX_HIT_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 float getBaseDamage() {
|
|
||||||
return Math.clamp(ConfigUtil.readFloat(BASE_DAMAGE_PATH, BASE_DAMAGE_DEFAULT), BASE_DAMAGE_MIN, BASE_DAMAGE_MAX);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static double getSpeed() {
|
|
||||||
return Math.clamp(ConfigUtil.readDouble(SPEED_PATH, SPEED_DEFAULT), SPEED_MIN, SPEED_MAX);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getMaxHit() {
|
|
||||||
return Math.clamp(ConfigUtil.readInt(MAX_HIT_PATH, MAX_HIT_DEFAULT), MAX_HIT_MIN, MAX_HIT_MAX);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final ConfigListItem CONFIG_LIST_ITEM = new ConfigListItem(
|
public static final ConfigListItem CONFIG_LIST_ITEM = new ConfigListItem(
|
||||||
"meteor_shot",
|
"meteor_shot",
|
||||||
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/item/meteor_shot.png"),
|
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/item/meteor_shot.png"),
|
||||||
@@ -84,7 +54,7 @@ public class MeteorShot extends BulletAmmo {
|
|||||||
this.checkBeforeTick(summon);
|
this.checkBeforeTick(summon);
|
||||||
if(summon.isRemoved()) return;
|
if(summon.isRemoved()) return;
|
||||||
|
|
||||||
double speed = getSpeed();
|
double speed = SPEED.get();
|
||||||
Vec3 motion = summon.getLookAngle().normalize().scale(speed);
|
Vec3 motion = summon.getLookAngle().normalize().scale(speed);
|
||||||
Vec3 start = summon.position();
|
Vec3 start = summon.position();
|
||||||
Vec3 end = start.add(motion);
|
Vec3 end = start.add(motion);
|
||||||
@@ -109,9 +79,9 @@ public class MeteorShot extends BulletAmmo {
|
|||||||
|
|
||||||
ItemStack sourceStack = summon.getEntityData().get(StaticSummon.STACK_SOURCE);
|
ItemStack sourceStack = summon.getEntityData().get(StaticSummon.STACK_SOURCE);
|
||||||
for(Entity target : targets) {
|
for(Entity target : targets) {
|
||||||
if(DamageUtil.rangedAttack(summon, target, sourceStack, (getBaseDamage() + damage), knockbackScale)) {
|
if(DamageUtil.rangedAttack(summon, target, sourceStack, (BASE_DAMAGE.get() + damage), knockbackScale)) {
|
||||||
target.invulnerableTime = invulnerableTime;
|
target.invulnerableTime = invulnerableTime;
|
||||||
if(incrementHit(summon) >= getMaxHit()) {
|
if(incrementHit(summon) >= MAX_HIT.get()) {
|
||||||
this.onDied(summon);
|
this.onDied(summon);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -122,7 +92,7 @@ public class MeteorShot extends BulletAmmo {
|
|||||||
//方块检测
|
//方块检测
|
||||||
BlockHitResult blockHitResult = CollisionUtil.checkBlockHit(summon, end);
|
BlockHitResult blockHitResult = CollisionUtil.checkBlockHit(summon, end);
|
||||||
if(blockHitResult.getType() != HitResult.Type.MISS) {
|
if(blockHitResult.getType() != HitResult.Type.MISS) {
|
||||||
if(MeteorShot.incrementHit(summon) >= getMaxHit()) {
|
if(MeteorShot.incrementHit(summon) >= MAX_HIT.get()) {
|
||||||
this.onDied(summon);
|
this.onDied(summon);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,13 +3,15 @@ package com.lzxnone.terraria.item.ammo;
|
|||||||
import com.lzxnone.terraria.LzxnoneTerraria;
|
import com.lzxnone.terraria.LzxnoneTerraria;
|
||||||
import com.lzxnone.terraria.entity.summon.IStaticSummonBehavior;
|
import com.lzxnone.terraria.entity.summon.IStaticSummonBehavior;
|
||||||
import com.lzxnone.terraria.entity.summon.StaticSummon;
|
import com.lzxnone.terraria.entity.summon.StaticSummon;
|
||||||
import com.lzxnone.terraria.ui.config.ConfigFactory;
|
|
||||||
import com.lzxnone.terraria.ui.config.ConfigListItem;
|
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.ui.config.IConfigData;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigDouble;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigFloat;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigStruct;
|
||||||
import com.lzxnone.terraria.utils.CollisionUtil;
|
import com.lzxnone.terraria.utils.CollisionUtil;
|
||||||
import com.lzxnone.terraria.utils.DamageUtil;
|
import com.lzxnone.terraria.utils.DamageUtil;
|
||||||
import com.lzxnone.terraria.utils.FilterUtil;
|
import com.lzxnone.terraria.utils.FilterUtil;
|
||||||
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
@@ -23,42 +25,17 @@ import net.minecraft.world.phys.Vec3;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class MusketBall extends BulletAmmo {
|
public class MusketBall extends BulletAmmo {
|
||||||
private static final String CONFIG_TRANSLATION_PREFIX = "lzxnoneterraria.configuration.";
|
public static final ConfigFloat BASE_DAMAGE = new ConfigFloat("ammo.musket_ball.base_damage", "musket_ball_base_damage", 0.8f, 0.0f, 8388600.0f);
|
||||||
|
|
||||||
public static final String BASE_DAMAGE_PATH = "ammo.musket_ball.base_damage";
|
public static final ConfigDouble SPEED = new ConfigDouble("ammo.musket_ball.speed", "musket_ball_speed", 3.0D, 0.0D, 24.0D);
|
||||||
public static final float BASE_DAMAGE_DEFAULT = 0.8f;
|
|
||||||
public static final float BASE_DAMAGE_MIN = 0.0f;
|
|
||||||
public static final float BASE_DAMAGE_MAX = 8388600.0f;
|
|
||||||
|
|
||||||
public static final String SPEED_PATH = "ammo.musket_ball.speed";
|
|
||||||
public static final double SPEED_DEFAULT = 3.0D;
|
|
||||||
public static final double SPEED_MIN = 0.0D;
|
|
||||||
public static final double SPEED_MAX = 24.0D;
|
|
||||||
|
|
||||||
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
||||||
@Override
|
@Override
|
||||||
public void onConfigLoad() {
|
public void onConfigLoad() {
|
||||||
ConfigFactory.loadFloatConfig(BASE_DAMAGE_PATH, configText("musket_ball_base_damage"), configTooltip("musket_ball_base_damage"), BASE_DAMAGE_DEFAULT, BASE_DAMAGE_MIN, BASE_DAMAGE_MAX);
|
ConfigStruct.loadAll(BASE_DAMAGE, SPEED);
|
||||||
ConfigFactory.loadDoubleConfig(SPEED_PATH, configText("musket_ball_speed"), configTooltip("musket_ball_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 float getBaseDamage() {
|
|
||||||
return Math.clamp(ConfigUtil.readFloat(BASE_DAMAGE_PATH, BASE_DAMAGE_DEFAULT), BASE_DAMAGE_MIN, BASE_DAMAGE_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(
|
public static final ConfigListItem CONFIG_LIST_ITEM = new ConfigListItem(
|
||||||
"musket_ball",
|
"musket_ball",
|
||||||
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/item/musket_ball.png"),
|
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/item/musket_ball.png"),
|
||||||
@@ -70,7 +47,7 @@ public class MusketBall extends BulletAmmo {
|
|||||||
@Override
|
@Override
|
||||||
public void tick(StaticSummon summon) {
|
public void tick(StaticSummon summon) {
|
||||||
this.checkBeforeTick(summon);
|
this.checkBeforeTick(summon);
|
||||||
Vec3 motion = summon.getLookAngle().normalize().scale(getSpeed());
|
Vec3 motion = summon.getLookAngle().normalize().scale(SPEED.get());
|
||||||
Vec3 start = summon.position();
|
Vec3 start = summon.position();
|
||||||
Vec3 end = start.add(motion);
|
Vec3 end = start.add(motion);
|
||||||
|
|
||||||
@@ -94,7 +71,7 @@ public class MusketBall extends BulletAmmo {
|
|||||||
|
|
||||||
ItemStack sourceStack = summon.getEntityData().get(StaticSummon.STACK_SOURCE);
|
ItemStack sourceStack = summon.getEntityData().get(StaticSummon.STACK_SOURCE);
|
||||||
Entity target = targets.getFirst();
|
Entity target = targets.getFirst();
|
||||||
if(DamageUtil.rangedAttack(summon, target, sourceStack, getBaseDamage() + damage, knockbackScale)) {
|
if(DamageUtil.rangedAttack(summon, target, sourceStack, BASE_DAMAGE.get() + damage, knockbackScale)) {
|
||||||
target.invulnerableTime = invulnerableTime;
|
target.invulnerableTime = invulnerableTime;
|
||||||
this.onDied(summon);
|
this.onDied(summon);
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -1,16 +1,24 @@
|
|||||||
package com.lzxnone.terraria.item.ammo;
|
package com.lzxnone.terraria.item.ammo;
|
||||||
|
|
||||||
|
import com.lzxnone.terraria.LzxnoneTerraria;
|
||||||
import com.lzxnone.terraria.effect.ModEffects;
|
import com.lzxnone.terraria.effect.ModEffects;
|
||||||
import com.lzxnone.terraria.entity.summon.IStaticSummonBehavior;
|
import com.lzxnone.terraria.entity.summon.IStaticSummonBehavior;
|
||||||
import com.lzxnone.terraria.entity.summon.StaticSummon;
|
import com.lzxnone.terraria.entity.summon.StaticSummon;
|
||||||
import com.lzxnone.terraria.ui.config.ConfigListItem;
|
import com.lzxnone.terraria.ui.config.ConfigListItem;
|
||||||
import com.lzxnone.terraria.ui.config.IConfigData;
|
import com.lzxnone.terraria.ui.config.IConfigData;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigDouble;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigFloat;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigInt;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigStruct;
|
||||||
import com.lzxnone.terraria.utils.CollisionUtil;
|
import com.lzxnone.terraria.utils.CollisionUtil;
|
||||||
import com.lzxnone.terraria.utils.DamageUtil;
|
import com.lzxnone.terraria.utils.DamageUtil;
|
||||||
import com.lzxnone.terraria.utils.FilterUtil;
|
import com.lzxnone.terraria.utils.FilterUtil;
|
||||||
import com.lzxnone.terraria.utils.MathUtil;
|
import com.lzxnone.terraria.utils.MathUtil;
|
||||||
|
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
import net.minecraft.network.chat.Component;
|
||||||
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.world.effect.MobEffectInstance;
|
import net.minecraft.world.effect.MobEffectInstance;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.entity.LivingEntity;
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
@@ -24,44 +32,26 @@ import java.util.List;
|
|||||||
|
|
||||||
public class NanoBullet extends BulletAmmo {
|
public class NanoBullet extends BulletAmmo {
|
||||||
public static final String ID = "nano_bullet";
|
public static final String ID = "nano_bullet";
|
||||||
public static final float BASE_DAMAGE_DEFAULT = 2.5f;
|
|
||||||
public static final double SPEED_DEFAULT = 3.0D;
|
public static final ConfigFloat BASE_DAMAGE = new ConfigFloat("ammo.nano_bullet.base_damage", "nano_bullet_base_damage", 2.5f, 0.0f, 8388600.0f);
|
||||||
public static final float DAMAGE_DECAY_DEFAULT = 0.67f;
|
public static final ConfigDouble SPEED = new ConfigDouble("ammo.nano_bullet.speed", "nano_bullet_speed", 3.0D, 0.0D, 24.0D);
|
||||||
public static final int MAX_HIT_DEFAULT = 2;
|
public static final ConfigFloat DAMAGE_DECAY = new ConfigFloat("ammo.nano_bullet.damage_decay", "nano_bullet_damage_decay", 0.67f, 0.0f, 1.0f);
|
||||||
public static final int EFFECT_TIME_DEFAULT = 40;
|
public static final ConfigInt MAX_HIT = new ConfigInt("ammo.nano_bullet.max_hit", "nano_bullet_max_hit", 2, 1, 100);
|
||||||
|
public static final ConfigInt EFFECT_TIME = new ConfigInt("ammo.nano_bullet.effect_time", "nano_bullet_effect_time", 40, 0, 72000);
|
||||||
|
|
||||||
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
||||||
@Override
|
@Override
|
||||||
public void onConfigLoad() {
|
public void onConfigLoad() {
|
||||||
AmmoConfig.loadFloat(ID, "base_damage", BASE_DAMAGE_DEFAULT, 0.0f, 8388600.0f);
|
ConfigStruct.loadAll(BASE_DAMAGE, SPEED, DAMAGE_DECAY, MAX_HIT, EFFECT_TIME);
|
||||||
AmmoConfig.loadDouble(ID, "speed", SPEED_DEFAULT, 0.0D, 24.0D);
|
|
||||||
AmmoConfig.loadFloat(ID, "damage_decay", DAMAGE_DECAY_DEFAULT, 0.0f, 1.0f);
|
|
||||||
AmmoConfig.loadInt(ID, "max_hit", MAX_HIT_DEFAULT, 1, 100);
|
|
||||||
AmmoConfig.loadInt(ID, "effect_time", EFFECT_TIME_DEFAULT, 0, 72000);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public static final ConfigListItem CONFIG_LIST_ITEM = AmmoConfig.createListItem(ID, CONFIG_DATA);
|
public static final ConfigListItem CONFIG_LIST_ITEM = new ConfigListItem(
|
||||||
|
ID,
|
||||||
public static float getBaseDamage() {
|
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/item/" + ID + ".png"),
|
||||||
return AmmoConfig.readFloat(ID, "base_damage", BASE_DAMAGE_DEFAULT, 0.0f, 8388600.0f);
|
Component.translatable("item.lzxnoneterraria." + ID),
|
||||||
}
|
CONFIG_DATA
|
||||||
|
);
|
||||||
public static double getSpeed() {
|
|
||||||
return AmmoConfig.readDouble(ID, "speed", SPEED_DEFAULT, 0.0D, 24.0D);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static float getDamageDecay() {
|
|
||||||
return AmmoConfig.readFloat(ID, "damage_decay", DAMAGE_DECAY_DEFAULT, 0.0f, 1.0f);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getMaxHit() {
|
|
||||||
return AmmoConfig.readInt(ID, "max_hit", MAX_HIT_DEFAULT, 1, 100);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getEffectTime() {
|
|
||||||
return AmmoConfig.readInt(ID, "effect_time", EFFECT_TIME_DEFAULT, 0, 72000);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final IStaticSummonBehavior SUMMON_BEHAVIOR = new IStaticSummonBehavior() {
|
public static final IStaticSummonBehavior SUMMON_BEHAVIOR = new IStaticSummonBehavior() {
|
||||||
@Override
|
@Override
|
||||||
@@ -69,7 +59,7 @@ public class NanoBullet extends BulletAmmo {
|
|||||||
this.checkBeforeTick(summon);
|
this.checkBeforeTick(summon);
|
||||||
if(summon.isRemoved()) return;
|
if(summon.isRemoved()) return;
|
||||||
|
|
||||||
double speed = getSpeed();
|
double speed = SPEED.get();
|
||||||
Vec3 motion = summon.getLookAngle().normalize().scale(speed);
|
Vec3 motion = summon.getLookAngle().normalize().scale(speed);
|
||||||
Vec3 start = summon.position();
|
Vec3 start = summon.position();
|
||||||
Vec3 end = start.add(motion);
|
Vec3 end = start.add(motion);
|
||||||
@@ -95,10 +85,10 @@ public class NanoBullet extends BulletAmmo {
|
|||||||
ItemStack sourceStack = summon.getEntityData().get(StaticSummon.STACK_SOURCE);
|
ItemStack sourceStack = summon.getEntityData().get(StaticSummon.STACK_SOURCE);
|
||||||
Entity target = targets.getFirst();
|
Entity target = targets.getFirst();
|
||||||
int hit = customData.getInt("hit");
|
int hit = customData.getInt("hit");
|
||||||
if(DamageUtil.rangedAttack(summon, target, sourceStack, hit > 0 ? (getBaseDamage() + damage) * getDamageDecay() : getBaseDamage() + damage, knockbackScale)) {
|
if(DamageUtil.rangedAttack(summon, target, sourceStack, hit > 0 ? (BASE_DAMAGE.get() + damage) * DAMAGE_DECAY.get() : BASE_DAMAGE.get() + damage, knockbackScale)) {
|
||||||
target.invulnerableTime = invulnerableTime;
|
target.invulnerableTime = invulnerableTime;
|
||||||
if(target instanceof LivingEntity livingEntity) {
|
if(target instanceof LivingEntity livingEntity) {
|
||||||
MobEffectInstance effectInstance = new MobEffectInstance(ModEffects.CONFUSED, getEffectTime(), 0);
|
MobEffectInstance effectInstance = new MobEffectInstance(ModEffects.CONFUSED, EFFECT_TIME.get(), 0);
|
||||||
livingEntity.addEffect(effectInstance);
|
livingEntity.addEffect(effectInstance);
|
||||||
}
|
}
|
||||||
onDied(summon);
|
onDied(summon);
|
||||||
@@ -109,7 +99,7 @@ public class NanoBullet extends BulletAmmo {
|
|||||||
//方块检测
|
//方块检测
|
||||||
BlockHitResult blockHitResult = CollisionUtil.checkBlockHit(summon, end);
|
BlockHitResult blockHitResult = CollisionUtil.checkBlockHit(summon, end);
|
||||||
if(blockHitResult.getType() != HitResult.Type.MISS) {
|
if(blockHitResult.getType() != HitResult.Type.MISS) {
|
||||||
if(incrementHit(summon) >= getMaxHit()) {
|
if(incrementHit(summon) >= MAX_HIT.get()) {
|
||||||
this.onDied(summon);
|
this.onDied(summon);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,22 @@
|
|||||||
package com.lzxnone.terraria.item.ammo;
|
package com.lzxnone.terraria.item.ammo;
|
||||||
|
|
||||||
|
import com.lzxnone.terraria.LzxnoneTerraria;
|
||||||
import com.lzxnone.terraria.entity.summon.IStaticSummonBehavior;
|
import com.lzxnone.terraria.entity.summon.IStaticSummonBehavior;
|
||||||
import com.lzxnone.terraria.entity.summon.StaticSummon;
|
import com.lzxnone.terraria.entity.summon.StaticSummon;
|
||||||
import com.lzxnone.terraria.particle.ModParticles;
|
import com.lzxnone.terraria.particle.ModParticles;
|
||||||
import com.lzxnone.terraria.ui.config.ConfigListItem;
|
import com.lzxnone.terraria.ui.config.ConfigListItem;
|
||||||
import com.lzxnone.terraria.ui.config.IConfigData;
|
import com.lzxnone.terraria.ui.config.IConfigData;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigDouble;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigFloat;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigStruct;
|
||||||
import com.lzxnone.terraria.utils.CollisionUtil;
|
import com.lzxnone.terraria.utils.CollisionUtil;
|
||||||
import com.lzxnone.terraria.utils.DamageUtil;
|
import com.lzxnone.terraria.utils.DamageUtil;
|
||||||
import com.lzxnone.terraria.utils.FilterUtil;
|
import com.lzxnone.terraria.utils.FilterUtil;
|
||||||
import com.lzxnone.terraria.utils.ParticleUtil;
|
import com.lzxnone.terraria.utils.ParticleUtil;
|
||||||
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
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.ServerLevel;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
@@ -22,32 +29,29 @@ import java.util.List;
|
|||||||
|
|
||||||
public class PartyBullet extends BulletAmmo {
|
public class PartyBullet extends BulletAmmo {
|
||||||
public static final String ID = "party_bullet";
|
public static final String ID = "party_bullet";
|
||||||
public static final float BASE_DAMAGE_DEFAULT = 1.5f;
|
|
||||||
public static final double SPEED_DEFAULT = 3.0D;
|
public static final ConfigFloat BASE_DAMAGE = new ConfigFloat("ammo.party_bullet.base_damage", "party_bullet_base_damage", 1.5f, 0.0f, 8388600.0f);
|
||||||
|
public static final ConfigDouble SPEED = new ConfigDouble("ammo.party_bullet.speed", "party_bullet_speed", 3.0D, 0.0D, 24.0D);
|
||||||
|
|
||||||
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
||||||
@Override
|
@Override
|
||||||
public void onConfigLoad() {
|
public void onConfigLoad() {
|
||||||
AmmoConfig.loadFloat(ID, "base_damage", BASE_DAMAGE_DEFAULT, 0.0f, 8388600.0f);
|
ConfigStruct.loadAll(BASE_DAMAGE, SPEED);
|
||||||
AmmoConfig.loadDouble(ID, "speed", SPEED_DEFAULT, 0.0D, 24.0D);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public static final ConfigListItem CONFIG_LIST_ITEM = AmmoConfig.createListItem(ID, CONFIG_DATA);
|
public static final ConfigListItem CONFIG_LIST_ITEM = new ConfigListItem(
|
||||||
|
ID,
|
||||||
public static float getBaseDamage() {
|
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/item/" + ID + ".png"),
|
||||||
return AmmoConfig.readFloat(ID, "base_damage", BASE_DAMAGE_DEFAULT, 0.0f, 8388600.0f);
|
Component.translatable("item.lzxnoneterraria." + ID),
|
||||||
}
|
CONFIG_DATA
|
||||||
|
);
|
||||||
public static double getSpeed() {
|
|
||||||
return AmmoConfig.readDouble(ID, "speed", SPEED_DEFAULT, 0.0D, 24.0D);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final IStaticSummonBehavior SUMMON_BEHAVIOR = new IStaticSummonBehavior() {
|
public static final IStaticSummonBehavior SUMMON_BEHAVIOR = new IStaticSummonBehavior() {
|
||||||
@Override
|
@Override
|
||||||
public void tick(StaticSummon summon) {
|
public void tick(StaticSummon summon) {
|
||||||
this.checkBeforeTick(summon);
|
this.checkBeforeTick(summon);
|
||||||
Vec3 motion = summon.getLookAngle().normalize().scale(getSpeed());
|
Vec3 motion = summon.getLookAngle().normalize().scale(SPEED.get());
|
||||||
Vec3 start = summon.position();
|
Vec3 start = summon.position();
|
||||||
Vec3 end = start.add(motion);
|
Vec3 end = start.add(motion);
|
||||||
|
|
||||||
@@ -71,7 +75,7 @@ public class PartyBullet extends BulletAmmo {
|
|||||||
|
|
||||||
ItemStack sourceStack = summon.getEntityData().get(StaticSummon.STACK_SOURCE);
|
ItemStack sourceStack = summon.getEntityData().get(StaticSummon.STACK_SOURCE);
|
||||||
Entity target = targets.getFirst();
|
Entity target = targets.getFirst();
|
||||||
if(DamageUtil.rangedAttack(summon, target, sourceStack, getBaseDamage() + damage, knockbackScale)) {
|
if(DamageUtil.rangedAttack(summon, target, sourceStack, BASE_DAMAGE.get() + damage, knockbackScale)) {
|
||||||
target.invulnerableTime = invulnerableTime;
|
target.invulnerableTime = invulnerableTime;
|
||||||
summon.setPos(end);
|
summon.setPos(end);
|
||||||
ParticleUtil.addParticles(
|
ParticleUtil.addParticles(
|
||||||
|
|||||||
@@ -3,13 +3,15 @@ package com.lzxnone.terraria.item.ammo;
|
|||||||
import com.lzxnone.terraria.LzxnoneTerraria;
|
import com.lzxnone.terraria.LzxnoneTerraria;
|
||||||
import com.lzxnone.terraria.entity.summon.IStaticSummonBehavior;
|
import com.lzxnone.terraria.entity.summon.IStaticSummonBehavior;
|
||||||
import com.lzxnone.terraria.entity.summon.StaticSummon;
|
import com.lzxnone.terraria.entity.summon.StaticSummon;
|
||||||
import com.lzxnone.terraria.ui.config.ConfigFactory;
|
|
||||||
import com.lzxnone.terraria.ui.config.ConfigListItem;
|
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.ui.config.IConfigData;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigDouble;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigFloat;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigStruct;
|
||||||
import com.lzxnone.terraria.utils.CollisionUtil;
|
import com.lzxnone.terraria.utils.CollisionUtil;
|
||||||
import com.lzxnone.terraria.utils.DamageUtil;
|
import com.lzxnone.terraria.utils.DamageUtil;
|
||||||
import com.lzxnone.terraria.utils.FilterUtil;
|
import com.lzxnone.terraria.utils.FilterUtil;
|
||||||
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
@@ -26,52 +28,19 @@ import net.minecraft.world.phys.Vec3;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class SilverBullet extends BulletAmmo {
|
public class SilverBullet extends BulletAmmo {
|
||||||
private static final String CONFIG_TRANSLATION_PREFIX = "lzxnoneterraria.configuration.";
|
public static final ConfigFloat BASE_DAMAGE = new ConfigFloat("ammo.silver_bullet.base_damage", "silver_bullet_base_damage", 1.2f, 0.0f, 8388600.0f);
|
||||||
|
|
||||||
public static final String BASE_DAMAGE_PATH = "ammo.silver_bullet.base_damage";
|
public static final ConfigDouble SPEED = new ConfigDouble("ammo.silver_bullet.speed", "silver_bullet_speed", 3.0D, 0.0D, 24.0D);
|
||||||
public static final float BASE_DAMAGE_DEFAULT = 1.2f;
|
|
||||||
public static final float BASE_DAMAGE_MIN = 0.0f;
|
|
||||||
public static final float BASE_DAMAGE_MAX = 8388600.0f;
|
|
||||||
|
|
||||||
public static final String SPEED_PATH = "ammo.silver_bullet.speed";
|
public static final ConfigFloat PIGLIN_DAMAGE_MULTIPLIER = new ConfigFloat("ammo.silver_bullet.piglin_damage_multiplier", "silver_bullet_piglin_damage_multiplier", 3.0f, 0.0f, 100.0f);
|
||||||
public static final double SPEED_DEFAULT = 3.0D;
|
|
||||||
public static final double SPEED_MIN = 0.0D;
|
|
||||||
public static final double SPEED_MAX = 24.0D;
|
|
||||||
|
|
||||||
public static final String PIGLIN_DAMAGE_MULTIPLIER_PATH = "ammo.silver_bullet.piglin_damage_multiplier";
|
|
||||||
public static final float PIGLIN_DAMAGE_MULTIPLIER_DEFAULT = 3.0f;
|
|
||||||
public static final float PIGLIN_DAMAGE_MULTIPLIER_MIN = 0.0f;
|
|
||||||
public static final float PIGLIN_DAMAGE_MULTIPLIER_MAX = 100.0f;
|
|
||||||
|
|
||||||
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
||||||
@Override
|
@Override
|
||||||
public void onConfigLoad() {
|
public void onConfigLoad() {
|
||||||
ConfigFactory.loadFloatConfig(BASE_DAMAGE_PATH, configText("silver_bullet_base_damage"), configTooltip("silver_bullet_base_damage"), BASE_DAMAGE_DEFAULT, BASE_DAMAGE_MIN, BASE_DAMAGE_MAX);
|
ConfigStruct.loadAll(BASE_DAMAGE, SPEED, PIGLIN_DAMAGE_MULTIPLIER);
|
||||||
ConfigFactory.loadDoubleConfig(SPEED_PATH, configText("silver_bullet_speed"), configTooltip("silver_bullet_speed"), SPEED_DEFAULT, SPEED_MIN, SPEED_MAX);
|
|
||||||
ConfigFactory.loadFloatConfig(PIGLIN_DAMAGE_MULTIPLIER_PATH, configText("silver_bullet_piglin_damage_multiplier"), configTooltip("silver_bullet_piglin_damage_multiplier"), PIGLIN_DAMAGE_MULTIPLIER_DEFAULT, PIGLIN_DAMAGE_MULTIPLIER_MIN, PIGLIN_DAMAGE_MULTIPLIER_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 float getBaseDamage() {
|
|
||||||
return Math.clamp(ConfigUtil.readFloat(BASE_DAMAGE_PATH, BASE_DAMAGE_DEFAULT), BASE_DAMAGE_MIN, BASE_DAMAGE_MAX);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static double getSpeed() {
|
|
||||||
return Math.clamp(ConfigUtil.readDouble(SPEED_PATH, SPEED_DEFAULT), SPEED_MIN, SPEED_MAX);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static float getPiglinDamageMultiplier() {
|
|
||||||
return Math.clamp(ConfigUtil.readFloat(PIGLIN_DAMAGE_MULTIPLIER_PATH, PIGLIN_DAMAGE_MULTIPLIER_DEFAULT), PIGLIN_DAMAGE_MULTIPLIER_MIN, PIGLIN_DAMAGE_MULTIPLIER_MAX);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final ConfigListItem CONFIG_LIST_ITEM = new ConfigListItem(
|
public static final ConfigListItem CONFIG_LIST_ITEM = new ConfigListItem(
|
||||||
"silver_bullet",
|
"silver_bullet",
|
||||||
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/item/silver_bullet.png"),
|
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/item/silver_bullet.png"),
|
||||||
@@ -83,7 +52,7 @@ public class SilverBullet extends BulletAmmo {
|
|||||||
@Override
|
@Override
|
||||||
public void tick(StaticSummon summon) {
|
public void tick(StaticSummon summon) {
|
||||||
this.checkBeforeTick(summon);
|
this.checkBeforeTick(summon);
|
||||||
Vec3 motion = summon.getLookAngle().normalize().scale(getSpeed());
|
Vec3 motion = summon.getLookAngle().normalize().scale(SPEED.get());
|
||||||
Vec3 start = summon.position();
|
Vec3 start = summon.position();
|
||||||
Vec3 end = start.add(motion);
|
Vec3 end = start.add(motion);
|
||||||
|
|
||||||
@@ -107,9 +76,9 @@ public class SilverBullet extends BulletAmmo {
|
|||||||
|
|
||||||
ItemStack sourceStack = summon.getEntityData().get(StaticSummon.STACK_SOURCE);
|
ItemStack sourceStack = summon.getEntityData().get(StaticSummon.STACK_SOURCE);
|
||||||
Entity target = targets.getFirst();
|
Entity target = targets.getFirst();
|
||||||
float finalDamage = getBaseDamage() + damage;
|
float finalDamage = BASE_DAMAGE.get() + damage;
|
||||||
if(target instanceof Piglin || target instanceof PiglinBrute || target instanceof ZombifiedPiglin) {
|
if(target instanceof Piglin || target instanceof PiglinBrute || target instanceof ZombifiedPiglin) {
|
||||||
finalDamage *= getPiglinDamageMultiplier();
|
finalDamage *= PIGLIN_DAMAGE_MULTIPLIER.get();
|
||||||
}
|
}
|
||||||
if(DamageUtil.rangedAttack(summon, target, sourceStack, finalDamage, knockbackScale)) {
|
if(DamageUtil.rangedAttack(summon, target, sourceStack, finalDamage, knockbackScale)) {
|
||||||
target.invulnerableTime = invulnerableTime;
|
target.invulnerableTime = invulnerableTime;
|
||||||
|
|||||||
@@ -3,13 +3,15 @@ package com.lzxnone.terraria.item.ammo;
|
|||||||
import com.lzxnone.terraria.LzxnoneTerraria;
|
import com.lzxnone.terraria.LzxnoneTerraria;
|
||||||
import com.lzxnone.terraria.entity.summon.IStaticSummonBehavior;
|
import com.lzxnone.terraria.entity.summon.IStaticSummonBehavior;
|
||||||
import com.lzxnone.terraria.entity.summon.StaticSummon;
|
import com.lzxnone.terraria.entity.summon.StaticSummon;
|
||||||
import com.lzxnone.terraria.ui.config.ConfigFactory;
|
|
||||||
import com.lzxnone.terraria.ui.config.ConfigListItem;
|
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.ui.config.IConfigData;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigDouble;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigFloat;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigStruct;
|
||||||
import com.lzxnone.terraria.utils.CollisionUtil;
|
import com.lzxnone.terraria.utils.CollisionUtil;
|
||||||
import com.lzxnone.terraria.utils.DamageUtil;
|
import com.lzxnone.terraria.utils.DamageUtil;
|
||||||
import com.lzxnone.terraria.utils.FilterUtil;
|
import com.lzxnone.terraria.utils.FilterUtil;
|
||||||
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
@@ -23,42 +25,17 @@ import net.minecraft.world.phys.Vec3;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class TungstenBullet extends BulletAmmo {
|
public class TungstenBullet extends BulletAmmo {
|
||||||
private static final String CONFIG_TRANSLATION_PREFIX = "lzxnoneterraria.configuration.";
|
public static final ConfigFloat BASE_DAMAGE = new ConfigFloat("ammo.tungsten_bullet.base_damage", "tungsten_bullet_base_damage", 1.2f, 0.0f, 8388600.0f);
|
||||||
|
|
||||||
public static final String BASE_DAMAGE_PATH = "ammo.tungsten_bullet.base_damage";
|
public static final ConfigDouble SPEED = new ConfigDouble("ammo.tungsten_bullet.speed", "tungsten_bullet_speed", 3.0D, 0.0D, 24.0D);
|
||||||
public static final float BASE_DAMAGE_DEFAULT = 1.2f;
|
|
||||||
public static final float BASE_DAMAGE_MIN = 0.0f;
|
|
||||||
public static final float BASE_DAMAGE_MAX = 8388600.0f;
|
|
||||||
|
|
||||||
public static final String SPEED_PATH = "ammo.tungsten_bullet.speed";
|
|
||||||
public static final double SPEED_DEFAULT = 3.0D;
|
|
||||||
public static final double SPEED_MIN = 0.0D;
|
|
||||||
public static final double SPEED_MAX = 24.0D;
|
|
||||||
|
|
||||||
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
||||||
@Override
|
@Override
|
||||||
public void onConfigLoad() {
|
public void onConfigLoad() {
|
||||||
ConfigFactory.loadFloatConfig(BASE_DAMAGE_PATH, configText("tungsten_bullet_base_damage"), configTooltip("tungsten_bullet_base_damage"), BASE_DAMAGE_DEFAULT, BASE_DAMAGE_MIN, BASE_DAMAGE_MAX);
|
ConfigStruct.loadAll(BASE_DAMAGE, SPEED);
|
||||||
ConfigFactory.loadDoubleConfig(SPEED_PATH, configText("tungsten_bullet_speed"), configTooltip("tungsten_bullet_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 float getBaseDamage() {
|
|
||||||
return Math.clamp(ConfigUtil.readFloat(BASE_DAMAGE_PATH, BASE_DAMAGE_DEFAULT), BASE_DAMAGE_MIN, BASE_DAMAGE_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(
|
public static final ConfigListItem CONFIG_LIST_ITEM = new ConfigListItem(
|
||||||
"tungsten_bullet",
|
"tungsten_bullet",
|
||||||
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/item/tungsten_bullet.png"),
|
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/item/tungsten_bullet.png"),
|
||||||
@@ -70,7 +47,7 @@ public class TungstenBullet extends BulletAmmo {
|
|||||||
@Override
|
@Override
|
||||||
public void tick(StaticSummon summon) {
|
public void tick(StaticSummon summon) {
|
||||||
this.checkBeforeTick(summon);
|
this.checkBeforeTick(summon);
|
||||||
Vec3 motion = summon.getLookAngle().normalize().scale(getSpeed());
|
Vec3 motion = summon.getLookAngle().normalize().scale(SPEED.get());
|
||||||
Vec3 start = summon.position();
|
Vec3 start = summon.position();
|
||||||
Vec3 end = start.add(motion);
|
Vec3 end = start.add(motion);
|
||||||
|
|
||||||
@@ -94,7 +71,7 @@ public class TungstenBullet extends BulletAmmo {
|
|||||||
|
|
||||||
ItemStack sourceStack = summon.getEntityData().get(StaticSummon.STACK_SOURCE);
|
ItemStack sourceStack = summon.getEntityData().get(StaticSummon.STACK_SOURCE);
|
||||||
Entity target = targets.getFirst();
|
Entity target = targets.getFirst();
|
||||||
if(DamageUtil.rangedAttack(summon, target, sourceStack, getBaseDamage() + damage, knockbackScale)) {
|
if(DamageUtil.rangedAttack(summon, target, sourceStack, BASE_DAMAGE.get() + damage, knockbackScale)) {
|
||||||
target.invulnerableTime = invulnerableTime;
|
target.invulnerableTime = invulnerableTime;
|
||||||
this.onDied(summon);
|
this.onDied(summon);
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -1,14 +1,22 @@
|
|||||||
package com.lzxnone.terraria.item.ammo;
|
package com.lzxnone.terraria.item.ammo;
|
||||||
|
|
||||||
|
import com.lzxnone.terraria.LzxnoneTerraria;
|
||||||
import com.lzxnone.terraria.effect.ModEffects;
|
import com.lzxnone.terraria.effect.ModEffects;
|
||||||
import com.lzxnone.terraria.entity.summon.IStaticSummonBehavior;
|
import com.lzxnone.terraria.entity.summon.IStaticSummonBehavior;
|
||||||
import com.lzxnone.terraria.entity.summon.StaticSummon;
|
import com.lzxnone.terraria.entity.summon.StaticSummon;
|
||||||
import com.lzxnone.terraria.ui.config.ConfigListItem;
|
import com.lzxnone.terraria.ui.config.ConfigListItem;
|
||||||
import com.lzxnone.terraria.ui.config.IConfigData;
|
import com.lzxnone.terraria.ui.config.IConfigData;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigDouble;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigFloat;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigInt;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigStruct;
|
||||||
import com.lzxnone.terraria.utils.CollisionUtil;
|
import com.lzxnone.terraria.utils.CollisionUtil;
|
||||||
import com.lzxnone.terraria.utils.DamageUtil;
|
import com.lzxnone.terraria.utils.DamageUtil;
|
||||||
import com.lzxnone.terraria.utils.FilterUtil;
|
import com.lzxnone.terraria.utils.FilterUtil;
|
||||||
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
import net.minecraft.network.chat.Component;
|
||||||
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.world.effect.MobEffectInstance;
|
import net.minecraft.world.effect.MobEffectInstance;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.entity.LivingEntity;
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
@@ -22,38 +30,30 @@ import java.util.List;
|
|||||||
|
|
||||||
public class VenomBullet extends BulletAmmo {
|
public class VenomBullet extends BulletAmmo {
|
||||||
public static final String ID = "venom_bullet";
|
public static final String ID = "venom_bullet";
|
||||||
public static final float BASE_DAMAGE_DEFAULT = 2.5f;
|
|
||||||
public static final double SPEED_DEFAULT = 3.0D;
|
public static final ConfigFloat BASE_DAMAGE = new ConfigFloat("ammo.venom_bullet.base_damage", "venom_bullet_base_damage", 2.5f, 0.0f, 8388600.0f);
|
||||||
public static final int EFFECT_TIME_DEFAULT = 200;
|
public static final ConfigDouble SPEED = new ConfigDouble("ammo.venom_bullet.speed", "venom_bullet_speed", 3.0D, 0.0D, 24.0D);
|
||||||
|
public static final ConfigInt EFFECT_TIME = new ConfigInt("ammo.venom_bullet.effect_time", "venom_bullet_effect_time", 200, 0, 72000);
|
||||||
|
|
||||||
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
||||||
@Override
|
@Override
|
||||||
public void onConfigLoad() {
|
public void onConfigLoad() {
|
||||||
AmmoConfig.loadFloat(ID, "base_damage", BASE_DAMAGE_DEFAULT, 0.0f, 8388600.0f);
|
ConfigStruct.loadAll(BASE_DAMAGE, SPEED, EFFECT_TIME);
|
||||||
AmmoConfig.loadDouble(ID, "speed", SPEED_DEFAULT, 0.0D, 24.0D);
|
|
||||||
AmmoConfig.loadInt(ID, "effect_time", EFFECT_TIME_DEFAULT, 0, 72000);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public static final ConfigListItem CONFIG_LIST_ITEM = AmmoConfig.createListItem(ID, CONFIG_DATA);
|
public static final ConfigListItem CONFIG_LIST_ITEM = new ConfigListItem(
|
||||||
|
ID,
|
||||||
public static float getBaseDamage() {
|
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/item/" + ID + ".png"),
|
||||||
return AmmoConfig.readFloat(ID, "base_damage", BASE_DAMAGE_DEFAULT, 0.0f, 8388600.0f);
|
Component.translatable("item.lzxnoneterraria." + ID),
|
||||||
}
|
CONFIG_DATA
|
||||||
|
);
|
||||||
public static double getSpeed() {
|
|
||||||
return AmmoConfig.readDouble(ID, "speed", SPEED_DEFAULT, 0.0D, 24.0D);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getEffectTime() {
|
|
||||||
return AmmoConfig.readInt(ID, "effect_time", EFFECT_TIME_DEFAULT, 0, 72000);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final IStaticSummonBehavior SUMMON_BEHAVIOR = new IStaticSummonBehavior() {
|
public static final IStaticSummonBehavior SUMMON_BEHAVIOR = new IStaticSummonBehavior() {
|
||||||
@Override
|
@Override
|
||||||
public void tick(StaticSummon summon) {
|
public void tick(StaticSummon summon) {
|
||||||
this.checkBeforeTick(summon);
|
this.checkBeforeTick(summon);
|
||||||
Vec3 motion = summon.getLookAngle().normalize().scale(getSpeed());
|
Vec3 motion = summon.getLookAngle().normalize().scale(SPEED.get());
|
||||||
Vec3 start = summon.position();
|
Vec3 start = summon.position();
|
||||||
Vec3 end = start.add(motion);
|
Vec3 end = start.add(motion);
|
||||||
|
|
||||||
@@ -77,10 +77,10 @@ public class VenomBullet extends BulletAmmo {
|
|||||||
|
|
||||||
ItemStack sourceStack = summon.getEntityData().get(StaticSummon.STACK_SOURCE);
|
ItemStack sourceStack = summon.getEntityData().get(StaticSummon.STACK_SOURCE);
|
||||||
Entity target = targets.getFirst();
|
Entity target = targets.getFirst();
|
||||||
if(DamageUtil.rangedAttack(summon, target, sourceStack, getBaseDamage() + damage, knockbackScale)) {
|
if(DamageUtil.rangedAttack(summon, target, sourceStack, BASE_DAMAGE.get() + damage, knockbackScale)) {
|
||||||
target.invulnerableTime = invulnerableTime;
|
target.invulnerableTime = invulnerableTime;
|
||||||
if(target instanceof LivingEntity livingEntity) {
|
if(target instanceof LivingEntity livingEntity) {
|
||||||
MobEffectInstance effectInstance = new MobEffectInstance(ModEffects.ACID_VENOM, getEffectTime(), 0);
|
MobEffectInstance effectInstance = new MobEffectInstance(ModEffects.ACID_VENOM, EFFECT_TIME.get(), 0);
|
||||||
livingEntity.addEffect(effectInstance);
|
livingEntity.addEffect(effectInstance);
|
||||||
}
|
}
|
||||||
this.onDied(summon);
|
this.onDied(summon);
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
package com.lzxnone.terraria.item.projectile;
|
|
||||||
|
|
||||||
import net.minecraft.world.item.Item;
|
|
||||||
|
|
||||||
public class EnchantedSwordBeam extends Item {
|
|
||||||
public EnchantedSwordBeam() {
|
|
||||||
super(new Item.Properties());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
package com.lzxnone.terraria.item.projectile;
|
|
||||||
|
|
||||||
import net.minecraft.world.item.Item;
|
|
||||||
|
|
||||||
public class InfluxWaverBeam extends Item {
|
|
||||||
public InfluxWaverBeam() {
|
|
||||||
super(new Item.Properties());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
package com.lzxnone.terraria.item.projectile;
|
|
||||||
|
|
||||||
import net.minecraft.world.item.Item;
|
|
||||||
|
|
||||||
public class LeafProjectile extends Item {
|
|
||||||
public LeafProjectile() {
|
|
||||||
super(new Item.Properties());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
package com.lzxnone.terraria.item.projectile;
|
|
||||||
|
|
||||||
import net.minecraft.world.item.Item;
|
|
||||||
|
|
||||||
public class MaceProjectile extends Item {
|
|
||||||
public MaceProjectile() {
|
|
||||||
super(new Item.Properties());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
package com.lzxnone.terraria.item.projectile;
|
|
||||||
|
|
||||||
import net.minecraft.world.item.Item;
|
|
||||||
|
|
||||||
public class MeowmereProjectile extends Item {
|
|
||||||
public MeowmereProjectile() {
|
|
||||||
super(new Item.Properties());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
package com.lzxnone.terraria.item.projectile;
|
|
||||||
|
|
||||||
import net.minecraft.world.item.Item;
|
|
||||||
|
|
||||||
public class SeedlerNut extends Item{
|
|
||||||
public SeedlerNut() {
|
|
||||||
super(new Item.Properties());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
package com.lzxnone.terraria.item.projectile;
|
|
||||||
|
|
||||||
import net.minecraft.world.item.Item;
|
|
||||||
|
|
||||||
public class SeedlerThorn extends Item {
|
|
||||||
public SeedlerThorn() {
|
|
||||||
super(new Item.Properties());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
package com.lzxnone.terraria.item.projectile;
|
|
||||||
|
|
||||||
import net.minecraft.world.item.Item;
|
|
||||||
|
|
||||||
public class StarWrathStar extends Item {
|
|
||||||
public StarWrathStar() {
|
|
||||||
super(new Item.Properties());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
package com.lzxnone.terraria.item.projectile;
|
|
||||||
|
|
||||||
import net.minecraft.world.item.Item;
|
|
||||||
|
|
||||||
public class StarfuryStar extends Item {
|
|
||||||
public StarfuryStar() {
|
|
||||||
super(new Item.Properties());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
package com.lzxnone.terraria.item.projectile;
|
|
||||||
|
|
||||||
import net.minecraft.world.item.Item;
|
|
||||||
|
|
||||||
public class TerraprismaSummon extends Item {
|
|
||||||
public TerraprismaSummon() {
|
|
||||||
super(new Item.Properties());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-9
@@ -1,9 +0,0 @@
|
|||||||
package com.lzxnone.terraria.item.projectile.first_fractal;
|
|
||||||
|
|
||||||
import net.minecraft.world.item.Item;
|
|
||||||
|
|
||||||
public class FirstFractalProjectile0 extends Item {
|
|
||||||
public FirstFractalProjectile0() {
|
|
||||||
super(new Item.Properties());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-9
@@ -1,9 +0,0 @@
|
|||||||
package com.lzxnone.terraria.item.projectile.first_fractal;
|
|
||||||
|
|
||||||
import net.minecraft.world.item.Item;
|
|
||||||
|
|
||||||
public class FirstFractalProjectile1 extends Item {
|
|
||||||
public FirstFractalProjectile1() {
|
|
||||||
super(new Item.Properties());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-9
@@ -1,9 +0,0 @@
|
|||||||
package com.lzxnone.terraria.item.projectile.first_fractal;
|
|
||||||
|
|
||||||
import net.minecraft.world.item.Item;
|
|
||||||
|
|
||||||
public class FirstFractalProjectile10 extends Item {
|
|
||||||
public FirstFractalProjectile10() {
|
|
||||||
super(new Item.Properties());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-9
@@ -1,9 +0,0 @@
|
|||||||
package com.lzxnone.terraria.item.projectile.first_fractal;
|
|
||||||
|
|
||||||
import net.minecraft.world.item.Item;
|
|
||||||
|
|
||||||
public class FirstFractalProjectile11 extends Item {
|
|
||||||
public FirstFractalProjectile11() {
|
|
||||||
super(new Item.Properties());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-9
@@ -1,9 +0,0 @@
|
|||||||
package com.lzxnone.terraria.item.projectile.first_fractal;
|
|
||||||
|
|
||||||
import net.minecraft.world.item.Item;
|
|
||||||
|
|
||||||
public class FirstFractalProjectile12 extends Item {
|
|
||||||
public FirstFractalProjectile12() {
|
|
||||||
super(new Item.Properties());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-9
@@ -1,9 +0,0 @@
|
|||||||
package com.lzxnone.terraria.item.projectile.first_fractal;
|
|
||||||
|
|
||||||
import net.minecraft.world.item.Item;
|
|
||||||
|
|
||||||
public class FirstFractalProjectile13 extends Item {
|
|
||||||
public FirstFractalProjectile13() {
|
|
||||||
super(new Item.Properties());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-9
@@ -1,9 +0,0 @@
|
|||||||
package com.lzxnone.terraria.item.projectile.first_fractal;
|
|
||||||
|
|
||||||
import net.minecraft.world.item.Item;
|
|
||||||
|
|
||||||
public class FirstFractalProjectile14 extends Item {
|
|
||||||
public FirstFractalProjectile14() {
|
|
||||||
super(new Item.Properties());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-9
@@ -1,9 +0,0 @@
|
|||||||
package com.lzxnone.terraria.item.projectile.first_fractal;
|
|
||||||
|
|
||||||
import net.minecraft.world.item.Item;
|
|
||||||
|
|
||||||
public class FirstFractalProjectile2 extends Item {
|
|
||||||
public FirstFractalProjectile2() {
|
|
||||||
super(new Item.Properties());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-9
@@ -1,9 +0,0 @@
|
|||||||
package com.lzxnone.terraria.item.projectile.first_fractal;
|
|
||||||
|
|
||||||
import net.minecraft.world.item.Item;
|
|
||||||
|
|
||||||
public class FirstFractalProjectile3 extends Item {
|
|
||||||
public FirstFractalProjectile3() {
|
|
||||||
super(new Item.Properties());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-9
@@ -1,9 +0,0 @@
|
|||||||
package com.lzxnone.terraria.item.projectile.first_fractal;
|
|
||||||
|
|
||||||
import net.minecraft.world.item.Item;
|
|
||||||
|
|
||||||
public class FirstFractalProjectile4 extends Item {
|
|
||||||
public FirstFractalProjectile4() {
|
|
||||||
super(new Item.Properties());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-9
@@ -1,9 +0,0 @@
|
|||||||
package com.lzxnone.terraria.item.projectile.first_fractal;
|
|
||||||
|
|
||||||
import net.minecraft.world.item.Item;
|
|
||||||
|
|
||||||
public class FirstFractalProjectile5 extends Item {
|
|
||||||
public FirstFractalProjectile5() {
|
|
||||||
super(new Item.Properties());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-9
@@ -1,9 +0,0 @@
|
|||||||
package com.lzxnone.terraria.item.projectile.first_fractal;
|
|
||||||
|
|
||||||
import net.minecraft.world.item.Item;
|
|
||||||
|
|
||||||
public class FirstFractalProjectile6 extends Item {
|
|
||||||
public FirstFractalProjectile6() {
|
|
||||||
super(new Item.Properties());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-9
@@ -1,9 +0,0 @@
|
|||||||
package com.lzxnone.terraria.item.projectile.first_fractal;
|
|
||||||
|
|
||||||
import net.minecraft.world.item.Item;
|
|
||||||
|
|
||||||
public class FirstFractalProjectile7 extends Item {
|
|
||||||
public FirstFractalProjectile7() {
|
|
||||||
super(new Item.Properties());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-9
@@ -1,9 +0,0 @@
|
|||||||
package com.lzxnone.terraria.item.projectile.first_fractal;
|
|
||||||
|
|
||||||
import net.minecraft.world.item.Item;
|
|
||||||
|
|
||||||
public class FirstFractalProjectile8 extends Item {
|
|
||||||
public FirstFractalProjectile8() {
|
|
||||||
super(new Item.Properties());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-9
@@ -1,9 +0,0 @@
|
|||||||
package com.lzxnone.terraria.item.projectile.first_fractal;
|
|
||||||
|
|
||||||
import net.minecraft.world.item.Item;
|
|
||||||
|
|
||||||
public class FirstFractalProjectile9 extends Item {
|
|
||||||
public FirstFractalProjectile9() {
|
|
||||||
super(new Item.Properties());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,33 +1,28 @@
|
|||||||
package com.lzxnone.terraria.item.weapon;
|
package com.lzxnone.terraria.item.weapon;
|
||||||
|
|
||||||
|
import com.lzxnone.terraria.attachment.ModAttachments;
|
||||||
|
import com.lzxnone.terraria.attachment.PlayerMana;
|
||||||
import com.lzxnone.terraria.enchantment.ModEnchantments;
|
import com.lzxnone.terraria.enchantment.ModEnchantments;
|
||||||
import com.lzxnone.terraria.enchantment.ModEnchantmentConfigs;
|
import com.lzxnone.terraria.enchantment.ModEnchantmentConfigs;
|
||||||
import net.minecraft.core.component.DataComponents;
|
import com.lzxnone.terraria.event.PlayerManaSyncEventHandler;
|
||||||
|
import com.lzxnone.terraria.effect.ManaSicknessEffect;
|
||||||
|
import com.lzxnone.terraria.item.accessory.AccessoryUtil;
|
||||||
|
import com.lzxnone.terraria.item.accessory.effect.AutoManaPotionUser;
|
||||||
|
import com.lzxnone.terraria.item.accessory.effect.ManaCostModifier;
|
||||||
|
import com.lzxnone.terraria.utils.ManaPotionUtil;
|
||||||
import net.minecraft.core.registries.Registries;
|
import net.minecraft.core.registries.Registries;
|
||||||
import net.minecraft.resources.ResourceKey;
|
import net.minecraft.resources.ResourceKey;
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.world.entity.Entity;
|
|
||||||
import net.minecraft.world.entity.LivingEntity;
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
import net.minecraft.world.item.component.CustomData;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.item.Tier;
|
import net.minecraft.world.item.Tier;
|
||||||
import net.minecraft.world.item.enchantment.Enchantment;
|
import net.minecraft.world.item.enchantment.Enchantment;
|
||||||
import net.minecraft.world.item.enchantment.EnchantmentHelper;
|
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
|
|
||||||
import java.util.function.IntSupplier;
|
|
||||||
|
|
||||||
public class MagicWeapon extends Weapon {
|
public class MagicWeapon extends Weapon {
|
||||||
private static final String MANA_CONSUME_PROGRESS_KEY = "magicManaConsumeProgress";
|
public MagicWeapon(Tier tier, Properties properties) {
|
||||||
private static final String MANA_RECOVER_PROGRESS_KEY = "magicManaRecoverProgress";
|
|
||||||
|
|
||||||
private final IntSupplier manaConsumeRate;
|
|
||||||
private final IntSupplier manaRecoverRate;
|
|
||||||
|
|
||||||
public MagicWeapon(Tier tier, Properties properties, IntSupplier manaConsumeRate, IntSupplier manaRecoverRate) {
|
|
||||||
super(tier, properties);
|
super(tier, properties);
|
||||||
this.manaConsumeRate = manaConsumeRate;
|
|
||||||
this.manaRecoverRate = manaRecoverRate;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -47,24 +42,11 @@ public class MagicWeapon extends Weapon {
|
|||||||
onMagicUseTick(level, entity, stack, count);
|
onMagicUseTick(level, entity, stack, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void inventoryTick(ItemStack stack, Level level, Entity entity, int slotId, boolean isSelected) {
|
|
||||||
super.inventoryTick(stack, level, entity, slotId, isSelected);
|
|
||||||
if(level.isClientSide() || !(entity instanceof LivingEntity livingEntity)) return;
|
|
||||||
if(livingEntity.getUseItem() == stack) return;
|
|
||||||
|
|
||||||
recoverMana(stack, getFinalManaRecoverRate(stack, livingEntity));
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void onMagicUseTick(Level level, LivingEntity entity, ItemStack stack, int count) {
|
protected void onMagicUseTick(Level level, LivingEntity entity, ItemStack stack, int count) {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int getManaConsumeRate(ItemStack stack, LivingEntity entity) {
|
protected double getManaConsumeRate(ItemStack stack, LivingEntity entity) {
|
||||||
return Math.max(0, manaConsumeRate.getAsInt());
|
return 0.0D;
|
||||||
}
|
|
||||||
|
|
||||||
protected int getManaRecoverRate(ItemStack stack, LivingEntity entity) {
|
|
||||||
return Math.max(0, manaRecoverRate.getAsInt());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected double getFinalManaConsumeRate(ItemStack stack, LivingEntity entity) {
|
protected double getFinalManaConsumeRate(ItemStack stack, LivingEntity entity) {
|
||||||
@@ -74,16 +56,7 @@ public class MagicWeapon extends Weapon {
|
|||||||
|
|
||||||
rate *= Math.pow(ModEnchantmentConfigs.getManaLeakConsumeMultiplier(), leakLevel);
|
rate *= Math.pow(ModEnchantmentConfigs.getManaLeakConsumeMultiplier(), leakLevel);
|
||||||
rate *= Math.pow(ModEnchantmentConfigs.getManaEfficiencyConsumeMultiplier(), efficiencyLevel);
|
rate *= Math.pow(ModEnchantmentConfigs.getManaEfficiencyConsumeMultiplier(), efficiencyLevel);
|
||||||
return Math.max(0.0D, rate);
|
rate *= getAccessoryManaCostMultiplier(entity);
|
||||||
}
|
|
||||||
|
|
||||||
protected double getFinalManaRecoverRate(ItemStack stack, LivingEntity entity) {
|
|
||||||
double rate = getManaRecoverRate(stack, entity);
|
|
||||||
int gatheringLevel = getEnchantmentLevel(entity, stack, ModEnchantments.MANA_GATHERING);
|
|
||||||
int curseLevel = getEnchantmentLevel(entity, stack, ModEnchantments.MANA_GATHERING_CURSE);
|
|
||||||
|
|
||||||
rate *= Math.pow(ModEnchantmentConfigs.getManaGatheringRecoverMultiplier(), gatheringLevel);
|
|
||||||
rate *= Math.pow(ModEnchantmentConfigs.getManaGatheringCurseRecoverMultiplier(), curseLevel);
|
|
||||||
return Math.max(0.0D, rate);
|
return Math.max(0.0D, rate);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,51 +65,63 @@ public class MagicWeapon extends Weapon {
|
|||||||
int amplificationLevel = getEnchantmentLevel(entity, stack, ModEnchantments.ARCANE_AMPLIFICATION);
|
int amplificationLevel = getEnchantmentLevel(entity, stack, ModEnchantments.ARCANE_AMPLIFICATION);
|
||||||
|
|
||||||
finalDamage *= Math.pow(ModEnchantmentConfigs.getArcaneAmplificationDamageMultiplier(), amplificationLevel);
|
finalDamage *= Math.pow(ModEnchantmentConfigs.getArcaneAmplificationDamageMultiplier(), amplificationLevel);
|
||||||
|
finalDamage *= ManaSicknessEffect.getMagicDamageMultiplier(entity);
|
||||||
return (float) Math.max(0.0D, finalDamage);
|
return (float) Math.max(0.0D, finalDamage);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean canUseMagic(ItemStack stack, LivingEntity entity) {
|
protected boolean canUseMagic(ItemStack stack, LivingEntity entity) {
|
||||||
return !isManaEmpty(stack);
|
if(entity.hasInfiniteMaterials()) return true;
|
||||||
|
if(!isManaEmpty(entity)) return true;
|
||||||
|
if(entity instanceof ServerPlayer player) {
|
||||||
|
return tryAutoUseManaPotion(player);
|
||||||
|
}
|
||||||
|
return entity instanceof Player player && canAutoUseManaPotion(player) && ManaPotionUtil.hasManaPotion(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean isManaEmpty(ItemStack stack) {
|
protected boolean isManaEmpty(LivingEntity entity) {
|
||||||
return stack.isDamageableItem() && stack.getDamageValue() >= stack.getMaxDamage();
|
if(!(entity instanceof Player player)) return false;
|
||||||
|
return !player.getData(ModAttachments.PLAYER_MANA).hasMana();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean tryConsumeMana(Level level, LivingEntity entity, ItemStack stack, double amount) {
|
protected boolean tryConsumeMana(Level level, LivingEntity entity, ItemStack stack, double amount) {
|
||||||
if(amount <= 0.0D || entity.hasInfiniteMaterials()) return true;
|
if(amount <= 0.0D || entity.hasInfiniteMaterials()) return true;
|
||||||
if(!stack.isDamageableItem() || isManaEmpty(stack)) return false;
|
if(!(entity instanceof ServerPlayer player)) return true;
|
||||||
|
|
||||||
int pendingDamage = addManaProgress(stack, MANA_CONSUME_PROGRESS_KEY, amount);
|
PlayerMana mana = player.getData(ModAttachments.PLAYER_MANA);
|
||||||
if(pendingDamage <= 0) return true;
|
int oldMana = mana.getMana();
|
||||||
|
boolean canContinue = mana.consumeMana(amount);
|
||||||
int damage = pendingDamage;
|
mana.applyRecoverDelay();
|
||||||
if(level instanceof ServerLevel serverLevel) {
|
player.setData(ModAttachments.PLAYER_MANA, mana);
|
||||||
damage = EnchantmentHelper.processDurabilityChange(serverLevel, stack, damage);
|
if(mana.getMana() != oldMana) {
|
||||||
|
PlayerManaSyncEventHandler.sync(player);
|
||||||
}
|
}
|
||||||
if(damage <= 0) return true;
|
if(canContinue) return true;
|
||||||
|
return tryAutoUseManaPotion(player);
|
||||||
int nextDamage = Math.min(stack.getDamageValue() + damage, stack.getMaxDamage());
|
|
||||||
stack.setDamageValue(nextDamage);
|
|
||||||
return nextDamage < stack.getMaxDamage();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void recoverMana(ItemStack stack, double amount) {
|
private static double getAccessoryManaCostMultiplier(LivingEntity entity) {
|
||||||
if(amount <= 0.0D || !stack.isDamageableItem() || stack.getDamageValue() <= 0) return;
|
double[] multiplier = {1.0D};
|
||||||
int recoverAmount = addManaProgress(stack, MANA_RECOVER_PROGRESS_KEY, amount);
|
AccessoryUtil.forEachAccessory(entity, (accessory, stack) -> {
|
||||||
if(recoverAmount <= 0) return;
|
if(accessory instanceof ManaCostModifier modifier) {
|
||||||
|
multiplier[0] *= modifier.getManaCostMultiplier(stack, entity);
|
||||||
stack.setDamageValue(Math.max(0, stack.getDamageValue() - recoverAmount));
|
}
|
||||||
|
});
|
||||||
|
return multiplier[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
private int addManaProgress(ItemStack stack, String key, double amount) {
|
private static boolean canAutoUseManaPotion(LivingEntity entity) {
|
||||||
double progress = stack.getOrDefault(DataComponents.CUSTOM_DATA, CustomData.EMPTY)
|
boolean[] result = {false};
|
||||||
.copyTag()
|
AccessoryUtil.forEachAccessory(entity, (accessory, stack) -> {
|
||||||
.getDouble(key) + amount;
|
if(accessory instanceof AutoManaPotionUser autoUser && autoUser.canAutoUseManaPotion(stack, entity)) {
|
||||||
int wholeAmount = (int) Math.floor(progress);
|
result[0] = true;
|
||||||
double nextProgress = progress - wholeAmount;
|
}
|
||||||
CustomData.update(DataComponents.CUSTOM_DATA, stack, tag -> tag.putDouble(key, nextProgress));
|
});
|
||||||
return wholeAmount;
|
return result[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean tryAutoUseManaPotion(ServerPlayer player) {
|
||||||
|
if(!canAutoUseManaPotion(player)) return false;
|
||||||
|
return ManaPotionUtil.tryUseManaPotion(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int getEnchantmentLevel(LivingEntity entity, ItemStack stack, ResourceKey<Enchantment> enchantment) {
|
private static int getEnchantmentLevel(LivingEntity entity, ItemStack stack, ResourceKey<Enchantment> enchantment) {
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import net.minecraft.network.chat.Component;
|
|||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.resources.ResourceKey;
|
import net.minecraft.resources.ResourceKey;
|
||||||
import net.minecraft.world.InteractionHand;
|
import net.minecraft.world.InteractionHand;
|
||||||
|
import net.minecraft.world.InteractionResultHolder;
|
||||||
import net.minecraft.world.entity.SlotAccess;
|
import net.minecraft.world.entity.SlotAccess;
|
||||||
import net.minecraft.world.entity.LivingEntity;
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
@@ -45,6 +46,10 @@ public class RangedWeapon extends Weapon {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected ResourceLocation getDefaultAmmo(ItemStack weaponStack) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public int getFinalAmmoConsumeAmount(ItemStack weaponStack, LivingEntity entity, int amount) {
|
public int getFinalAmmoConsumeAmount(ItemStack weaponStack, LivingEntity entity, int amount) {
|
||||||
if(amount <= 0) return 0;
|
if(amount <= 0) return 0;
|
||||||
int exhaustionLevel = getEnchantmentLevel(entity, weaponStack, ModEnchantments.AMMO_EXHAUSTION);
|
int exhaustionLevel = getEnchantmentLevel(entity, weaponStack, ModEnchantments.AMMO_EXHAUSTION);
|
||||||
@@ -138,6 +143,15 @@ public class RangedWeapon extends Weapon {
|
|||||||
|
|
||||||
protected void shoot(Level level, Player player, InteractionHand hand, ItemStack weaponStack) {}
|
protected void shoot(Level level, Player player, InteractionHand hand, ItemStack weaponStack) {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public InteractionResultHolder<ItemStack> use(Level level, Player player, InteractionHand hand) {
|
||||||
|
ItemStack stack = player.getItemInHand(hand);
|
||||||
|
if(player.getCooldowns().isOnCooldown(stack.getItem()) || !tryShoot(level, player, hand, stack)) return InteractionResultHolder.fail(stack);
|
||||||
|
player.startUsingItem(hand);
|
||||||
|
player.getCooldowns().addCooldown(stack.getItem(), Math.max(1, getUseTime(stack, player) / 3));
|
||||||
|
return InteractionResultHolder.consume(stack);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onUseTick(Level level, LivingEntity entity, ItemStack stack, int remainingUseTicks) {
|
public void onUseTick(Level level, LivingEntity entity, ItemStack stack, int remainingUseTicks) {
|
||||||
if(!(entity instanceof Player player)) return;
|
if(!(entity instanceof Player player)) return;
|
||||||
@@ -157,7 +171,11 @@ public class RangedWeapon extends Weapon {
|
|||||||
String ammo = weaponStack.getOrDefault(DataComponents.CUSTOM_DATA, CustomData.EMPTY)
|
String ammo = weaponStack.getOrDefault(DataComponents.CUSTOM_DATA, CustomData.EMPTY)
|
||||||
.copyTag()
|
.copyTag()
|
||||||
.getString(AMMO_KEY);
|
.getString(AMMO_KEY);
|
||||||
return ammo.isEmpty() ? null : ResourceLocation.parse(ammo);
|
if(!ammo.isEmpty()) return ResourceLocation.parse(ammo);
|
||||||
|
if(weaponStack.getItem() instanceof RangedWeapon rangedWeapon) {
|
||||||
|
return rangedWeapon.getDefaultAmmo(weaponStack);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ItemStack getAmmoStack(ItemStack weaponStack) {
|
public static ItemStack getAmmoStack(ItemStack weaponStack) {
|
||||||
|
|||||||
@@ -10,10 +10,12 @@ import com.lzxnone.terraria.item.ModItems;
|
|||||||
import com.lzxnone.terraria.item.weapon.MagicWeapon;
|
import com.lzxnone.terraria.item.weapon.MagicWeapon;
|
||||||
import com.lzxnone.terraria.item.weapon.melee.Mace;
|
import com.lzxnone.terraria.item.weapon.melee.Mace;
|
||||||
import com.lzxnone.terraria.particle.DustParticleOptions;
|
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.ConfigListItem;
|
||||||
import com.lzxnone.terraria.ui.config.ConfigUtil;
|
|
||||||
import com.lzxnone.terraria.ui.config.IConfigData;
|
import com.lzxnone.terraria.ui.config.IConfigData;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigDouble;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigFloat;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigInt;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigStruct;
|
||||||
import com.lzxnone.terraria.utils.DamageUtil;
|
import com.lzxnone.terraria.utils.DamageUtil;
|
||||||
import com.lzxnone.terraria.utils.FilterUtil;
|
import com.lzxnone.terraria.utils.FilterUtil;
|
||||||
import com.lzxnone.terraria.utils.MathUtil;
|
import com.lzxnone.terraria.utils.MathUtil;
|
||||||
@@ -22,6 +24,7 @@ import com.lzxnone.terraria.utils.SoundUtil;
|
|||||||
import com.mojang.math.Axis;
|
import com.mojang.math.Axis;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
|
import net.minecraft.core.component.DataComponents;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
import net.minecraft.world.InteractionHand;
|
import net.minecraft.world.InteractionHand;
|
||||||
@@ -32,6 +35,7 @@ import net.minecraft.world.entity.player.Player;
|
|||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.world.item.Item;
|
import net.minecraft.world.item.Item;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
import net.minecraft.world.item.component.CustomData;
|
||||||
import net.minecraft.world.item.Rarity;
|
import net.minecraft.world.item.Rarity;
|
||||||
import net.minecraft.world.item.Tiers;
|
import net.minecraft.world.item.Tiers;
|
||||||
import net.minecraft.world.item.UseAnim;
|
import net.minecraft.world.item.UseAnim;
|
||||||
@@ -49,89 +53,79 @@ import java.util.List;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
public class LastPrism extends MagicWeapon {
|
public class LastPrism extends MagicWeapon {
|
||||||
private static final String CONFIG_TRANSLATION_PREFIX = "lzxnoneterraria.configuration.";
|
private static final String USE_START_GAME_TIME_KEY = "lastPrismUseStartGameTime";
|
||||||
|
|
||||||
public static final String DAMAGE_PATH = "weapon.last_prism.damage";
|
|
||||||
public static final float DAMAGE_DEFAULT = 1.0f;
|
|
||||||
public static final float DAMAGE_MIN = 0.0f;
|
|
||||||
public static final float DAMAGE_MAX = 8388600.0f;
|
|
||||||
|
|
||||||
public static final String CHARGE_TIME_PATH = "weapon.last_prism.charge_time";
|
|
||||||
public static final int CHARGE_TIME_DEFAULT = 67;
|
|
||||||
public static final int CHARGE_TIME_MIN = 1;
|
|
||||||
public static final int CHARGE_TIME_MAX = 72000;
|
|
||||||
|
|
||||||
public static final String MAX_USE_TIME_PATH = "weapon.last_prism.max_use_time";
|
|
||||||
public static final int MAX_USE_TIME_DEFAULT = 1200;
|
|
||||||
public static final int MAX_USE_TIME_MIN = 1;
|
|
||||||
public static final int MAX_USE_TIME_MAX = 72000;
|
|
||||||
|
|
||||||
public static final String MAX_RANGE_PATH = "weapon.last_prism.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 = 512.0;
|
|
||||||
|
|
||||||
public static final String MANA_CONSUME_RATE_PATH = "weapon.last_prism.mana_consume_rate";
|
|
||||||
public static final int MANA_CONSUME_RATE_DEFAULT = 20;
|
|
||||||
public static final int MANA_CONSUME_RATE_MIN = 0;
|
|
||||||
public static final int MANA_CONSUME_RATE_MAX = 72000;
|
|
||||||
|
|
||||||
public static final String MANA_RECOVER_RATE_PATH = "weapon.last_prism.mana_recover_rate";
|
|
||||||
public static final int MANA_RECOVER_RATE_DEFAULT = 20;
|
|
||||||
public static final int MANA_RECOVER_RATE_MIN = 0;
|
|
||||||
public static final int MANA_RECOVER_RATE_MAX = 72000;
|
|
||||||
|
|
||||||
|
public static final ConfigFloat DAMAGE = new ConfigFloat(
|
||||||
|
"weapon.last_prism.damage",
|
||||||
|
"last_prism_damage",
|
||||||
|
1.0f,
|
||||||
|
0.0f,
|
||||||
|
8388600.0f
|
||||||
|
);
|
||||||
|
public static final ConfigInt CHARGE_TIME = new ConfigInt(
|
||||||
|
"weapon.last_prism.charge_time",
|
||||||
|
"last_prism_charge_time",
|
||||||
|
67,
|
||||||
|
1,
|
||||||
|
72000
|
||||||
|
);
|
||||||
|
public static final ConfigInt MAX_USE_TIME = new ConfigInt(
|
||||||
|
"weapon.last_prism.max_use_time",
|
||||||
|
"last_prism_max_use_time",
|
||||||
|
1200,
|
||||||
|
1,
|
||||||
|
72000
|
||||||
|
);
|
||||||
|
public static final ConfigDouble MAX_RANGE = new ConfigDouble(
|
||||||
|
"weapon.last_prism.max_range",
|
||||||
|
"last_prism_max_range",
|
||||||
|
64.0,
|
||||||
|
1.0,
|
||||||
|
512.0
|
||||||
|
);
|
||||||
|
public static final ConfigInt MANA_CONSUME_RATE = new ConfigInt(
|
||||||
|
"weapon.last_prism.mana_consume_rate",
|
||||||
|
"last_prism_mana_consume_rate",
|
||||||
|
7,
|
||||||
|
0,
|
||||||
|
72000
|
||||||
|
);
|
||||||
public LastPrism() {
|
public LastPrism() {
|
||||||
super(
|
super(
|
||||||
Tiers.NETHERITE,
|
Tiers.NETHERITE,
|
||||||
new Item.Properties().stacksTo(1).fireResistant().rarity(Rarity.EPIC),
|
new Item.Properties().stacksTo(1).fireResistant().rarity(Rarity.EPIC)
|
||||||
LastPrism::getManaConsumeRate,
|
|
||||||
LastPrism::getManaRecoverRate
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
||||||
@Override
|
@Override
|
||||||
public void onConfigLoad() {
|
public void onConfigLoad() {
|
||||||
ConfigFactory.loadFloatConfig(DAMAGE_PATH, configText("last_prism_damage"), configTooltip("last_prism_damage"), DAMAGE_DEFAULT, DAMAGE_MIN, DAMAGE_MAX);
|
ConfigStruct.loadAll(
|
||||||
ConfigFactory.loadIntConfig(CHARGE_TIME_PATH, configText("last_prism_charge_time"), configTooltip("last_prism_charge_time"), CHARGE_TIME_DEFAULT, CHARGE_TIME_MIN, CHARGE_TIME_MAX);
|
DAMAGE,
|
||||||
ConfigFactory.loadIntConfig(MAX_USE_TIME_PATH, configText("last_prism_max_use_time"), configTooltip("last_prism_max_use_time"), MAX_USE_TIME_DEFAULT, MAX_USE_TIME_MIN, MAX_USE_TIME_MAX);
|
CHARGE_TIME,
|
||||||
ConfigFactory.loadDoubleConfig(MAX_RANGE_PATH, configText("last_prism_max_range"), configTooltip("last_prism_max_range"), MAX_RANGE_DEFAULT, MAX_RANGE_MIN, MAX_RANGE_MAX);
|
MAX_USE_TIME,
|
||||||
ConfigFactory.loadIntConfig(MANA_CONSUME_RATE_PATH, configText("last_prism_mana_consume_rate"), configTooltip("last_prism_mana_consume_rate"), MANA_CONSUME_RATE_DEFAULT, MANA_CONSUME_RATE_MIN, MANA_CONSUME_RATE_MAX);
|
MAX_RANGE,
|
||||||
ConfigFactory.loadIntConfig(MANA_RECOVER_RATE_PATH, configText("last_prism_mana_recover_rate"), configTooltip("last_prism_mana_recover_rate"), MANA_RECOVER_RATE_DEFAULT, MANA_RECOVER_RATE_MIN, MANA_RECOVER_RATE_MAX);
|
MANA_CONSUME_RATE
|
||||||
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
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 float getDamage() {
|
|
||||||
return Math.clamp(ConfigUtil.readFloat(DAMAGE_PATH, DAMAGE_DEFAULT), DAMAGE_MIN, DAMAGE_MAX);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getChargeTime() {
|
public static int getChargeTime() {
|
||||||
return Math.clamp(ConfigUtil.readInt(CHARGE_TIME_PATH, CHARGE_TIME_DEFAULT), CHARGE_TIME_MIN, CHARGE_TIME_MAX);
|
return CHARGE_TIME.get();
|
||||||
}
|
|
||||||
|
|
||||||
public static int getMaxUseTime() {
|
|
||||||
return Math.clamp(ConfigUtil.readInt(MAX_USE_TIME_PATH, MAX_USE_TIME_DEFAULT), MAX_USE_TIME_MIN, MAX_USE_TIME_MAX);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double getMaxRange() {
|
public static double getMaxRange() {
|
||||||
return Math.clamp(ConfigUtil.readDouble(MAX_RANGE_PATH, MAX_RANGE_DEFAULT), MAX_RANGE_MIN, MAX_RANGE_MAX);
|
return MAX_RANGE.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getManaConsumeRate() {
|
@Override
|
||||||
return Math.clamp(ConfigUtil.readInt(MANA_CONSUME_RATE_PATH, MANA_CONSUME_RATE_DEFAULT), MANA_CONSUME_RATE_MIN, MANA_CONSUME_RATE_MAX);
|
protected double getManaConsumeRate(ItemStack stack, LivingEntity entity) {
|
||||||
}
|
long startGameTime = stack.getOrDefault(DataComponents.CUSTOM_DATA, CustomData.EMPTY)
|
||||||
|
.copyTag()
|
||||||
public static int getManaRecoverRate() {
|
.getLong(USE_START_GAME_TIME_KEY);
|
||||||
return Math.clamp(ConfigUtil.readInt(MANA_RECOVER_RATE_PATH, MANA_RECOVER_RATE_DEFAULT), MANA_RECOVER_RATE_MIN, MANA_RECOVER_RATE_MAX);
|
long elapsedTime = Math.max(0L, entity.level().getGameTime() - startGameTime);
|
||||||
|
double useRatio = Mth.clamp(elapsedTime / (double)MAX_USE_TIME.get(), 0.0D, 1.0D);
|
||||||
|
return MANA_CONSUME_RATE.get() * useRatio;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final ConfigListItem CONFIG_LIST_ITEM = new ConfigListItem(
|
public static final ConfigListItem CONFIG_LIST_ITEM = new ConfigListItem(
|
||||||
@@ -239,7 +233,7 @@ public class LastPrism extends MagicWeapon {
|
|||||||
AABB entityBox = hitEntity.getBoundingBox().inflate(beamData.radius());
|
AABB entityBox = hitEntity.getBoundingBox().inflate(beamData.radius());
|
||||||
Optional<Vec3> clipResult = entityBox.clip(beamData.start(), beamData.end());
|
Optional<Vec3> clipResult = entityBox.clip(beamData.start(), beamData.end());
|
||||||
if(entityBox.contains(beamData.start()) || clipResult.isPresent()) {
|
if(entityBox.contains(beamData.start()) || clipResult.isPresent()) {
|
||||||
if(DamageUtil.magicAttack(beam, hitEntity, beam.getEntityData().get(StaticSummon.STACK_SOURCE), getDamage() * beamData.ratio(), 0.1f)) {
|
if(DamageUtil.magicAttack(beam, hitEntity, beam.getEntityData().get(StaticSummon.STACK_SOURCE), DAMAGE.get() * beamData.ratio(), 0.1f)) {
|
||||||
hitEntity.invulnerableTime = 5;
|
hitEntity.invulnerableTime = 5;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -269,8 +263,8 @@ public class LastPrism extends MagicWeapon {
|
|||||||
Vector3f[] dirs = MathUtil.computeCoordinateSystem(owner);
|
Vector3f[] dirs = MathUtil.computeCoordinateSystem(owner);
|
||||||
float time = tri.getEntityData().get(StaticSummon.AGE) + partialTick;
|
float time = tri.getEntityData().get(StaticSummon.AGE) + partialTick;
|
||||||
float angle = computePrismAngle(time);
|
float angle = computePrismAngle(time);
|
||||||
float ratio = Math.min(1.0f, time / getChargeTime());
|
float ratio = Math.min(1.0f, time / CHARGE_TIME.get());
|
||||||
double maxRange = getMaxRange();
|
double maxRange = MAX_RANGE.get();
|
||||||
double dy = maxRange / 2;
|
double dy = maxRange / 2;
|
||||||
|
|
||||||
Vec3 basePos = tri.position().add(MathUtil.toVec3(dirs[0]).scale(0.5f));
|
Vec3 basePos = tri.position().add(MathUtil.toVec3(dirs[0]).scale(0.5f));
|
||||||
@@ -304,7 +298,7 @@ public class LastPrism extends MagicWeapon {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static float computePrismAngle(float time) {
|
private static float computePrismAngle(float time) {
|
||||||
int chargeTime = getChargeTime();
|
int chargeTime = CHARGE_TIME.get();
|
||||||
float a = MAX_ROTATE / chargeTime;
|
float a = MAX_ROTATE / chargeTime;
|
||||||
float v = Math.min(a * time, MAX_ROTATE);
|
float v = Math.min(a * time, MAX_ROTATE);
|
||||||
if(v < MAX_ROTATE) {
|
if(v < MAX_ROTATE) {
|
||||||
@@ -319,6 +313,7 @@ public class LastPrism extends MagicWeapon {
|
|||||||
if(!canUseMagic(stack, player)) return InteractionResultHolder.fail(stack);
|
if(!canUseMagic(stack, player)) return InteractionResultHolder.fail(stack);
|
||||||
|
|
||||||
if(stack.is(ModItems.LAST_PRISM.get()) && !player.level().isClientSide()) {
|
if(stack.is(ModItems.LAST_PRISM.get()) && !player.level().isClientSide()) {
|
||||||
|
CustomData.update(DataComponents.CUSTOM_DATA, stack, tag -> tag.putLong(USE_START_GAME_TIME_KEY, level.getGameTime()));
|
||||||
Vector3f[] dirs = MathUtil.computeCoordinateSystem(player);
|
Vector3f[] dirs = MathUtil.computeCoordinateSystem(player);
|
||||||
|
|
||||||
StaticSummon summon = new StaticSummon(ModEntities.STATIC_SUMMON.get(), level);
|
StaticSummon summon = new StaticSummon(ModEntities.STATIC_SUMMON.get(), level);
|
||||||
@@ -348,7 +343,7 @@ public class LastPrism extends MagicWeapon {
|
|||||||
beam.setPos(pos);
|
beam.setPos(pos);
|
||||||
beam.getEntityData().set(StaticSummon.BEHAVIOR, StaticSummonBehaviors.LAST_PRISM_BEAM);
|
beam.getEntityData().set(StaticSummon.BEHAVIOR, StaticSummonBehaviors.LAST_PRISM_BEAM);
|
||||||
beam.getEntityData().set(StaticSummon.RENDER_MODE, "custom");
|
beam.getEntityData().set(StaticSummon.RENDER_MODE, "custom");
|
||||||
beam.getEntityData().set(StaticSummon.LIFETIME, getMaxUseTime());
|
beam.getEntityData().set(StaticSummon.LIFETIME, MAX_USE_TIME.get());
|
||||||
beam.getEntityData().set(StaticSummon.GLOW, true);
|
beam.getEntityData().set(StaticSummon.GLOW, true);
|
||||||
beam.getEntityData().set(StaticSummon.COLOR_R, color.x);
|
beam.getEntityData().set(StaticSummon.COLOR_R, color.x);
|
||||||
beam.getEntityData().set(StaticSummon.COLOR_G, color.y);
|
beam.getEntityData().set(StaticSummon.COLOR_G, color.y);
|
||||||
@@ -388,29 +383,4 @@ public class LastPrism extends MagicWeapon {
|
|||||||
public int getUseDuration(ItemStack stack, LivingEntity entity) {
|
public int getUseDuration(ItemStack stack, LivingEntity entity) {
|
||||||
return 72000;
|
return 72000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private static float[] computeSoftPrismColor(float hue) {
|
|
||||||
float normalizedHue = Math.floorMod((int)(hue * 1000.0F), 1000) / 1000.0F;
|
|
||||||
int color = Mth.hsvToRgb(normalizedHue, 0.85F, 1.0F);
|
|
||||||
float rainbowR = ((color >> 16) & 255) / 255.0F;
|
|
||||||
float rainbowG = ((color >> 8) & 255) / 255.0F;
|
|
||||||
float rainbowB = (color & 255) / 255.0F;
|
|
||||||
float tint = 0.75F;
|
|
||||||
|
|
||||||
return new float[]{
|
|
||||||
1.0F * (1.0F - tint) + rainbowR * tint,
|
|
||||||
1.0F * (1.0F - tint) + rainbowG * tint,
|
|
||||||
1.0F * (1.0F - tint) + rainbowB * tint
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static Vec3 computeRingDir(Vec3 n, Vec3 b, float ang) {
|
|
||||||
return n.scale(Math.cos(ang)).add(b.scale(Math.sin(ang)));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -6,10 +6,11 @@ import com.lzxnone.terraria.effect.ModEffects;
|
|||||||
import com.lzxnone.terraria.entity.ModEntities;
|
import com.lzxnone.terraria.entity.ModEntities;
|
||||||
import com.lzxnone.terraria.entity.summon.BeeSummon;
|
import com.lzxnone.terraria.entity.summon.BeeSummon;
|
||||||
import com.lzxnone.terraria.item.IItemWaveBehavior;
|
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.ConfigListItem;
|
||||||
import com.lzxnone.terraria.ui.config.ConfigUtil;
|
|
||||||
import com.lzxnone.terraria.ui.config.IConfigData;
|
import com.lzxnone.terraria.ui.config.IConfigData;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigFloat;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigInt;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigStruct;
|
||||||
import com.lzxnone.terraria.utils.FilterUtil;
|
import com.lzxnone.terraria.utils.FilterUtil;
|
||||||
import com.lzxnone.terraria.utils.MathUtil;
|
import com.lzxnone.terraria.utils.MathUtil;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
@@ -29,23 +30,27 @@ import net.minecraft.world.phys.Vec3;
|
|||||||
import net.neoforged.neoforge.event.entity.player.AttackEntityEvent;
|
import net.neoforged.neoforge.event.entity.player.AttackEntityEvent;
|
||||||
|
|
||||||
public class BeeKeeper extends MeleeWeapon {
|
public class BeeKeeper extends MeleeWeapon {
|
||||||
private static final String CONFIG_TRANSLATION_PREFIX = "lzxnoneterraria.configuration.";
|
public static final ConfigInt MAX_BEES = new ConfigInt(
|
||||||
|
"weapon.bee_keeper.max_bees",
|
||||||
public static final String MAX_BEES_PATH = "weapon.bee_keeper.max_bees";
|
"bee_keeper_max_bees",
|
||||||
public static final int MAX_BEES_DEFAULT = 3;
|
3,
|
||||||
public static final int MAX_BEES_MIN = 0;
|
0,
|
||||||
public static final int MAX_BEES_MAX = 10;
|
10
|
||||||
|
);
|
||||||
public static final String CONFUSION_DURATION_PATH = "weapon.bee_keeper.confusion_duration";
|
public static final ConfigInt CONFUSION_DURATION = new ConfigInt(
|
||||||
public static final int CONFUSION_DURATION_DEFAULT = 40;
|
"weapon.bee_keeper.confusion_duration",
|
||||||
public static final int CONFUSION_DURATION_MIN = 0;
|
"bee_keeper_confusion_duration",
|
||||||
public static final int CONFUSION_DURATION_MAX = 1200;
|
40,
|
||||||
|
0,
|
||||||
public static final String BEE_DAMAGE_PATH = "weapon.bee_keeper.bee_damage";
|
1200
|
||||||
public static final float BEE_DAMAGE_DEFAULT = 2.0f;
|
);
|
||||||
public static final float BEE_DAMAGE_MIN = 0.0f;
|
public static final ConfigFloat BEE_DAMAGE = new ConfigFloat(
|
||||||
public static final float BEE_DAMAGE_MAX = 8388600.0f;
|
"weapon.bee_keeper.bee_damage",
|
||||||
|
"bee_keeper_bee_damage",
|
||||||
|
2.0f,
|
||||||
|
0.0f,
|
||||||
|
8388600.0f
|
||||||
|
);
|
||||||
public BeeKeeper() {
|
public BeeKeeper() {
|
||||||
super(Tiers.IRON, new Item.Properties().attributes(ItemAttributeModifiers.builder()
|
super(Tiers.IRON, new Item.Properties().attributes(ItemAttributeModifiers.builder()
|
||||||
.add(Attributes.ATTACK_DAMAGE,
|
.add(Attributes.ATTACK_DAMAGE,
|
||||||
@@ -61,30 +66,16 @@ public class BeeKeeper extends MeleeWeapon {
|
|||||||
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
||||||
@Override
|
@Override
|
||||||
public void onConfigLoad() {
|
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);
|
ConfigStruct.loadAll(
|
||||||
ConfigFactory.loadIntConfig(CONFUSION_DURATION_PATH, configText("bee_keeper_confusion_duration"), configTooltip("bee_keeper_confusion_duration"), CONFUSION_DURATION_DEFAULT, CONFUSION_DURATION_MIN, CONFUSION_DURATION_MAX);
|
MAX_BEES,
|
||||||
ConfigFactory.loadFloatConfig(BEE_DAMAGE_PATH, configText("bee_keeper_bee_damage"), configTooltip("bee_keeper_bee_damage"), BEE_DAMAGE_DEFAULT, BEE_DAMAGE_MIN, BEE_DAMAGE_MAX);
|
CONFUSION_DURATION,
|
||||||
|
BEE_DAMAGE
|
||||||
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
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 float getBeeDamage() {
|
public static float getBeeDamage() {
|
||||||
return Math.clamp(ConfigUtil.readFloat(BEE_DAMAGE_PATH, BEE_DAMAGE_DEFAULT), BEE_DAMAGE_MIN, BEE_DAMAGE_MAX);
|
return BEE_DAMAGE.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final ConfigListItem CONFIG_LIST_ITEM = new ConfigListItem(
|
public static final ConfigListItem CONFIG_LIST_ITEM = new ConfigListItem(
|
||||||
@@ -107,12 +98,12 @@ public class BeeKeeper extends MeleeWeapon {
|
|||||||
if(target instanceof LivingEntity livingTarget && FilterUtil.createLivingTargetFilter(player).test(livingTarget)) {
|
if(target instanceof LivingEntity livingTarget && FilterUtil.createLivingTargetFilter(player).test(livingTarget)) {
|
||||||
livingTarget.addEffect(new MobEffectInstance(
|
livingTarget.addEffect(new MobEffectInstance(
|
||||||
ModEffects.CONFUSED,
|
ModEffects.CONFUSED,
|
||||||
getConfusionDuration(),
|
CONFUSION_DURATION.get(),
|
||||||
0
|
0
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
int maxBees = getMaxBees();
|
int maxBees = MAX_BEES.get();
|
||||||
int count = maxBees > 0 ? player.level().random.nextInt(maxBees) + 1 : 0;
|
int count = maxBees > 0 ? player.level().random.nextInt(maxBees) + 1 : 0;
|
||||||
while(count-- > 0) {
|
while(count-- > 0) {
|
||||||
BeeSummon bee = ModEntities.BEE_SUMMON.get().create(player.level());
|
BeeSummon bee = ModEntities.BEE_SUMMON.get().create(player.level());
|
||||||
|
|||||||
@@ -35,102 +35,82 @@ import net.minecraft.world.phys.BlockHitResult;
|
|||||||
import net.minecraft.world.phys.EntityHitResult;
|
import net.minecraft.world.phys.EntityHitResult;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
import org.joml.Vector3f;
|
import org.joml.Vector3f;
|
||||||
import com.lzxnone.terraria.ui.config.ConfigFactory;
|
|
||||||
import com.lzxnone.terraria.ui.config.ConfigListItem;
|
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.ui.config.IConfigData;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigDouble;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigFloat;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigInt;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigStruct;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class BladeOfGrass extends MeleeWeapon {
|
public class BladeOfGrass extends MeleeWeapon {
|
||||||
private static final String CONFIG_TRANSLATION_PREFIX = "lzxnoneterraria.configuration.";
|
public static final ConfigFloat PROJECTILE_DAMAGE = new ConfigFloat(
|
||||||
|
"weapon.blade_of_grass.projectile_damage",
|
||||||
public static final String PROJECTILE_DAMAGE_PATH = "weapon.blade_of_grass.projectile_damage";
|
"blade_of_grass_projectile_damage",
|
||||||
public static final float PROJECTILE_DAMAGE_DEFAULT = 2.0f;
|
2.0f,
|
||||||
public static final float PROJECTILE_DAMAGE_MIN = 0.0f;
|
0.0f,
|
||||||
public static final float PROJECTILE_DAMAGE_MAX = 8388600.0f;
|
8388600.0f
|
||||||
|
);
|
||||||
public static final String EFFECT_DURATION_PATH = "weapon.blade_of_grass.effect_duration";
|
public static final ConfigInt EFFECT_DURATION = new ConfigInt(
|
||||||
public static final int EFFECT_DURATION_DEFAULT = 140;
|
"weapon.blade_of_grass.effect_duration",
|
||||||
public static final int EFFECT_DURATION_MIN = 0;
|
"blade_of_grass_effect_duration",
|
||||||
public static final int EFFECT_DURATION_MAX = 72000;
|
140,
|
||||||
|
0,
|
||||||
public static final String TARGET_RANGE_PATH = "weapon.blade_of_grass.target_range";
|
72000
|
||||||
public static final double TARGET_RANGE_DEFAULT = 8.0;
|
);
|
||||||
public static final double TARGET_RANGE_MIN = 1.0;
|
public static final ConfigDouble TARGET_RANGE = new ConfigDouble(
|
||||||
public static final double TARGET_RANGE_MAX = 64.0;
|
"weapon.blade_of_grass.target_range",
|
||||||
|
"blade_of_grass_target_range",
|
||||||
public static final String PROJECTILE_LIFETIME_PATH = "weapon.blade_of_grass.projectile_lifetime";
|
8.0,
|
||||||
public static final int PROJECTILE_LIFETIME_DEFAULT = 60;
|
1.0,
|
||||||
public static final int PROJECTILE_LIFETIME_MIN = 1;
|
64.0
|
||||||
public static final int PROJECTILE_LIFETIME_MAX = 600;
|
);
|
||||||
|
public static final ConfigInt PROJECTILE_LIFETIME = new ConfigInt(
|
||||||
public static final String PROJECTILE_MAX_HIT_COUNT_PATH = "weapon.blade_of_grass.projectile_max_hit_count";
|
"weapon.blade_of_grass.projectile_lifetime",
|
||||||
public static final int PROJECTILE_MAX_HIT_COUNT_DEFAULT = 2;
|
"blade_of_grass_projectile_lifetime",
|
||||||
public static final int PROJECTILE_MAX_HIT_COUNT_MIN = 0;
|
60,
|
||||||
public static final int PROJECTILE_MAX_HIT_COUNT_MAX = 100;
|
1,
|
||||||
|
600
|
||||||
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 ConfigInt PROJECTILE_MAX_HIT_COUNT = new ConfigInt(
|
||||||
public static final double RADIUS_GROWTH_MIN = 0.0;
|
"weapon.blade_of_grass.projectile_max_hit_count",
|
||||||
public static final double RADIUS_GROWTH_MAX = 1.0;
|
"blade_of_grass_projectile_max_hit_count",
|
||||||
|
2,
|
||||||
public static final String ROTATION_SPEED_PATH = "weapon.blade_of_grass.rotation_speed";
|
0,
|
||||||
public static final double ROTATION_SPEED_DEFAULT = 0.2;
|
100
|
||||||
public static final double ROTATION_SPEED_MIN = 0.0;
|
);
|
||||||
public static final double ROTATION_SPEED_MAX = 1.0;
|
public static final ConfigDouble RADIUS_GROWTH = new ConfigDouble(
|
||||||
|
"weapon.blade_of_grass.radius_growth",
|
||||||
|
"blade_of_grass_radius_growth",
|
||||||
|
0.05,
|
||||||
|
0.0,
|
||||||
|
1.0
|
||||||
|
);
|
||||||
|
public static final ConfigDouble ROTATION_SPEED = new ConfigDouble(
|
||||||
|
"weapon.blade_of_grass.rotation_speed",
|
||||||
|
"blade_of_grass_rotation_speed",
|
||||||
|
0.2,
|
||||||
|
0.0,
|
||||||
|
1.0
|
||||||
|
);
|
||||||
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
||||||
@Override
|
@Override
|
||||||
public void onConfigLoad() {
|
public void onConfigLoad() {
|
||||||
ConfigFactory.loadFloatConfig(PROJECTILE_DAMAGE_PATH, configText("blade_of_grass_projectile_damage"), configTooltip("blade_of_grass_projectile_damage"), PROJECTILE_DAMAGE_DEFAULT, PROJECTILE_DAMAGE_MIN, PROJECTILE_DAMAGE_MAX);
|
ConfigStruct.loadAll(
|
||||||
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);
|
PROJECTILE_DAMAGE,
|
||||||
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);
|
EFFECT_DURATION,
|
||||||
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);
|
TARGET_RANGE,
|
||||||
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);
|
PROJECTILE_LIFETIME,
|
||||||
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);
|
PROJECTILE_MAX_HIT_COUNT,
|
||||||
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);
|
RADIUS_GROWTH,
|
||||||
|
ROTATION_SPEED
|
||||||
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
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 float getProjectileDamage() {
|
|
||||||
return Math.clamp(ConfigUtil.readFloat(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(
|
public static final ConfigListItem CONFIG_LIST_ITEM = new ConfigListItem(
|
||||||
"blade_of_grass",
|
"blade_of_grass",
|
||||||
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/item/blade_of_grass.png"),
|
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/item/blade_of_grass.png"),
|
||||||
@@ -173,19 +153,19 @@ public class BladeOfGrass extends MeleeWeapon {
|
|||||||
Entity owner = projectile.getOwner();
|
Entity owner = projectile.getOwner();
|
||||||
if(owner == null) return;
|
if(owner == null) return;
|
||||||
CompoundTag customData = projectile.getEntityData().get(StaticProjectile.CUSTOM_DATA);
|
CompoundTag customData = projectile.getEntityData().get(StaticProjectile.CUSTOM_DATA);
|
||||||
if(!customData.contains("hitCount") || customData.getInt("hitCount") >= getProjectileMaxHitCount()) return;
|
if(!customData.contains("hitCount") || customData.getInt("hitCount") >= PROJECTILE_MAX_HIT_COUNT.get()) return;
|
||||||
if(!FilterUtil.createTargetFilter(owner).test(target) || !(owner instanceof Player player)) return;
|
if(!FilterUtil.createTargetFilter(owner).test(target) || !(owner instanceof Player player)) return;
|
||||||
if(DamageUtil.meleeAttack(projectile, target, projectile.getEntityData().get(StaticProjectile.STACK_SOURCE), (float) getProjectileDamage(), 1.0f)) {
|
if(DamageUtil.meleeAttack(projectile, target, projectile.getEntityData().get(StaticProjectile.STACK_SOURCE), (float) PROJECTILE_DAMAGE.get(), 1.0f)) {
|
||||||
int count = customData.getInt("hitCount");
|
int count = customData.getInt("hitCount");
|
||||||
count++;
|
count++;
|
||||||
if(target instanceof LivingEntity livingEntity && projectile.getRandom().nextInt(4) == 0) {
|
if(target instanceof LivingEntity livingEntity && projectile.getRandom().nextInt(4) == 0) {
|
||||||
livingEntity.addEffect(new MobEffectInstance(
|
livingEntity.addEffect(new MobEffectInstance(
|
||||||
MobEffects.POISON,
|
MobEffects.POISON,
|
||||||
getEffectDuration(),
|
EFFECT_DURATION.get(),
|
||||||
0
|
0
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
if(count >= getProjectileMaxHitCount()) onDied(projectile);
|
if(count >= PROJECTILE_MAX_HIT_COUNT.get()) onDied(projectile);
|
||||||
else customData.putInt("hitCount", count);
|
else customData.putInt("hitCount", count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -211,7 +191,7 @@ public class BladeOfGrass extends MeleeWeapon {
|
|||||||
if(!level.isClientSide()) {
|
if(!level.isClientSide()) {
|
||||||
List<Entity> targets = CollisionUtil.searchEnemies(
|
List<Entity> targets = CollisionUtil.searchEnemies(
|
||||||
player.level(),
|
player.level(),
|
||||||
AABB.ofSize(player.getBoundingBox().getCenter(), getTargetRange() * 2, getTargetRange() * 2, getTargetRange() * 2),
|
AABB.ofSize(player.getBoundingBox().getCenter(), TARGET_RANGE.get() * 2, TARGET_RANGE.get() * 2, TARGET_RANGE.get() * 2),
|
||||||
player,
|
player,
|
||||||
player
|
player
|
||||||
);
|
);
|
||||||
@@ -248,9 +228,9 @@ public class BladeOfGrass extends MeleeWeapon {
|
|||||||
projectile.getEntityData().set(StaticProjectile.RXP, -90);
|
projectile.getEntityData().set(StaticProjectile.RXP, -90);
|
||||||
projectile.getEntityData().set(StaticProjectile.RZP, -90);
|
projectile.getEntityData().set(StaticProjectile.RZP, -90);
|
||||||
projectile.getEntityData().set(StaticProjectile.RYPS, 10);
|
projectile.getEntityData().set(StaticProjectile.RYPS, 10);
|
||||||
projectile.getEntityData().set(StaticProjectile.LIFETIME, getProjectileLifetime());
|
projectile.getEntityData().set(StaticProjectile.LIFETIME, PROJECTILE_LIFETIME.get());
|
||||||
projectile.getEntityData().set(StaticProjectile.EXPRESSION_Z, String.format("(%.3f+%.3f*t)*cos(%.3f*t+%.3f)", radius, getRadiusGrowth(), getRotationSpeed(), angleRad));
|
projectile.getEntityData().set(StaticProjectile.EXPRESSION_Z, String.format("(%.3f+%.3f*t)*cos(%.3f*t+%.3f)", radius, RADIUS_GROWTH.get(), ROTATION_SPEED.get(), angleRad));
|
||||||
projectile.getEntityData().set(StaticProjectile.EXPRESSION_Y, String.format("(%.3f+%.3f*t)*sin(%.3f*t+%.3f)", radius, getRadiusGrowth(), getRotationSpeed(), angleRad));
|
projectile.getEntityData().set(StaticProjectile.EXPRESSION_Y, String.format("(%.3f+%.3f*t)*sin(%.3f*t+%.3f)", radius, RADIUS_GROWTH.get(), ROTATION_SPEED.get(), angleRad));
|
||||||
|
|
||||||
CompoundTag customData = new CompoundTag();
|
CompoundTag customData = new CompoundTag();
|
||||||
customData.putInt("hitCount", 0);
|
customData.putInt("hitCount", 0);
|
||||||
|
|||||||
@@ -5,10 +5,10 @@ import com.lzxnone.terraria.LzxnoneTerraria;
|
|||||||
import com.lzxnone.terraria.effect.ModEffects;
|
import com.lzxnone.terraria.effect.ModEffects;
|
||||||
import com.lzxnone.terraria.item.IItemWaveBehavior;
|
import com.lzxnone.terraria.item.IItemWaveBehavior;
|
||||||
import com.lzxnone.terraria.particle.ModParticles;
|
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.ConfigListItem;
|
||||||
import com.lzxnone.terraria.ui.config.ConfigUtil;
|
|
||||||
import com.lzxnone.terraria.ui.config.IConfigData;
|
import com.lzxnone.terraria.ui.config.IConfigData;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigInt;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigStruct;
|
||||||
import com.lzxnone.terraria.utils.FilterUtil;
|
import com.lzxnone.terraria.utils.FilterUtil;
|
||||||
import com.lzxnone.terraria.utils.ParticleUtil;
|
import com.lzxnone.terraria.utils.ParticleUtil;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
@@ -29,18 +29,20 @@ import net.neoforged.neoforge.event.entity.player.AttackEntityEvent;
|
|||||||
import net.neoforged.neoforge.event.entity.player.PlayerInteractEvent;
|
import net.neoforged.neoforge.event.entity.player.PlayerInteractEvent;
|
||||||
|
|
||||||
public class BloodButcherer extends MeleeWeapon {
|
public class BloodButcherer extends MeleeWeapon {
|
||||||
private static final String CONFIG_TRANSLATION_PREFIX = "lzxnoneterraria.configuration.";
|
public static final ConfigInt EFFECT_DURATION = new ConfigInt(
|
||||||
|
"weapon.blood_butcherer.effect_duration",
|
||||||
public static final String EFFECT_DURATION_PATH = "weapon.blood_butcherer.effect_duration";
|
"blood_butcherer_effect_duration",
|
||||||
public static final int EFFECT_DURATION_DEFAULT = 180;
|
180,
|
||||||
public static final int EFFECT_DURATION_MIN = 0;
|
0,
|
||||||
public static final int EFFECT_DURATION_MAX = 72000;
|
72000
|
||||||
|
);
|
||||||
public static final String MAX_LEVEL_PATH = "weapon.blood_butcherer.max_level";
|
public static final ConfigInt MAX_LEVEL = new ConfigInt(
|
||||||
public static final int MAX_LEVEL_DEFAULT = 4;
|
"weapon.blood_butcherer.max_level",
|
||||||
public static final int MAX_LEVEL_MIN = 0;
|
"blood_butcherer_max_level",
|
||||||
public static final int MAX_LEVEL_MAX = 255;
|
4,
|
||||||
|
0,
|
||||||
|
255
|
||||||
|
);
|
||||||
public BloodButcherer() {
|
public BloodButcherer() {
|
||||||
super(Tiers.IRON, new Item.Properties().attributes(ItemAttributeModifiers.builder()
|
super(Tiers.IRON, new Item.Properties().attributes(ItemAttributeModifiers.builder()
|
||||||
.add(Attributes.ATTACK_DAMAGE,
|
.add(Attributes.ATTACK_DAMAGE,
|
||||||
@@ -56,27 +58,13 @@ public class BloodButcherer extends MeleeWeapon {
|
|||||||
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
||||||
@Override
|
@Override
|
||||||
public void onConfigLoad() {
|
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);
|
ConfigStruct.loadAll(
|
||||||
ConfigFactory.loadIntConfig(MAX_LEVEL_PATH, configText("blood_butcherer_max_level"), configTooltip("blood_butcherer_max_level"), MAX_LEVEL_DEFAULT, MAX_LEVEL_MIN, MAX_LEVEL_MAX);
|
EFFECT_DURATION,
|
||||||
|
MAX_LEVEL
|
||||||
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
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(
|
public static final ConfigListItem CONFIG_LIST_ITEM = new ConfigListItem(
|
||||||
"blood_butcherer",
|
"blood_butcherer",
|
||||||
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/item/blood_butcherer.png"),
|
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/item/blood_butcherer.png"),
|
||||||
@@ -139,12 +127,12 @@ public class BloodButcherer extends MeleeWeapon {
|
|||||||
currentLevel = instance.getAmplifier();
|
currentLevel = instance.getAmplifier();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int maxLevel = getMaxLevel();
|
int maxLevel = MAX_LEVEL.get();
|
||||||
if(maxLevel > 0) {
|
if(maxLevel > 0) {
|
||||||
if(currentLevel >= maxLevel) currentLevel = maxLevel - 1;
|
if(currentLevel >= maxLevel) currentLevel = maxLevel - 1;
|
||||||
livingTarget.addEffect(new MobEffectInstance(
|
livingTarget.addEffect(new MobEffectInstance(
|
||||||
ModEffects.BLOOD_BUTCHERED,
|
ModEffects.BLOOD_BUTCHERED,
|
||||||
getEffectDuration(),
|
EFFECT_DURATION.get(),
|
||||||
currentLevel + 1
|
currentLevel + 1
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,200 +46,171 @@ import net.neoforged.neoforge.event.entity.player.PlayerInteractEvent;
|
|||||||
import net.neoforged.neoforge.network.PacketDistributor;
|
import net.neoforged.neoforge.network.PacketDistributor;
|
||||||
import org.joml.Quaternionf;
|
import org.joml.Quaternionf;
|
||||||
import org.joml.Vector3f;
|
import org.joml.Vector3f;
|
||||||
import com.lzxnone.terraria.ui.config.ConfigFactory;
|
|
||||||
import com.lzxnone.terraria.ui.config.ConfigListItem;
|
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.ui.config.IConfigData;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigDouble;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigFloat;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigInt;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigStruct;
|
||||||
|
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
|
||||||
public class DevilsDevastation extends MeleeWeapon {
|
public class DevilsDevastation extends MeleeWeapon {
|
||||||
private static final String CONFIG_TRANSLATION_PREFIX = "lzxnoneterraria.configuration.";
|
public static final ConfigInt KILL_MODE_TIME = new ConfigInt(
|
||||||
|
"weapon.devils_devastation.kill_mode_time",
|
||||||
public static final String KILL_MODE_TIME_PATH = "weapon.devils_devastation.kill_mode_time";
|
"devils_devastation_kill_mode_time",
|
||||||
public static final int KILL_MODE_TIME_DEFAULT = 100;
|
100,
|
||||||
public static final int KILL_MODE_TIME_MIN = 0;
|
0,
|
||||||
public static final int KILL_MODE_TIME_MAX = 72000;
|
72000
|
||||||
|
);
|
||||||
public static final String KILL_MODE_COOLDOWN_TIME_PATH = "weapon.devils_devastation.kill_mode_cooldown_time";
|
public static final ConfigInt KILL_MODE_COOLDOWN_TIME = new ConfigInt(
|
||||||
public static final int KILL_MODE_COOLDOWN_TIME_DEFAULT = 100;
|
"weapon.devils_devastation.kill_mode_cooldown_time",
|
||||||
public static final int KILL_MODE_COOLDOWN_TIME_MIN = 0;
|
"devils_devastation_kill_mode_cooldown_time",
|
||||||
public static final int KILL_MODE_COOLDOWN_TIME_MAX = 72000;
|
100,
|
||||||
|
0,
|
||||||
public static final String PROJECTILE_DAMAGE_PATH = "weapon.devils_devastation.projectile_damage";
|
72000
|
||||||
public static final float PROJECTILE_DAMAGE_DEFAULT = 30.0f;
|
);
|
||||||
public static final float PROJECTILE_DAMAGE_MIN = 0.0f;
|
public static final ConfigFloat PROJECTILE_DAMAGE = new ConfigFloat(
|
||||||
public static final float PROJECTILE_DAMAGE_MAX = 8388600.0f;
|
"weapon.devils_devastation.projectile_damage",
|
||||||
|
"devils_devastation_projectile_damage",
|
||||||
public static final String PROJECTILE_LIFETIME_PATH = "weapon.devils_devastation.projectile_lifetime";
|
30.0f,
|
||||||
public static final int PROJECTILE_LIFETIME_DEFAULT = 40;
|
0.0f,
|
||||||
public static final int PROJECTILE_LIFETIME_MIN = 1;
|
8388600.0f
|
||||||
public static final int PROJECTILE_LIFETIME_MAX = 1200;
|
);
|
||||||
|
public static final ConfigInt PROJECTILE_LIFETIME = new ConfigInt(
|
||||||
public static final String PROJECTILE_SPEED_PATH = "weapon.devils_devastation.projectile_speed";
|
"weapon.devils_devastation.projectile_lifetime",
|
||||||
public static final double PROJECTILE_SPEED_DEFAULT = 3.0;
|
"devils_devastation_projectile_lifetime",
|
||||||
public static final double PROJECTILE_SPEED_MIN = 0.0;
|
40,
|
||||||
public static final double PROJECTILE_SPEED_MAX = 10.0;
|
1,
|
||||||
|
1200
|
||||||
public static final String STUCK_PROJECTILE_DAMAGE_PATH = "weapon.devils_devastation.stuck_projectile_damage";
|
);
|
||||||
public static final float STUCK_PROJECTILE_DAMAGE_DEFAULT = 30.0f;
|
public static final ConfigDouble PROJECTILE_SPEED = new ConfigDouble(
|
||||||
public static final float STUCK_PROJECTILE_DAMAGE_MIN = 0.0f;
|
"weapon.devils_devastation.projectile_speed",
|
||||||
public static final float STUCK_PROJECTILE_DAMAGE_MAX = 8388600.0f;
|
"devils_devastation_projectile_speed",
|
||||||
|
3.0,
|
||||||
public static final String STUCK_PROJECTILE_LIFETIME_PATH = "weapon.devils_devastation.stuck_projectile_lifetime";
|
0.0,
|
||||||
public static final int STUCK_PROJECTILE_LIFETIME_DEFAULT = 40;
|
10.0
|
||||||
public static final int STUCK_PROJECTILE_LIFETIME_MIN = 1;
|
);
|
||||||
public static final int STUCK_PROJECTILE_LIFETIME_MAX = 1200;
|
public static final ConfigFloat STUCK_PROJECTILE_DAMAGE = new ConfigFloat(
|
||||||
|
"weapon.devils_devastation.stuck_projectile_damage",
|
||||||
public static final String STUCK_PROJECTILE_SPEED_PATH = "weapon.devils_devastation.stuck_projectile_speed";
|
"devils_devastation_stuck_projectile_damage",
|
||||||
public static final double STUCK_PROJECTILE_SPEED_DEFAULT = 3.0;
|
30.0f,
|
||||||
public static final double STUCK_PROJECTILE_SPEED_MIN = 0.0;
|
0.0f,
|
||||||
public static final double STUCK_PROJECTILE_SPEED_MAX = 10.0;
|
8388600.0f
|
||||||
|
);
|
||||||
public static final String KILL_MODE_PROJECTILE_CYCLE_PATH = "weapon.devils_devastation.kill_mode_projectile_cycle";
|
public static final ConfigInt STUCK_PROJECTILE_LIFETIME = new ConfigInt(
|
||||||
public static final int KILL_MODE_PROJECTILE_CYCLE_DEFAULT = 8;
|
"weapon.devils_devastation.stuck_projectile_lifetime",
|
||||||
public static final int KILL_MODE_PROJECTILE_CYCLE_MIN = 1;
|
"devils_devastation_stuck_projectile_lifetime",
|
||||||
public static final int KILL_MODE_PROJECTILE_CYCLE_MAX = 200;
|
40,
|
||||||
|
1,
|
||||||
public static final String KILL_MODE_PROJECTILE_DAMAGE_PATH = "weapon.devils_devastation.kill_mode_projectile_damage";
|
1200
|
||||||
public static final float KILL_MODE_PROJECTILE_DAMAGE_DEFAULT = 200.0f;
|
);
|
||||||
public static final float KILL_MODE_PROJECTILE_DAMAGE_MIN = 0.0f;
|
public static final ConfigDouble STUCK_PROJECTILE_SPEED = new ConfigDouble(
|
||||||
public static final float KILL_MODE_PROJECTILE_DAMAGE_MAX = 8388600.0f;
|
"weapon.devils_devastation.stuck_projectile_speed",
|
||||||
|
"devils_devastation_stuck_projectile_speed",
|
||||||
public static final String KILL_MODE_PROJECTILE_ROTATE_PATH = "weapon.devils_devastation.kill_mode_projectile_rotate";
|
3.0,
|
||||||
public static final int KILL_MODE_PROJECTILE_ROTATE_DEFAULT = 30;
|
0.0,
|
||||||
public static final int KILL_MODE_PROJECTILE_ROTATE_MIN = 0;
|
10.0
|
||||||
public static final int KILL_MODE_PROJECTILE_ROTATE_MAX = 90;
|
);
|
||||||
|
public static final ConfigInt KILL_MODE_PROJECTILE_CYCLE = new ConfigInt(
|
||||||
public static final String STUCK_LIFETIME_PATH = "weapon.devils_devastation.stuck_lifetime";
|
"weapon.devils_devastation.kill_mode_projectile_cycle",
|
||||||
public static final int STUCK_LIFETIME_DEFAULT = 200;
|
"devils_devastation_kill_mode_projectile_cycle",
|
||||||
public static final int STUCK_LIFETIME_MIN = 1;
|
8,
|
||||||
public static final int STUCK_LIFETIME_MAX = 72000;
|
1,
|
||||||
|
200
|
||||||
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 ConfigFloat KILL_MODE_PROJECTILE_DAMAGE = new ConfigFloat(
|
||||||
public static final int MAX_STUCK_COUNT_MIN = 1;
|
"weapon.devils_devastation.kill_mode_projectile_damage",
|
||||||
public static final int MAX_STUCK_COUNT_MAX = 50;
|
"devils_devastation_kill_mode_projectile_damage",
|
||||||
|
200.0f,
|
||||||
public static final String MARK_LIGHTNING_DAMAGE_PATH = "weapon.devils_devastation.mark_lightning_damage";
|
0.0f,
|
||||||
public static final float MARK_LIGHTNING_DAMAGE_DEFAULT = 100.0f;
|
8388600.0f
|
||||||
public static final float MARK_LIGHTNING_DAMAGE_MIN = 0.0f;
|
);
|
||||||
public static final float MARK_LIGHTNING_DAMAGE_MAX = 8388600.0f;
|
public static final ConfigInt KILL_MODE_PROJECTILE_ROTATE = new ConfigInt(
|
||||||
|
"weapon.devils_devastation.kill_mode_projectile_rotate",
|
||||||
public static final String PROJECTILE_EFFECT_DURATION_PATH = "weapon.devils_devastation.projectile_effect_duration";
|
"devils_devastation_kill_mode_projectile_rotate",
|
||||||
public static final int PROJECTILE_EFFECT_DURATION_DEFAULT = 40;
|
30,
|
||||||
public static final int PROJECTILE_EFFECT_DURATION_MIN = 0;
|
0,
|
||||||
public static final int PROJECTILE_EFFECT_DURATION_MAX = 72000;
|
90
|
||||||
|
);
|
||||||
public static final String STUCK_PROJECTILE_EFFECT_DURATION_PATH = "weapon.devils_devastation.stuck_projectile_effect_duration";
|
public static final ConfigInt STUCK_LIFETIME = new ConfigInt(
|
||||||
public static final int STUCK_PROJECTILE_EFFECT_DURATION_DEFAULT = 60;
|
"weapon.devils_devastation.stuck_lifetime",
|
||||||
public static final int STUCK_PROJECTILE_EFFECT_DURATION_MIN = 0;
|
"devils_devastation_stuck_lifetime",
|
||||||
public static final int STUCK_PROJECTILE_EFFECT_DURATION_MAX = 72000;
|
200,
|
||||||
|
1,
|
||||||
public static final String KILL_MODE_PROJECTILE_EFFECT_DURATION_PATH = "weapon.devils_devastation.kill_mode_projectile_effect_duration";
|
72000
|
||||||
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 ConfigInt MAX_STUCK_COUNT = new ConfigInt(
|
||||||
public static final int KILL_MODE_PROJECTILE_EFFECT_DURATION_MAX = 72000;
|
"weapon.devils_devastation.max_stuck_count",
|
||||||
|
"devils_devastation_max_stuck_count",
|
||||||
|
5,
|
||||||
|
1,
|
||||||
|
50
|
||||||
|
);
|
||||||
|
public static final ConfigFloat MARK_LIGHTNING_DAMAGE = new ConfigFloat(
|
||||||
|
"weapon.devils_devastation.mark_lightning_damage",
|
||||||
|
"devils_devastation_mark_lightning_damage",
|
||||||
|
100.0f,
|
||||||
|
0.0f,
|
||||||
|
8388600.0f
|
||||||
|
);
|
||||||
|
public static final ConfigInt PROJECTILE_EFFECT_DURATION = new ConfigInt(
|
||||||
|
"weapon.devils_devastation.projectile_effect_duration",
|
||||||
|
"devils_devastation_projectile_effect_duration",
|
||||||
|
40,
|
||||||
|
0,
|
||||||
|
72000
|
||||||
|
);
|
||||||
|
public static final ConfigInt STUCK_PROJECTILE_EFFECT_DURATION = new ConfigInt(
|
||||||
|
"weapon.devils_devastation.stuck_projectile_effect_duration",
|
||||||
|
"devils_devastation_stuck_projectile_effect_duration",
|
||||||
|
60,
|
||||||
|
0,
|
||||||
|
72000
|
||||||
|
);
|
||||||
|
public static final ConfigInt KILL_MODE_PROJECTILE_EFFECT_DURATION = new ConfigInt(
|
||||||
|
"weapon.devils_devastation.kill_mode_projectile_effect_duration",
|
||||||
|
"devils_devastation_kill_mode_projectile_effect_duration",
|
||||||
|
70,
|
||||||
|
0,
|
||||||
|
72000
|
||||||
|
);
|
||||||
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
||||||
@Override
|
@Override
|
||||||
public void onConfigLoad() {
|
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);
|
ConfigStruct.loadAll(
|
||||||
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);
|
KILL_MODE_TIME,
|
||||||
ConfigFactory.loadFloatConfig(PROJECTILE_DAMAGE_PATH, configText("devils_devastation_projectile_damage"), configTooltip("devils_devastation_projectile_damage"), PROJECTILE_DAMAGE_DEFAULT, PROJECTILE_DAMAGE_MIN, PROJECTILE_DAMAGE_MAX);
|
KILL_MODE_COOLDOWN_TIME,
|
||||||
ConfigFactory.loadIntConfig(PROJECTILE_LIFETIME_PATH, configText("devils_devastation_projectile_lifetime"), configTooltip("devils_devastation_projectile_lifetime"), PROJECTILE_LIFETIME_DEFAULT, PROJECTILE_LIFETIME_MIN, PROJECTILE_LIFETIME_MAX);
|
PROJECTILE_DAMAGE,
|
||||||
ConfigFactory.loadDoubleConfig(PROJECTILE_SPEED_PATH, configText("devils_devastation_projectile_speed"), configTooltip("devils_devastation_projectile_speed"), PROJECTILE_SPEED_DEFAULT, PROJECTILE_SPEED_MIN, PROJECTILE_SPEED_MAX);
|
PROJECTILE_LIFETIME,
|
||||||
ConfigFactory.loadFloatConfig(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);
|
PROJECTILE_SPEED,
|
||||||
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);
|
STUCK_PROJECTILE_DAMAGE,
|
||||||
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);
|
STUCK_PROJECTILE_LIFETIME,
|
||||||
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);
|
STUCK_PROJECTILE_SPEED,
|
||||||
ConfigFactory.loadFloatConfig(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);
|
KILL_MODE_PROJECTILE_CYCLE,
|
||||||
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);
|
KILL_MODE_PROJECTILE_DAMAGE,
|
||||||
ConfigFactory.loadIntConfig(STUCK_LIFETIME_PATH, configText("devils_devastation_stuck_lifetime"), configTooltip("devils_devastation_stuck_lifetime"), STUCK_LIFETIME_DEFAULT, STUCK_LIFETIME_MIN, STUCK_LIFETIME_MAX);
|
KILL_MODE_PROJECTILE_ROTATE,
|
||||||
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);
|
STUCK_LIFETIME,
|
||||||
ConfigFactory.loadFloatConfig(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);
|
MAX_STUCK_COUNT,
|
||||||
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);
|
MARK_LIGHTNING_DAMAGE,
|
||||||
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);
|
PROJECTILE_EFFECT_DURATION,
|
||||||
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);
|
STUCK_PROJECTILE_EFFECT_DURATION,
|
||||||
|
KILL_MODE_PROJECTILE_EFFECT_DURATION
|
||||||
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
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() {
|
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);
|
return KILL_MODE_TIME.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getKillModeCooldownTime() {
|
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);
|
return KILL_MODE_COOLDOWN_TIME.get();
|
||||||
}
|
|
||||||
|
|
||||||
public static float getProjectileDamage() {
|
|
||||||
return Math.clamp(ConfigUtil.readFloat(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 float getStuckProjectileDamage() {
|
|
||||||
return Math.clamp(ConfigUtil.readFloat(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() {
|
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);
|
return KILL_MODE_PROJECTILE_CYCLE.get();
|
||||||
}
|
|
||||||
|
|
||||||
public static float getKillModeProjectileDamage() {
|
|
||||||
return Math.clamp(ConfigUtil.readFloat(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 float getMarkLightningDamage() {
|
|
||||||
return Math.clamp(ConfigUtil.readFloat(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(
|
public static final ConfigListItem CONFIG_LIST_ITEM = new ConfigListItem(
|
||||||
@@ -352,9 +323,9 @@ public class DevilsDevastation extends MeleeWeapon {
|
|||||||
Entity owner = projectile.getOwner();
|
Entity owner = projectile.getOwner();
|
||||||
if(owner == null) return;
|
if(owner == null) return;
|
||||||
if(!FilterUtil.createTargetFilter(owner).test(target) || !(owner instanceof Player player)) return;
|
if(!FilterUtil.createTargetFilter(owner).test(target) || !(owner instanceof Player player)) return;
|
||||||
if(DamageUtil.meleeAttack(projectile, target, projectile.getEntityData().get(StaticProjectile.STACK_SOURCE), (float) getProjectileDamage(), 1.0f)) {
|
if(DamageUtil.meleeAttack(projectile, target, projectile.getEntityData().get(StaticProjectile.STACK_SOURCE), (float) PROJECTILE_DAMAGE.get(), 1.0f)) {
|
||||||
if(target instanceof LivingEntity le) {
|
if(target instanceof LivingEntity le) {
|
||||||
MobEffectInstance effectInstance = new MobEffectInstance(ModEffects.DEMONIC_FLAMES, getProjectileEffectDuration(), 0);
|
MobEffectInstance effectInstance = new MobEffectInstance(ModEffects.DEMONIC_FLAMES, PROJECTILE_EFFECT_DURATION.get(), 0);
|
||||||
le.addEffect(effectInstance);
|
le.addEffect(effectInstance);
|
||||||
}
|
}
|
||||||
target.invulnerableTime = 5;
|
target.invulnerableTime = 5;
|
||||||
@@ -372,7 +343,7 @@ public class DevilsDevastation extends MeleeWeapon {
|
|||||||
summon.getEntityData().set(StaticSummon.SCALE_Z, 4.0f);
|
summon.getEntityData().set(StaticSummon.SCALE_Z, 4.0f);
|
||||||
summon.getEntityData().set(StaticSummon.RXP, -90);
|
summon.getEntityData().set(StaticSummon.RXP, -90);
|
||||||
summon.getEntityData().set(StaticSummon.RZP, -135);
|
summon.getEntityData().set(StaticSummon.RZP, -135);
|
||||||
summon.getEntityData().set(StaticSummon.LIFETIME, getStuckLifetime());
|
summon.getEntityData().set(StaticSummon.LIFETIME, STUCK_LIFETIME.get());
|
||||||
summon.getEntityData().set(StaticSummon.GLOW, true);
|
summon.getEntityData().set(StaticSummon.GLOW, true);
|
||||||
|
|
||||||
CompoundTag customData = new CompoundTag();
|
CompoundTag customData = new CompoundTag();
|
||||||
@@ -396,7 +367,7 @@ public class DevilsDevastation extends MeleeWeapon {
|
|||||||
}
|
}
|
||||||
if(target.isAlive()) {
|
if(target.isAlive()) {
|
||||||
List<UUID> uuids = new ArrayList<>(target.getData(ModAttachments.STUCK_DEVILS_DEVASTATION_PROJECTILE));
|
List<UUID> uuids = new ArrayList<>(target.getData(ModAttachments.STUCK_DEVILS_DEVASTATION_PROJECTILE));
|
||||||
if (uuids.size() >= getMaxStuckCount()) {
|
if (uuids.size() >= MAX_STUCK_COUNT.get()) {
|
||||||
Entity stuckProjectile = ((ServerLevel) projectile.level()).getEntity(uuids.getFirst());
|
Entity stuckProjectile = ((ServerLevel) projectile.level()).getEntity(uuids.getFirst());
|
||||||
if (stuckProjectile != null && stuckProjectile.isAlive() && stuckProjectile instanceof StaticSummon stuckStaticProjectile)
|
if (stuckProjectile != null && stuckProjectile.isAlive() && stuckProjectile instanceof StaticSummon stuckStaticProjectile)
|
||||||
summonStuckProjectile(stuckStaticProjectile);
|
summonStuckProjectile(stuckStaticProjectile);
|
||||||
@@ -536,9 +507,9 @@ public class DevilsDevastation extends MeleeWeapon {
|
|||||||
Entity owner = projectile.getOwner();
|
Entity owner = projectile.getOwner();
|
||||||
if(owner == null) return;
|
if(owner == null) return;
|
||||||
if(!FilterUtil.createTargetFilter(owner).test(target) || !(owner instanceof Player player)) return;
|
if(!FilterUtil.createTargetFilter(owner).test(target) || !(owner instanceof Player player)) return;
|
||||||
if(DamageUtil.meleeAttack(projectile, target, projectile.getEntityData().get(StaticProjectile.STACK_SOURCE), (float) getStuckProjectileDamage(), 1.0f)) {
|
if(DamageUtil.meleeAttack(projectile, target, projectile.getEntityData().get(StaticProjectile.STACK_SOURCE), (float) STUCK_PROJECTILE_DAMAGE.get(), 1.0f)) {
|
||||||
if(target instanceof LivingEntity le) {
|
if(target instanceof LivingEntity le) {
|
||||||
MobEffectInstance effectInstance = new MobEffectInstance(ModEffects.DEMONIC_FLAMES, getStuckProjectileEffectDuration(), 0);
|
MobEffectInstance effectInstance = new MobEffectInstance(ModEffects.DEMONIC_FLAMES, STUCK_PROJECTILE_EFFECT_DURATION.get(), 0);
|
||||||
le.addEffect(effectInstance);
|
le.addEffect(effectInstance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -646,9 +617,9 @@ public class DevilsDevastation extends MeleeWeapon {
|
|||||||
Entity target = result.getEntity();
|
Entity target = result.getEntity();
|
||||||
List<UUID> tempStuckList = target.getData(ModAttachments.STUCK_DEVILS_DEVASTATION_PROJECTILE);
|
List<UUID> tempStuckList = target.getData(ModAttachments.STUCK_DEVILS_DEVASTATION_PROJECTILE);
|
||||||
boolean valid = !tempStuckList.isEmpty();
|
boolean valid = !tempStuckList.isEmpty();
|
||||||
if(projectile.getOwner() instanceof Player player && DamageUtil.meleeAttack(projectile, target, projectile.getEntityData().get(StaticProjectile.STACK_SOURCE), (float) getKillModeProjectileDamage(), 4.0f)) {
|
if(projectile.getOwner() instanceof Player player && DamageUtil.meleeAttack(projectile, target, projectile.getEntityData().get(StaticProjectile.STACK_SOURCE), (float) KILL_MODE_PROJECTILE_DAMAGE.get(), 4.0f)) {
|
||||||
if(target instanceof LivingEntity le) {
|
if(target instanceof LivingEntity le) {
|
||||||
MobEffectInstance effectInstance = new MobEffectInstance(ModEffects.DEMONIC_FLAMES, getKillModeProjectileEffectDuration(), 1);
|
MobEffectInstance effectInstance = new MobEffectInstance(ModEffects.DEMONIC_FLAMES, KILL_MODE_PROJECTILE_EFFECT_DURATION.get(), 1);
|
||||||
le.addEffect(effectInstance);
|
le.addEffect(effectInstance);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -668,7 +639,7 @@ public class DevilsDevastation extends MeleeWeapon {
|
|||||||
summon.setPos(pos);
|
summon.setPos(pos);
|
||||||
summon.getEntityData().set(StaticSummon.BEHAVIOR, StaticSummonBehaviors.DEVILS_DEVASTATION_MARK);
|
summon.getEntityData().set(StaticSummon.BEHAVIOR, StaticSummonBehaviors.DEVILS_DEVASTATION_MARK);
|
||||||
summon.getEntityData().set(StaticSummon.RENDER_MODE, "custom");
|
summon.getEntityData().set(StaticSummon.RENDER_MODE, "custom");
|
||||||
summon.getEntityData().set(StaticSummon.LIFETIME, getKillModeProjectileCycle() + 20);
|
summon.getEntityData().set(StaticSummon.LIFETIME, KILL_MODE_PROJECTILE_CYCLE.get() + 20);
|
||||||
summon.getEntityData().set(StaticSummon.GLOW, true);
|
summon.getEntityData().set(StaticSummon.GLOW, true);
|
||||||
|
|
||||||
CompoundTag summonCustomData = new CompoundTag();
|
CompoundTag summonCustomData = new CompoundTag();
|
||||||
@@ -728,13 +699,13 @@ public class DevilsDevastation extends MeleeWeapon {
|
|||||||
CompoundTag customData = projectile.getEntityData().get(StaticProjectile.CUSTOM_DATA);
|
CompoundTag customData = projectile.getEntityData().get(StaticProjectile.CUSTOM_DATA);
|
||||||
if(projectile.getOwner() instanceof LivingEntity livingEntity) {
|
if(projectile.getOwner() instanceof LivingEntity livingEntity) {
|
||||||
if(customData.contains("validHit")) {
|
if(customData.contains("validHit")) {
|
||||||
MobEffectInstance effectInstance = new MobEffectInstance(ModEffects.KILL_MODE, getKillModeTime(), 0);
|
MobEffectInstance effectInstance = new MobEffectInstance(ModEffects.KILL_MODE, KILL_MODE_TIME.get(), 0);
|
||||||
livingEntity.addEffect(effectInstance);
|
livingEntity.addEffect(effectInstance);
|
||||||
|
|
||||||
MobEffectInstance effectInstance2 = livingEntity.getEffect(ModEffects.KILL_MODE_COOLDOWN);
|
MobEffectInstance effectInstance2 = livingEntity.getEffect(ModEffects.KILL_MODE_COOLDOWN);
|
||||||
if(effectInstance2 != null) livingEntity.removeEffect(effectInstance2.getEffect());
|
if(effectInstance2 != null) livingEntity.removeEffect(effectInstance2.getEffect());
|
||||||
}else {
|
}else {
|
||||||
MobEffectInstance effectInstance = new MobEffectInstance(ModEffects.KILL_MODE_COOLDOWN, getKillModeCooldownTime(), 0);
|
MobEffectInstance effectInstance = new MobEffectInstance(ModEffects.KILL_MODE_COOLDOWN, KILL_MODE_COOLDOWN_TIME.get(), 0);
|
||||||
livingEntity.addEffect(effectInstance);
|
livingEntity.addEffect(effectInstance);
|
||||||
|
|
||||||
MobEffectInstance effectInstance2 = livingEntity.getEffect(ModEffects.KILL_MODE);
|
MobEffectInstance effectInstance2 = livingEntity.getEffect(ModEffects.KILL_MODE);
|
||||||
@@ -833,7 +804,7 @@ public class DevilsDevastation extends MeleeWeapon {
|
|||||||
UUID uuid = customData.getUUID("uuid");
|
UUID uuid = customData.getUUID("uuid");
|
||||||
Entity entity = serverLevel.getEntity(uuid);
|
Entity entity = serverLevel.getEntity(uuid);
|
||||||
if(entity instanceof Player player) {
|
if(entity instanceof Player player) {
|
||||||
DamageUtil.meleeAttack(player, owner, summon.getEntityData().get(StaticSummon.STACK_SOURCE), (float) getMarkLightningDamage(), 1.0f);
|
DamageUtil.meleeAttack(player, owner, summon.getEntityData().get(StaticSummon.STACK_SOURCE), (float) MARK_LIGHTNING_DAMAGE.get(), 1.0f);
|
||||||
StaticSummon newSummon = new StaticSummon(ModEntities.STATIC_SUMMON.get(), serverLevel);
|
StaticSummon newSummon = new StaticSummon(ModEntities.STATIC_SUMMON.get(), serverLevel);
|
||||||
newSummon.setOwner(player);
|
newSummon.setOwner(player);
|
||||||
newSummon.getEntityData().set(StaticSummon.STACK_SOURCE, summon.getEntityData().get(StaticSummon.STACK_SOURCE).copy());
|
newSummon.getEntityData().set(StaticSummon.STACK_SOURCE, summon.getEntityData().get(StaticSummon.STACK_SOURCE).copy());
|
||||||
@@ -888,9 +859,9 @@ public class DevilsDevastation extends MeleeWeapon {
|
|||||||
projectile.getEntityData().set(StaticProjectile.RIGHT, dirs[2]);
|
projectile.getEntityData().set(StaticProjectile.RIGHT, dirs[2]);
|
||||||
projectile.getEntityData().set(StaticProjectile.ITEM, new ItemStack(ModItems.DEVILS_DEVASTATION.get()));
|
projectile.getEntityData().set(StaticProjectile.ITEM, new ItemStack(ModItems.DEVILS_DEVASTATION.get()));
|
||||||
projectile.getEntityData().set(StaticProjectile.RZP, rotate);
|
projectile.getEntityData().set(StaticProjectile.RZP, rotate);
|
||||||
projectile.getEntityData().set(StaticProjectile.LIFETIME, getStuckProjectileLifetime());
|
projectile.getEntityData().set(StaticProjectile.LIFETIME, STUCK_PROJECTILE_LIFETIME.get());
|
||||||
projectile.getEntityData().set(StaticProjectile.GLOW, true);
|
projectile.getEntityData().set(StaticProjectile.GLOW, true);
|
||||||
projectile.getEntityData().set(StaticProjectile.EXPRESSION_Z, String.format("%.3f*t", getStuckProjectileSpeed()));
|
projectile.getEntityData().set(StaticProjectile.EXPRESSION_Z, String.format("%.3f*t", STUCK_PROJECTILE_SPEED.get()));
|
||||||
projectile.setDeltaMovement(MathUtil.toVec3(dirs[0]));
|
projectile.setDeltaMovement(MathUtil.toVec3(dirs[0]));
|
||||||
|
|
||||||
serverLevel.addFreshEntity(projectile);
|
serverLevel.addFreshEntity(projectile);
|
||||||
@@ -903,12 +874,12 @@ public class DevilsDevastation extends MeleeWeapon {
|
|||||||
ItemStack itemStack = player.getMainHandItem();
|
ItemStack itemStack = player.getMainHandItem();
|
||||||
if(!itemStack.is(ModItems.DEVILS_DEVASTATION.get())) return;
|
if(!itemStack.is(ModItems.DEVILS_DEVASTATION.get())) return;
|
||||||
if(player.getCooldowns().isOnCooldown(itemStack.getItem())) return;
|
if(player.getCooldowns().isOnCooldown(itemStack.getItem())) return;
|
||||||
player.getCooldowns().addCooldown(itemStack.getItem(), getKillModeProjectileCycle() + 5);
|
player.getCooldowns().addCooldown(itemStack.getItem(), KILL_MODE_PROJECTILE_CYCLE.get() + 5);
|
||||||
if(!player.level().isClientSide()) {
|
if(!player.level().isClientSide()) {
|
||||||
float radius = 4.0f;
|
float radius = 4.0f;
|
||||||
float w = (float) Math.PI * 1.5f / getKillModeProjectileCycle();
|
float w = (float) Math.PI * 1.5f / KILL_MODE_PROJECTILE_CYCLE.get();
|
||||||
if(player.getRandom().nextInt(2) == 0) w = -w;
|
if(player.getRandom().nextInt(2) == 0) w = -w;
|
||||||
int rotate = (int) ((Math.random() * 2 - 1) * getKillModeProjectileRotate());
|
int rotate = (int) ((Math.random() * 2 - 1) * KILL_MODE_PROJECTILE_ROTATE.get());
|
||||||
Vector3f[] dirs = MathUtil.computeCoordinateSystem(player);
|
Vector3f[] dirs = MathUtil.computeCoordinateSystem(player);
|
||||||
dirs = MathUtil.rotateCoordinateSystem(dirs[0], dirs[2], rotate);
|
dirs = MathUtil.rotateCoordinateSystem(dirs[0], dirs[2], rotate);
|
||||||
|
|
||||||
@@ -924,7 +895,7 @@ public class DevilsDevastation extends MeleeWeapon {
|
|||||||
projectile.getEntityData().set(StaticProjectile.UP, dirs[1]);
|
projectile.getEntityData().set(StaticProjectile.UP, dirs[1]);
|
||||||
projectile.getEntityData().set(StaticProjectile.RIGHT, dirs[2]);
|
projectile.getEntityData().set(StaticProjectile.RIGHT, dirs[2]);
|
||||||
projectile.getEntityData().set(StaticProjectile.ITEM, new ItemStack(ModItems.DEVILS_DEVASTATION.get()));
|
projectile.getEntityData().set(StaticProjectile.ITEM, new ItemStack(ModItems.DEVILS_DEVASTATION.get()));
|
||||||
projectile.getEntityData().set(StaticProjectile.LIFETIME, getKillModeProjectileCycle());
|
projectile.getEntityData().set(StaticProjectile.LIFETIME, KILL_MODE_PROJECTILE_CYCLE.get());
|
||||||
projectile.getEntityData().set(StaticProjectile.GLOW, true);
|
projectile.getEntityData().set(StaticProjectile.GLOW, true);
|
||||||
projectile.getEntityData().set(StaticProjectile.RZP, rotate);
|
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));
|
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));
|
||||||
@@ -1063,8 +1034,8 @@ public class DevilsDevastation extends MeleeWeapon {
|
|||||||
summonKilModeProjectile(player);
|
summonKilModeProjectile(player);
|
||||||
player.setData(ModAttachments.DEVILS_DEVASTATION_HIT_COUNT, player.getData(ModAttachments.DEVILS_DEVASTATION_HIT_COUNT) + 1);
|
player.setData(ModAttachments.DEVILS_DEVASTATION_HIT_COUNT, player.getData(ModAttachments.DEVILS_DEVASTATION_HIT_COUNT) + 1);
|
||||||
MobEffectInstance instance = player.getEffect(ModEffects.KILL_MODE);
|
MobEffectInstance instance = player.getEffect(ModEffects.KILL_MODE);
|
||||||
if(instance != null && instance.getDuration() < DevilsDevastation.getKillModeProjectileCycle()) {
|
if(instance != null && instance.getDuration() < DevilsDevastation.KILL_MODE_PROJECTILE_CYCLE.get()) {
|
||||||
MobEffectInstance effectInstance = new MobEffectInstance(ModEffects.KILL_MODE, DevilsDevastation.getKillModeProjectileCycle(), 0);
|
MobEffectInstance effectInstance = new MobEffectInstance(ModEffects.KILL_MODE, DevilsDevastation.KILL_MODE_PROJECTILE_CYCLE.get(), 0);
|
||||||
player.addEffect(effectInstance);
|
player.addEffect(effectInstance);
|
||||||
}
|
}
|
||||||
event.setCanceled(true);
|
event.setCanceled(true);
|
||||||
@@ -1096,9 +1067,9 @@ public class DevilsDevastation extends MeleeWeapon {
|
|||||||
projectile.getEntityData().set(StaticProjectile.SCALE_Z, 4.0f);
|
projectile.getEntityData().set(StaticProjectile.SCALE_Z, 4.0f);
|
||||||
projectile.getEntityData().set(StaticProjectile.RXP, -90);
|
projectile.getEntityData().set(StaticProjectile.RXP, -90);
|
||||||
projectile.getEntityData().set(StaticProjectile.RZP, -135);
|
projectile.getEntityData().set(StaticProjectile.RZP, -135);
|
||||||
projectile.getEntityData().set(StaticProjectile.LIFETIME, getProjectileLifetime());
|
projectile.getEntityData().set(StaticProjectile.LIFETIME, PROJECTILE_LIFETIME.get());
|
||||||
projectile.getEntityData().set(StaticProjectile.GLOW, true);
|
projectile.getEntityData().set(StaticProjectile.GLOW, true);
|
||||||
projectile.getEntityData().set(StaticProjectile.EXPRESSION_Z, String.format("%.3f*t", getProjectileSpeed()));
|
projectile.getEntityData().set(StaticProjectile.EXPRESSION_Z, String.format("%.3f*t", PROJECTILE_SPEED.get()));
|
||||||
projectile.setDeltaMovement(MathUtil.toVec3(dirs[0]));
|
projectile.setDeltaMovement(MathUtil.toVec3(dirs[0]));
|
||||||
level.addFreshEntity(projectile);
|
level.addFreshEntity(projectile);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,10 +9,12 @@ import com.lzxnone.terraria.entity.projectile.StaticProjectileBehaviors;
|
|||||||
import com.lzxnone.terraria.entity.projectile.StaticProjectile;
|
import com.lzxnone.terraria.entity.projectile.StaticProjectile;
|
||||||
import com.lzxnone.terraria.item.ModItems;
|
import com.lzxnone.terraria.item.ModItems;
|
||||||
import com.lzxnone.terraria.particle.ModParticles;
|
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.ConfigListItem;
|
||||||
import com.lzxnone.terraria.ui.config.ConfigUtil;
|
|
||||||
import com.lzxnone.terraria.ui.config.IConfigData;
|
import com.lzxnone.terraria.ui.config.IConfigData;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigDouble;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigFloat;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigInt;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigStruct;
|
||||||
import com.lzxnone.terraria.utils.*;
|
import com.lzxnone.terraria.utils.*;
|
||||||
import net.minecraft.core.component.DataComponents;
|
import net.minecraft.core.component.DataComponents;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
@@ -40,23 +42,27 @@ import net.minecraft.world.phys.Vec3;
|
|||||||
import org.joml.Vector3f;
|
import org.joml.Vector3f;
|
||||||
|
|
||||||
public class EnchantedSword extends MeleeWeapon {
|
public class EnchantedSword extends MeleeWeapon {
|
||||||
private static final String CONFIG_TRANSLATION_PREFIX = "lzxnoneterraria.configuration.";
|
public static final ConfigFloat DAMAGE = new ConfigFloat(
|
||||||
|
"weapon.enchanted_sword.damage",
|
||||||
public static final String DAMAGE_PATH = "weapon.enchanted_sword.damage";
|
"enchanted_sword_damage",
|
||||||
public static final float DAMAGE_DEFAULT = 4.0f;
|
4.0f,
|
||||||
public static final float DAMAGE_MIN = 0.0f;
|
0.0f,
|
||||||
public static final float DAMAGE_MAX = 8388600.0f;
|
8388600.0f
|
||||||
|
);
|
||||||
public static final String LIFETIME_PATH = "weapon.enchanted_sword.lifetime";
|
public static final ConfigInt LIFETIME = new ConfigInt(
|
||||||
public static final int LIFETIME_DEFAULT = 60;
|
"weapon.enchanted_sword.lifetime",
|
||||||
public static final int LIFETIME_MIN = 1;
|
"enchanted_sword_lifetime",
|
||||||
public static final int LIFETIME_MAX = 1200;
|
60,
|
||||||
|
1,
|
||||||
public static final String SPEED_PATH = "weapon.enchanted_sword.speed";
|
1200
|
||||||
public static final double SPEED_DEFAULT = 1.0;
|
);
|
||||||
public static final double SPEED_MIN = 0.0;
|
public static final ConfigDouble SPEED = new ConfigDouble(
|
||||||
public static final double SPEED_MAX = 10.0;
|
"weapon.enchanted_sword.speed",
|
||||||
|
"enchanted_sword_speed",
|
||||||
|
1.0,
|
||||||
|
0.0,
|
||||||
|
10.0
|
||||||
|
);
|
||||||
public EnchantedSword() {
|
public EnchantedSword() {
|
||||||
super(Tiers.IRON, new Item.Properties().attributes(ItemAttributeModifiers.builder()
|
super(Tiers.IRON, new Item.Properties().attributes(ItemAttributeModifiers.builder()
|
||||||
.add(Attributes.ATTACK_DAMAGE,
|
.add(Attributes.ATTACK_DAMAGE,
|
||||||
@@ -74,32 +80,14 @@ public class EnchantedSword extends MeleeWeapon {
|
|||||||
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
||||||
@Override
|
@Override
|
||||||
public void onConfigLoad() {
|
public void onConfigLoad() {
|
||||||
ConfigFactory.loadFloatConfig(DAMAGE_PATH, configText("enchanted_sword_damage"), configTooltip("enchanted_sword_damage"), DAMAGE_DEFAULT, DAMAGE_MIN, DAMAGE_MAX);
|
ConfigStruct.loadAll(
|
||||||
ConfigFactory.loadIntConfig(LIFETIME_PATH, configText("enchanted_sword_lifetime"), configTooltip("enchanted_sword_lifetime"), LIFETIME_DEFAULT, LIFETIME_MIN, LIFETIME_MAX);
|
DAMAGE,
|
||||||
ConfigFactory.loadDoubleConfig(SPEED_PATH, configText("enchanted_sword_speed"), configTooltip("enchanted_sword_speed"), SPEED_DEFAULT, SPEED_MIN, SPEED_MAX);
|
LIFETIME,
|
||||||
|
SPEED
|
||||||
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
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 float getDamage() {
|
|
||||||
return Math.clamp(ConfigUtil.readFloat(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(
|
public static final ConfigListItem CONFIG_LIST_ITEM = new ConfigListItem(
|
||||||
"enchanted_sword",
|
"enchanted_sword",
|
||||||
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/item/enchanted_sword.png"),
|
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/item/enchanted_sword.png"),
|
||||||
@@ -123,7 +111,7 @@ public class EnchantedSword extends MeleeWeapon {
|
|||||||
Entity owner = projectile.getOwner();
|
Entity owner = projectile.getOwner();
|
||||||
if(owner == null) return;
|
if(owner == null) return;
|
||||||
if(!FilterUtil.createTargetFilter(owner).test(target) || !(owner instanceof Player player)) return;
|
if(!FilterUtil.createTargetFilter(owner).test(target) || !(owner instanceof Player player)) return;
|
||||||
if(DamageUtil.meleeAttack(projectile, target, projectile.getEntityData().get(StaticProjectile.STACK_SOURCE),(float) getDamage(), 1.0f)) {
|
if(DamageUtil.meleeAttack(projectile, target, projectile.getEntityData().get(StaticProjectile.STACK_SOURCE),(float) DAMAGE.get(), 1.0f)) {
|
||||||
target.invulnerableTime = 5;
|
target.invulnerableTime = 5;
|
||||||
ParticleUtil.addParticles(
|
ParticleUtil.addParticles(
|
||||||
(ServerLevel) projectile.level(), ModParticles.COLORFUL_PARTICLE,
|
(ServerLevel) projectile.level(), ModParticles.COLORFUL_PARTICLE,
|
||||||
@@ -167,8 +155,8 @@ public class EnchantedSword extends MeleeWeapon {
|
|||||||
projectile.getEntityData().set(StaticProjectile.RZP, 45);
|
projectile.getEntityData().set(StaticProjectile.RZP, 45);
|
||||||
projectile.getEntityData().set(StaticProjectile.RYPS, 10);
|
projectile.getEntityData().set(StaticProjectile.RYPS, 10);
|
||||||
projectile.getEntityData().set(StaticProjectile.GLOW, true);
|
projectile.getEntityData().set(StaticProjectile.GLOW, true);
|
||||||
projectile.getEntityData().set(StaticProjectile.LIFETIME, getLifetime());
|
projectile.getEntityData().set(StaticProjectile.LIFETIME, LIFETIME.get());
|
||||||
projectile.getEntityData().set(StaticProjectile.EXPRESSION_Z, String.format("%.3f*t", getSpeed()));
|
projectile.getEntityData().set(StaticProjectile.EXPRESSION_Z, String.format("%.3f*t", SPEED.get()));
|
||||||
|
|
||||||
projectile.setDeltaMovement(MathUtil.toVec3(dirs[0]));
|
projectile.setDeltaMovement(MathUtil.toVec3(dirs[0]));
|
||||||
level.addFreshEntity(projectile);
|
level.addFreshEntity(projectile);
|
||||||
|
|||||||
@@ -34,59 +34,46 @@ import net.neoforged.neoforge.event.entity.player.AttackEntityEvent;
|
|||||||
import net.neoforged.neoforge.event.entity.player.PlayerInteractEvent;
|
import net.neoforged.neoforge.event.entity.player.PlayerInteractEvent;
|
||||||
import net.neoforged.neoforge.network.PacketDistributor;
|
import net.neoforged.neoforge.network.PacketDistributor;
|
||||||
import org.joml.Vector3f;
|
import org.joml.Vector3f;
|
||||||
import com.lzxnone.terraria.ui.config.ConfigFactory;
|
|
||||||
import com.lzxnone.terraria.ui.config.ConfigListItem;
|
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.ui.config.IConfigData;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigFloat;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigInt;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigStruct;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
|
|
||||||
public class Excalibur extends MeleeWeapon {
|
public class Excalibur extends MeleeWeapon {
|
||||||
private static final String CONFIG_TRANSLATION_PREFIX = "lzxnoneterraria.configuration.";
|
public static final ConfigInt ROTATE_RANGE = new ConfigInt(
|
||||||
|
"weapon.excalibur.rotate_range",
|
||||||
public static final String ROTATE_RANGE_PATH = "weapon.excalibur.rotate_range";
|
"excalibur_rotate_range",
|
||||||
public static final int ROTATE_RANGE_DEFAULT = 45;
|
45,
|
||||||
public static final int ROTATE_RANGE_MIN = 0;
|
0,
|
||||||
public static final int ROTATE_RANGE_MAX = 90;
|
90
|
||||||
|
);
|
||||||
public static final String MAX_HIT_COUNT_PATH = "weapon.excalibur.max_hit_count";
|
public static final ConfigInt MAX_HIT_COUNT = new ConfigInt(
|
||||||
public static final int MAX_HIT_COUNT_DEFAULT = 3;
|
"weapon.excalibur.max_hit_count",
|
||||||
public static final int MAX_HIT_COUNT_MIN = 0;
|
"excalibur_max_hit_count",
|
||||||
public static final int MAX_HIT_COUNT_MAX = 100;
|
3,
|
||||||
|
0,
|
||||||
public static final String DAMAGE_PATH = "weapon.excalibur.damage";
|
100
|
||||||
public static final float DAMAGE_DEFAULT = 8.0f;
|
);
|
||||||
public static final float DAMAGE_MIN = 0.0f;
|
public static final ConfigFloat DAMAGE = new ConfigFloat(
|
||||||
public static final float DAMAGE_MAX = 8388600.0f;
|
"weapon.excalibur.damage",
|
||||||
|
"excalibur_damage",
|
||||||
|
8.0f,
|
||||||
|
0.0f,
|
||||||
|
8388600.0f
|
||||||
|
);
|
||||||
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
||||||
@Override
|
@Override
|
||||||
public void onConfigLoad() {
|
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);
|
ConfigStruct.loadAll(
|
||||||
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);
|
ROTATE_RANGE,
|
||||||
ConfigFactory.loadFloatConfig(DAMAGE_PATH, configText("excalibur_damage"), configTooltip("excalibur_damage"), DAMAGE_DEFAULT, DAMAGE_MIN, DAMAGE_MAX);
|
MAX_HIT_COUNT,
|
||||||
|
DAMAGE
|
||||||
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
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 float getDamage() {
|
|
||||||
return Math.clamp(ConfigUtil.readFloat(DAMAGE_PATH, DAMAGE_DEFAULT), DAMAGE_MIN, DAMAGE_MAX);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final ConfigListItem CONFIG_LIST_ITEM = new ConfigListItem(
|
public static final ConfigListItem CONFIG_LIST_ITEM = new ConfigListItem(
|
||||||
"excalibur",
|
"excalibur",
|
||||||
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/item/excalibur.png"),
|
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/item/excalibur.png"),
|
||||||
@@ -151,8 +138,8 @@ public class Excalibur extends MeleeWeapon {
|
|||||||
CompoundTag custom_data = beam.getEntityData().get(SwordBeam.CUSTOM_DATA);
|
CompoundTag custom_data = beam.getEntityData().get(SwordBeam.CUSTOM_DATA);
|
||||||
if(custom_data.contains("hitEntityCount")) {
|
if(custom_data.contains("hitEntityCount")) {
|
||||||
int count = custom_data.getInt("hitEntityCount");
|
int count = custom_data.getInt("hitEntityCount");
|
||||||
if(count < getMaxHitCount()) {
|
if(count < MAX_HIT_COUNT.get()) {
|
||||||
if(DamageUtil.meleeAttack(beam, target, beam.getEntityData().get(SwordBeam.STACK_SOURCE), (float) getDamage(), 1.0f)) {
|
if(DamageUtil.meleeAttack(beam, target, beam.getEntityData().get(SwordBeam.STACK_SOURCE), (float) DAMAGE.get(), 1.0f)) {
|
||||||
target.invulnerableTime = 20;
|
target.invulnerableTime = 20;
|
||||||
count++;
|
count++;
|
||||||
custom_data.putInt("hitEntityCount", count);
|
custom_data.putInt("hitEntityCount", count);
|
||||||
@@ -171,7 +158,7 @@ public class Excalibur extends MeleeWeapon {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void generate(Entity entity, CompoundTag beamData) {
|
public void generate(Entity entity, CompoundTag beamData) {
|
||||||
beamData.putInt("rotate", (int) (getRotateRange() * (Math.random() * 2 - 1)));
|
beamData.putInt("rotate", (int) (ROTATE_RANGE.get() * (Math.random() * 2 - 1)));
|
||||||
ISwordBeamBehavior.super.generate(entity, beamData);
|
ISwordBeamBehavior.super.generate(entity, beamData);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -28,108 +28,99 @@ import net.minecraft.world.phys.AABB;
|
|||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
import org.joml.Vector3f;
|
import org.joml.Vector3f;
|
||||||
import org.jspecify.annotations.NonNull;
|
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.ConfigListItem;
|
||||||
import com.lzxnone.terraria.ui.config.ConfigUtil;
|
|
||||||
import com.lzxnone.terraria.ui.config.IConfigData;
|
import com.lzxnone.terraria.ui.config.IConfigData;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigBoolean;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigDouble;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigFloat;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigInt;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigStruct;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class FirstFractal extends MeleeWeapon {
|
public class FirstFractal extends MeleeWeapon {
|
||||||
private static final String CONFIG_TRANSLATION_PREFIX = "lzxnoneterraria.configuration.";
|
public static final ConfigFloat PROJECTILE_DAMAGE = new ConfigFloat(
|
||||||
|
"weapon.first_fractal.projectile_damage",
|
||||||
public static final String PROJECTILE_DAMAGE_PATH = "weapon.first_fractal.projectile_damage";
|
"first_fractal_projectile_damage",
|
||||||
public static final float PROJECTILE_DAMAGE_DEFAULT = 10.0f;
|
10.0f,
|
||||||
public static final float PROJECTILE_DAMAGE_MIN = 0.0f;
|
0.0f,
|
||||||
public static final float PROJECTILE_DAMAGE_MAX = 8388600.0f;
|
8388600.0f
|
||||||
|
);
|
||||||
public static final String BOUNDING_BOX_SIZE_PATH = "weapon.first_fractal.bounding_box_size";
|
public static final ConfigDouble BOUNDING_BOX_SIZE = new ConfigDouble(
|
||||||
public static final double BOUNDING_BOX_SIZE_DEFAULT = 1.5;
|
"weapon.first_fractal.bounding_box_size",
|
||||||
public static final double BOUNDING_BOX_SIZE_MIN = 0.5;
|
"first_fractal_bounding_box_size",
|
||||||
public static final double BOUNDING_BOX_SIZE_MAX = 10.0;
|
1.5,
|
||||||
|
0.5,
|
||||||
public static final String PROJECTILE_SPEED_PATH = "weapon.first_fractal.projectile_speed";
|
10.0
|
||||||
public static final double PROJECTILE_SPEED_DEFAULT = 1.5;
|
);
|
||||||
public static final double PROJECTILE_SPEED_MIN = 0.0;
|
public static final ConfigDouble PROJECTILE_SPEED = new ConfigDouble(
|
||||||
public static final double PROJECTILE_SPEED_MAX = 10.0;
|
"weapon.first_fractal.projectile_speed",
|
||||||
|
"first_fractal_projectile_speed",
|
||||||
public static final String PROJECTILE_LIFETIME_PATH = "weapon.first_fractal.projectile_lifetime";
|
1.5,
|
||||||
public static final int PROJECTILE_LIFETIME_DEFAULT = 30;
|
0.0,
|
||||||
public static final int PROJECTILE_LIFETIME_MIN = 1;
|
10.0
|
||||||
public static final int PROJECTILE_LIFETIME_MAX = 1200;
|
);
|
||||||
|
public static final ConfigInt PROJECTILE_LIFETIME = new ConfigInt(
|
||||||
public static final String DISTANCE_MODE_PATH = "weapon.first_fractal.distance_mode";
|
"weapon.first_fractal.projectile_lifetime",
|
||||||
public static final boolean DISTANCE_MODE_DEFAULT = true;
|
"first_fractal_projectile_lifetime",
|
||||||
|
30,
|
||||||
public static final String SCROLL_SPEED_PATH = "weapon.first_fractal.scroll_speed";
|
1,
|
||||||
public static final int SCROLL_SPEED_DEFAULT = 4;
|
1200
|
||||||
public static final int SCROLL_SPEED_MIN = 0;
|
);
|
||||||
public static final int SCROLL_SPEED_MAX = 128;
|
public static final ConfigBoolean DISTANCE_MODE = new ConfigBoolean(
|
||||||
|
"weapon.first_fractal.distance_mode",
|
||||||
public static final String MAX_RANGE_PATH = "weapon.first_fractal.max_range";
|
"first_fractal_distance_mode",
|
||||||
public static final double MAX_RANGE_DEFAULT = 64.0;
|
true
|
||||||
public static final double MAX_RANGE_MIN = 1.0;
|
);
|
||||||
public static final double MAX_RANGE_MAX = 1024.0;
|
public static final ConfigInt SCROLL_SPEED = new ConfigInt(
|
||||||
|
"weapon.first_fractal.scroll_speed",
|
||||||
public static final String SPAWN_RANGE_PATH = "weapon.first_fractal.spawn_range";
|
"first_fractal_scroll_speed",
|
||||||
public static final double SPAWN_RANGE_DEFAULT = 16.0;
|
4,
|
||||||
public static final double SPAWN_RANGE_MIN = 1.0;
|
0,
|
||||||
public static final double SPAWN_RANGE_MAX = 64.0;
|
128
|
||||||
|
);
|
||||||
|
public static final ConfigDouble MAX_RANGE = new ConfigDouble(
|
||||||
|
"weapon.first_fractal.max_range",
|
||||||
|
"first_fractal_max_range",
|
||||||
|
64.0,
|
||||||
|
1.0,
|
||||||
|
1024.0
|
||||||
|
);
|
||||||
|
public static final ConfigDouble SPAWN_RANGE = new ConfigDouble(
|
||||||
|
"weapon.first_fractal.spawn_range",
|
||||||
|
"first_fractal_spawn_range",
|
||||||
|
16.0,
|
||||||
|
1.0,
|
||||||
|
64.0
|
||||||
|
);
|
||||||
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
||||||
@Override
|
@Override
|
||||||
public void onConfigLoad() {
|
public void onConfigLoad() {
|
||||||
ConfigFactory.loadFloatConfig(PROJECTILE_DAMAGE_PATH, configText("first_fractal_projectile_damage"), configTooltip("first_fractal_projectile_damage"), PROJECTILE_DAMAGE_DEFAULT, PROJECTILE_DAMAGE_MIN, PROJECTILE_DAMAGE_MAX);
|
ConfigStruct.loadAll(
|
||||||
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);
|
PROJECTILE_DAMAGE,
|
||||||
ConfigFactory.loadDoubleConfig(PROJECTILE_SPEED_PATH, configText("first_fractal_projectile_speed"), configTooltip("first_fractal_projectile_speed"), PROJECTILE_SPEED_DEFAULT, PROJECTILE_SPEED_MIN, PROJECTILE_SPEED_MAX);
|
BOUNDING_BOX_SIZE,
|
||||||
ConfigFactory.loadIntConfig(PROJECTILE_LIFETIME_PATH, configText("first_fractal_projectile_lifetime"), configTooltip("first_fractal_projectile_lifetime"), PROJECTILE_LIFETIME_DEFAULT, PROJECTILE_LIFETIME_MIN, PROJECTILE_LIFETIME_MAX);
|
PROJECTILE_SPEED,
|
||||||
ConfigFactory.loadBooleanConfig(DISTANCE_MODE_PATH, configText("first_fractal_distance_mode"), configTooltip("first_fractal_distance_mode"), DISTANCE_MODE_DEFAULT);
|
PROJECTILE_LIFETIME,
|
||||||
ConfigFactory.loadIntConfig(SCROLL_SPEED_PATH, configText("first_fractal_scroll_speed"), configTooltip("first_fractal_scroll_speed"), SCROLL_SPEED_DEFAULT, SCROLL_SPEED_MIN, SCROLL_SPEED_MAX);
|
DISTANCE_MODE,
|
||||||
ConfigFactory.loadDoubleConfig(MAX_RANGE_PATH, configText("first_fractal_max_range"), configTooltip("first_fractal_max_range"), MAX_RANGE_DEFAULT, MAX_RANGE_MIN, MAX_RANGE_MAX);
|
SCROLL_SPEED,
|
||||||
ConfigFactory.loadDoubleConfig(SPAWN_RANGE_PATH, configText("first_fractal_spawn_range"), configTooltip("first_fractal_spawn_range"), SPAWN_RANGE_DEFAULT, SPAWN_RANGE_MIN, SPAWN_RANGE_MAX);
|
MAX_RANGE,
|
||||||
|
SPAWN_RANGE
|
||||||
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
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 float getProjectileDamage() {
|
|
||||||
return Math.clamp(ConfigUtil.readFloat(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() {
|
public static boolean isDistanceMode() {
|
||||||
return ConfigUtil.readBoolean(DISTANCE_MODE_PATH, DISTANCE_MODE_DEFAULT);
|
return DISTANCE_MODE.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getScrollSpeed() {
|
public static int getScrollSpeed() {
|
||||||
return Math.clamp(ConfigUtil.readInt(SCROLL_SPEED_PATH, SCROLL_SPEED_DEFAULT), SCROLL_SPEED_MIN, SCROLL_SPEED_MAX);
|
return SCROLL_SPEED.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double getMaxRange() {
|
public static double getMaxRange() {
|
||||||
return Math.clamp(ConfigUtil.readDouble(MAX_RANGE_PATH, MAX_RANGE_DEFAULT), MAX_RANGE_MIN, MAX_RANGE_MAX);
|
return MAX_RANGE.get();
|
||||||
}
|
|
||||||
|
|
||||||
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(
|
public static final ConfigListItem CONFIG_LIST_ITEM = new ConfigListItem(
|
||||||
@@ -194,11 +185,11 @@ public class FirstFractal extends MeleeWeapon {
|
|||||||
@Override
|
@Override
|
||||||
public void tick(StaticSummon summon) {
|
public void tick(StaticSummon summon) {
|
||||||
this.checkBeforeTick(summon);
|
this.checkBeforeTick(summon);
|
||||||
summon.setDeltaMovement(summon.getLookAngle().normalize().scale(getProjectileSpeed()));
|
summon.setDeltaMovement(summon.getLookAngle().normalize().scale(PROJECTILE_SPEED.get()));
|
||||||
|
|
||||||
summon.setBoundingBox(new AABB(
|
summon.setBoundingBox(new AABB(
|
||||||
summon.getX() - getBoundingBoxSize(), summon.getY() - getBoundingBoxSize(), summon.getZ() - getBoundingBoxSize(),
|
summon.getX() - BOUNDING_BOX_SIZE.get(), summon.getY() - BOUNDING_BOX_SIZE.get(), summon.getZ() - BOUNDING_BOX_SIZE.get(),
|
||||||
summon.getX() + getBoundingBoxSize(), summon.getY() + getBoundingBoxSize(), summon.getZ() + getBoundingBoxSize()
|
summon.getX() + BOUNDING_BOX_SIZE.get(), summon.getY() + BOUNDING_BOX_SIZE.get(), summon.getZ() + BOUNDING_BOX_SIZE.get()
|
||||||
));
|
));
|
||||||
|
|
||||||
if(!summon.level().isClientSide()) {
|
if(!summon.level().isClientSide()) {
|
||||||
@@ -209,7 +200,7 @@ public class FirstFractal extends MeleeWeapon {
|
|||||||
FilterUtil.createTargetFilter(summon, summon.getOwner())
|
FilterUtil.createTargetFilter(summon, summon.getOwner())
|
||||||
);
|
);
|
||||||
for(Entity target : targets) {
|
for(Entity target : targets) {
|
||||||
if(DamageUtil.meleeAttack(summon, target, summon.getEntityData().get(StaticSummon.STACK_SOURCE), (float) getProjectileDamage(), 0.2f)) {
|
if(DamageUtil.meleeAttack(summon, target, summon.getEntityData().get(StaticSummon.STACK_SOURCE), (float) PROJECTILE_DAMAGE.get(), 0.2f)) {
|
||||||
target.invulnerableTime = 10;
|
target.invulnerableTime = 10;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -223,7 +214,7 @@ public class FirstFractal extends MeleeWeapon {
|
|||||||
Vector3f[] dirs = MathUtil.computeCoordinateSystem(summon.getLookAngle().toVector3f(), 0);
|
Vector3f[] dirs = MathUtil.computeCoordinateSystem(summon.getLookAngle().toVector3f(), 0);
|
||||||
ZenithTrailParticleOptions options = new ZenithTrailParticleOptions(0.05f, 40, true, color, dirs[1], dirs[2], 90);
|
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 pos = MathUtil.toVec3(dirs[1]).scale(Math.random() * 2).add(summon.position());
|
||||||
Vec3 speed = MathUtil.toVec3(dirs[0]).scale(getProjectileSpeed());
|
Vec3 speed = MathUtil.toVec3(dirs[0]).scale(PROJECTILE_SPEED.get());
|
||||||
ParticleUtil.addParticle(
|
ParticleUtil.addParticle(
|
||||||
summon.level(), options,
|
summon.level(), options,
|
||||||
pos, 0,
|
pos, 0,
|
||||||
@@ -236,19 +227,19 @@ public class FirstFractal extends MeleeWeapon {
|
|||||||
public static void summon(Player player, double deltaDist) {
|
public static void summon(Player player, double deltaDist) {
|
||||||
if(!player.level().isClientSide()) {
|
if(!player.level().isClientSide()) {
|
||||||
Vec3 targetPos;
|
Vec3 targetPos;
|
||||||
if(isDistanceMode()) {
|
if(DISTANCE_MODE.get()) {
|
||||||
Vec3 origin = MathUtil.getCrosshairPos(player, player.level(), getMaxRange());
|
Vec3 origin = MathUtil.getCrosshairPos(player, player.level(), MAX_RANGE.get());
|
||||||
double dist = origin.subtract(player.getEyePosition()).length();
|
double dist = origin.subtract(player.getEyePosition()).length();
|
||||||
double maxScale = getMaxRange() - dist;
|
double maxScale = MAX_RANGE.get() - dist;
|
||||||
double minScale = -dist;
|
double minScale = -dist;
|
||||||
double scale = Math.min(deltaDist, maxScale);
|
double scale = Math.min(deltaDist, maxScale);
|
||||||
if(deltaDist < minScale) scale = -minScale;
|
if(deltaDist < minScale) scale = -minScale;
|
||||||
targetPos = origin.add(player.getLookAngle().normalize().scale(scale));
|
targetPos = origin.add(player.getLookAngle().normalize().scale(scale));
|
||||||
}else {
|
}else {
|
||||||
targetPos = player.getEyePosition().add(player.getLookAngle().normalize().scale(Math.min(deltaDist, getMaxRange())));
|
targetPos = player.getEyePosition().add(player.getLookAngle().normalize().scale(Math.min(deltaDist, MAX_RANGE.get())));
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec3 summonPos = MathUtil.getRandomPosInRadius(targetPos, getSpawnRange());
|
Vec3 summonPos = MathUtil.getRandomPosInRadius(targetPos, SPAWN_RANGE.get());
|
||||||
Vector3f color = COLORS[player.getRandom().nextInt(COLORS.length)];
|
Vector3f color = COLORS[player.getRandom().nextInt(COLORS.length)];
|
||||||
|
|
||||||
StaticSummon summon = new StaticSummon(ModEntities.STATIC_SUMMON.get(), player.level());
|
StaticSummon summon = new StaticSummon(ModEntities.STATIC_SUMMON.get(), player.level());
|
||||||
@@ -262,7 +253,7 @@ public class FirstFractal extends MeleeWeapon {
|
|||||||
summon.getEntityData().set(StaticSummon.COLOR_G, color.y);
|
summon.getEntityData().set(StaticSummon.COLOR_G, color.y);
|
||||||
summon.getEntityData().set(StaticSummon.COLOR_B, color.z);
|
summon.getEntityData().set(StaticSummon.COLOR_B, color.z);
|
||||||
summon.getEntityData().set(StaticSummon.GLOW, true);
|
summon.getEntityData().set(StaticSummon.GLOW, true);
|
||||||
summon.getEntityData().set(StaticSummon.LIFETIME, getProjectileLifetime());
|
summon.getEntityData().set(StaticSummon.LIFETIME, PROJECTILE_LIFETIME.get());
|
||||||
|
|
||||||
Vector3f[] dirs = MathUtil.computeCoordinateSystem(targetPos.subtract(summonPos).toVector3f(), 0);
|
Vector3f[] dirs = MathUtil.computeCoordinateSystem(targetPos.subtract(summonPos).toVector3f(), 0);
|
||||||
float[] xyRot = MathUtil.computeXYRot(dirs[0], dirs[1]);
|
float[] xyRot = MathUtil.computeXYRot(dirs[0], dirs[1]);
|
||||||
|
|||||||
@@ -35,10 +35,12 @@ import net.minecraft.world.level.block.Blocks;
|
|||||||
import net.minecraft.world.phys.*;
|
import net.minecraft.world.phys.*;
|
||||||
import net.objecthunter.exp4j.ExpressionBuilder;
|
import net.objecthunter.exp4j.ExpressionBuilder;
|
||||||
import org.joml.Vector3f;
|
import org.joml.Vector3f;
|
||||||
import com.lzxnone.terraria.ui.config.ConfigFactory;
|
|
||||||
import com.lzxnone.terraria.ui.config.ConfigListItem;
|
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.ui.config.IConfigData;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigDouble;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigFloat;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigInt;
|
||||||
|
import com.lzxnone.terraria.ui.config.struct.ConfigStruct;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
@@ -46,72 +48,54 @@ import java.util.List;
|
|||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
public class InfluxWaver extends MeleeWeapon {
|
public class InfluxWaver extends MeleeWeapon {
|
||||||
private static final String CONFIG_TRANSLATION_PREFIX = "lzxnoneterraria.configuration.";
|
public static final ConfigFloat DAMAGE = new ConfigFloat(
|
||||||
|
"weapon.influx_waver.damage",
|
||||||
public static final String DAMAGE_PATH = "weapon.influx_waver.damage";
|
"influx_waver_damage",
|
||||||
public static final float DAMAGE_DEFAULT = 12.0f;
|
12.0f,
|
||||||
public static final float DAMAGE_MIN = 0.0f;
|
0.0f,
|
||||||
public static final float DAMAGE_MAX = 8388600.0f;
|
8388600.0f
|
||||||
|
);
|
||||||
public static final String MAX_COUNT_PATH = "weapon.influx_waver.max_count";
|
public static final ConfigInt MAX_COUNT = new ConfigInt(
|
||||||
public static final int MAX_COUNT_DEFAULT = 2;
|
"weapon.influx_waver.max_count",
|
||||||
public static final int MAX_COUNT_MIN = 0;
|
"influx_waver_max_count",
|
||||||
public static final int MAX_COUNT_MAX = 10;
|
2,
|
||||||
|
0,
|
||||||
public static final String SPEED_PATH = "weapon.influx_waver.speed";
|
10
|
||||||
public static final double SPEED_DEFAULT = 1.0;
|
);
|
||||||
public static final double SPEED_MIN = 0.0;
|
public static final ConfigDouble SPEED = new ConfigDouble(
|
||||||
public static final double SPEED_MAX = 10.0;
|
"weapon.influx_waver.speed",
|
||||||
|
"influx_waver_speed",
|
||||||
public static final String SPAWN_RANGE_PATH = "weapon.influx_waver.spawn_range";
|
1.0,
|
||||||
public static final double SPAWN_RANGE_DEFAULT = 8.0;
|
0.0,
|
||||||
public static final double SPAWN_RANGE_MIN = 1.0;
|
10.0
|
||||||
public static final double SPAWN_RANGE_MAX = 64.0;
|
);
|
||||||
|
public static final ConfigDouble SPAWN_RANGE = new ConfigDouble(
|
||||||
public static final String TARGET_RANGE_PATH = "weapon.influx_waver.target_range";
|
"weapon.influx_waver.spawn_range",
|
||||||
public static final double TARGET_RANGE_DEFAULT = 24.0;
|
"influx_waver_spawn_range",
|
||||||
public static final double TARGET_RANGE_MIN = 1.0;
|
8.0,
|
||||||
public static final double TARGET_RANGE_MAX = 64.0;
|
1.0,
|
||||||
|
64.0
|
||||||
|
);
|
||||||
|
public static final ConfigDouble TARGET_RANGE = new ConfigDouble(
|
||||||
|
"weapon.influx_waver.target_range",
|
||||||
|
"influx_waver_target_range",
|
||||||
|
24.0,
|
||||||
|
1.0,
|
||||||
|
64.0
|
||||||
|
);
|
||||||
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
public static final IConfigData CONFIG_DATA = new IConfigData() {
|
||||||
@Override
|
@Override
|
||||||
public void onConfigLoad() {
|
public void onConfigLoad() {
|
||||||
ConfigFactory.loadFloatConfig(DAMAGE_PATH, configText("influx_waver_damage"), configTooltip("influx_waver_damage"), DAMAGE_DEFAULT, DAMAGE_MIN, DAMAGE_MAX);
|
ConfigStruct.loadAll(
|
||||||
ConfigFactory.loadIntConfig(MAX_COUNT_PATH, configText("influx_waver_max_count"), configTooltip("influx_waver_max_count"), MAX_COUNT_DEFAULT, MAX_COUNT_MIN, MAX_COUNT_MAX);
|
DAMAGE,
|
||||||
ConfigFactory.loadDoubleConfig(SPEED_PATH, configText("influx_waver_speed"), configTooltip("influx_waver_speed"), SPEED_DEFAULT, SPEED_MIN, SPEED_MAX);
|
MAX_COUNT,
|
||||||
ConfigFactory.loadDoubleConfig(SPAWN_RANGE_PATH, configText("influx_waver_spawn_range"), configTooltip("influx_waver_spawn_range"), SPAWN_RANGE_DEFAULT, SPAWN_RANGE_MIN, SPAWN_RANGE_MAX);
|
SPEED,
|
||||||
ConfigFactory.loadDoubleConfig(TARGET_RANGE_PATH, configText("influx_waver_target_range"), configTooltip("influx_waver_target_range"), TARGET_RANGE_DEFAULT, TARGET_RANGE_MIN, TARGET_RANGE_MAX);
|
SPAWN_RANGE,
|
||||||
|
TARGET_RANGE
|
||||||
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
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 float getDamage() {
|
|
||||||
return Math.clamp(ConfigUtil.readFloat(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(
|
public static final ConfigListItem CONFIG_LIST_ITEM = new ConfigListItem(
|
||||||
"influx_waver",
|
"influx_waver",
|
||||||
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/item/influx_waver.png"),
|
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/item/influx_waver.png"),
|
||||||
@@ -178,23 +162,23 @@ public class InfluxWaver extends MeleeWeapon {
|
|||||||
checkEntity = false;
|
checkEntity = false;
|
||||||
}else {
|
}else {
|
||||||
if(idx == 0) {
|
if(idx == 0) {
|
||||||
summon.setDeltaMovement(summon.getLookAngle().normalize().scale(getSpeed()));
|
summon.setDeltaMovement(summon.getLookAngle().normalize().scale(SPEED.get()));
|
||||||
}else {
|
}else {
|
||||||
checkBlock = false;
|
checkBlock = false;
|
||||||
if(customData.contains("target")) {
|
if(customData.contains("target")) {
|
||||||
Entity target = summon.level().getEntity(customData.getInt("target"));
|
Entity target = summon.level().getEntity(customData.getInt("target"));
|
||||||
if(target == null || !target.isAlive()) {
|
if(target == null || !target.isAlive()) {
|
||||||
//summon.setDeltaMovement(summon.getLookAngle().normalize().scale(getSpeed()));
|
//summon.setDeltaMovement(summon.getLookAngle().normalize().scale(SPEED.get()));
|
||||||
checkEntity = false;
|
checkEntity = false;
|
||||||
}else {
|
}else {
|
||||||
//Vec3 targetPos = new Vec3(target.getX(), target.getY() + target.getBbHeight() / 2, target.getZ());
|
//Vec3 targetPos = new Vec3(target.getX(), target.getY() + target.getBbHeight() / 2, target.getZ());
|
||||||
//summon.setDeltaMovement(targetPos.subtract(summon.position()).normalize().scale(getSpeed()));
|
//summon.setDeltaMovement(targetPos.subtract(summon.position()).normalize().scale(SPEED.get()));
|
||||||
}
|
}
|
||||||
}else {
|
}else {
|
||||||
//summon.setDeltaMovement(summon.getLookAngle().normalize().scale(getSpeed()));
|
//summon.setDeltaMovement(summon.getLookAngle().normalize().scale(SPEED.get()));
|
||||||
checkEntity = false;
|
checkEntity = false;
|
||||||
}
|
}
|
||||||
summon.setDeltaMovement(summon.getLookAngle().normalize().scale(getSpeed()));
|
summon.setDeltaMovement(summon.getLookAngle().normalize().scale(SPEED.get()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -224,7 +208,7 @@ public class InfluxWaver extends MeleeWeapon {
|
|||||||
Entity target = customData.contains("target") ? summon.level().getEntity(customData.getInt("target")) : null;
|
Entity target = customData.contains("target") ? summon.level().getEntity(customData.getInt("target")) : null;
|
||||||
if(target != null && !hitTarget.getUUID().equals(target.getUUID())) return;
|
if(target != null && !hitTarget.getUUID().equals(target.getUUID())) return;
|
||||||
if(summon.getOwner() instanceof Player player && FilterUtil.createTargetFilter(player).test(hitTarget)) {
|
if(summon.getOwner() instanceof Player player && FilterUtil.createTargetFilter(player).test(hitTarget)) {
|
||||||
if(DamageUtil.meleeAttack(summon, hitTarget, summon.getEntityData().get(StaticSummon.STACK_SOURCE), (float) getDamage(), 1.0f)) {
|
if(DamageUtil.meleeAttack(summon, hitTarget, summon.getEntityData().get(StaticSummon.STACK_SOURCE), (float) DAMAGE.get(), 1.0f)) {
|
||||||
hitTarget.invulnerableTime = 2;
|
hitTarget.invulnerableTime = 2;
|
||||||
}
|
}
|
||||||
customData.putBoolean("dead", false);
|
customData.putBoolean("dead", false);
|
||||||
@@ -240,12 +224,12 @@ public class InfluxWaver extends MeleeWeapon {
|
|||||||
public void onDied(StaticSummon summon) {
|
public void onDied(StaticSummon summon) {
|
||||||
if(!summon.level().isClientSide()) {
|
if(!summon.level().isClientSide()) {
|
||||||
CompoundTag customData = summon.getEntityData().get(StaticSummon.CUSTOM_DATA);
|
CompoundTag customData = summon.getEntityData().get(StaticSummon.CUSTOM_DATA);
|
||||||
if(customData.contains("dead") && !customData.getBoolean("dead") && customData.contains("idx") && customData.getInt("idx") < getMaxCount()) {
|
if(customData.contains("dead") && !customData.getBoolean("dead") && customData.contains("idx") && customData.getInt("idx") < MAX_COUNT.get()) {
|
||||||
if(summon.getOwner() instanceof Player player) {
|
if(summon.getOwner() instanceof Player player) {
|
||||||
Entity target = InfluxWaver.search(player, summon.position());
|
Entity target = InfluxWaver.search(player, summon.position());
|
||||||
if(target != null) {
|
if(target != null) {
|
||||||
Vec3 targetPos = new Vec3(target.getX(), target.getY() + target.getBbHeight() / 2, target.getZ());
|
Vec3 targetPos = new Vec3(target.getX(), target.getY() + target.getBbHeight() / 2, target.getZ());
|
||||||
Vec3 summonPos = MathUtil.getRandomPosOnRadius(targetPos, getSpawnRange());
|
Vec3 summonPos = MathUtil.getRandomPosOnRadius(targetPos, SPAWN_RANGE.get());
|
||||||
InfluxWaver.summon(player, summonPos, targetPos.subtract(summonPos).normalize(), target, customData.getInt("idx") + 1);
|
InfluxWaver.summon(player, summonPos, targetPos.subtract(summonPos).normalize(), target, customData.getInt("idx") + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -292,8 +276,8 @@ public class InfluxWaver extends MeleeWeapon {
|
|||||||
|
|
||||||
public static Entity search(Player player, Vec3 pos) {
|
public static Entity search(Player player, Vec3 pos) {
|
||||||
AABB searchBox = new AABB(
|
AABB searchBox = new AABB(
|
||||||
pos.x - getTargetRange(), pos.y - getTargetRange(), pos.z - getTargetRange(),
|
pos.x - TARGET_RANGE.get(), pos.y - TARGET_RANGE.get(), pos.z - TARGET_RANGE.get(),
|
||||||
pos.x + getTargetRange(), pos.y + getTargetRange(), pos.z + getTargetRange()
|
pos.x + TARGET_RANGE.get(), pos.y + TARGET_RANGE.get(), pos.z + TARGET_RANGE.get()
|
||||||
);
|
);
|
||||||
List<Entity> entities = CollisionUtil.searchEnemies(player.level(), searchBox, player, player);
|
List<Entity> entities = CollisionUtil.searchEnemies(player.level(), searchBox, player, player);
|
||||||
Entity target = null;
|
Entity target = null;
|
||||||
|
|||||||
Loaded 100 of 208 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user