This commit is contained in:
LZX committed 2026-07-25 01:18:36 +08:00
1 parent 9d48a65e35
commit fff35f2473
21 files changed
+76 -78

No files matched your search

@@ -0,0 +1,47 @@
package com.lzxnone.terraria.event;
import com.lzxnone.terraria.LzxnoneTerraria;
import com.lzxnone.terraria.attachment.ModAttachments;
import com.lzxnone.terraria.effect.ModEffects;
import com.lzxnone.terraria.item.ModItems;
import net.minecraft.Util;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Font;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.network.chat.Component;
import net.minecraft.world.item.ItemStack;
import net.neoforged.api.distmarker.Dist;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.common.EventBusSubscriber;
import net.neoforged.neoforge.client.event.RenderGuiEvent;
@EventBusSubscriber(modid = LzxnoneTerraria.MODID, value = Dist.CLIENT)
public class GuiRenderHandler {
@SubscribeEvent
public static void onRenderGui(RenderGuiEvent.Post event) {
Minecraft minecraft = Minecraft.getInstance();
LocalPlayer player = minecraft.player;
if(player == null || minecraft.options.hideGui) return;
ItemStack stack = player.getMainHandItem();
if(stack.is(ModItems.DEVILS_DEVASTATION.get()) && player.getEffect(ModEffects.KILL_MODE) != null) {
Component text = Component.translatable("effect.lzxnoneterraria.kill_mode");
Font font = minecraft.font;
String plainText = text.getString();
int yShift = Math.max(minecraft.gui.leftHeight, minecraft.gui.rightHeight) + (68 - 59);
int actionbarY = event.getGuiGraphics().guiHeight() - Math.max(yShift, 68);
int x = (event.getGuiGraphics().guiWidth() - font.width(plainText)) / 2;
int y = actionbarY + 8;
long shakeTime = Util.getMillis() % 1500L;
if(shakeTime < 500L) {
float progress = shakeTime / 500.0F;
float strength = 1.0F - progress;
x += Math.round(Math.sin(shakeTime * 0.12D) * 4.0D * strength);
y += Math.round(Math.sin(shakeTime * 0.27D) * 2.0D * strength);
}
event.getGuiGraphics().drawString(font, text, x, y, 0xB373F4, true);
}
}
}
@@ -123,7 +123,7 @@ public class DevilsDevastation extends SwordItem {
public static final String KILL_MODE_PROJECTILE_ROTATE_PATH = "weapon.devils_devastation.kill_mode_projectile_rotate";
public static final int KILL_MODE_PROJECTILE_ROTATE_DEFAULT = 30;
public static final int KILL_MODE_PROJECTILE_ROTATE_MIN = 0;
public static final int KILL_MODE_PROJECTILE_ROTATE_MAX = 360;
public static final int KILL_MODE_PROJECTILE_ROTATE_MAX = 90;
public static final String STUCK_LIFETIME_PATH = "weapon.devils_devastation.stuck_lifetime";
public static final int STUCK_LIFETIME_DEFAULT = 200;
@@ -881,7 +881,7 @@ public class DevilsDevastation extends SwordItem {
CompoundTag customData = projectile.getEntityData().get(StaticProjectile.CUSTOM_DATA);
if(customData.contains("hit") && !customData.getBoolean("hit")) {
float pitch = Math.min(1.0f + (player.getData(ModAttachments.DEVILS_DEVASTATION_HIT_COUNT) - 1) * 0.02f, 1.2f);
float pitch = Math.min(1.0f + (player.getData(ModAttachments.DEVILS_DEVASTATION_HIT_COUNT) - 1) * 0.025f, 1.25f);
if(projectile.getRandom().nextInt(1) == 0) SoundUtil.playServerSound(projectile.level(), ModSounds.DEMON_SWORD_INSANE_IMPACT.get(), target.position(), 16.0f, pitch);
else SoundUtil.playServerSound(projectile.level(), ModSounds.DEMON_SWORD_STRONG_IMPACT.get(), target.position(), 16.0f, pitch);
customData.putBoolean("hit", true);
@@ -921,7 +921,7 @@ public class DevilsDevastation extends SwordItem {
@Override
public void onDied(StaticProjectile projectile) {
if(projectile.level() instanceof ServerLevel serverLevel) {
if(projectile.level() instanceof ServerLevel) {
CompoundTag customData = projectile.getEntityData().get(StaticProjectile.CUSTOM_DATA);
if(projectile.getOwner() instanceof LivingEntity livingEntity) {
if(customData.contains("validHit")) {
@@ -936,19 +936,6 @@ public class DevilsDevastation extends SwordItem {
MobEffectInstance effectInstance2 = livingEntity.getEffect(ModEffects.KILL_MODE);
if(effectInstance2 != null) livingEntity.removeEffect(effectInstance2.getEffect());
/*Optional<UUID> markUUID = livingEntity.getData(ModAttachments.DEVILS_DEVASTATION_MARK);
if(markUUID.isPresent()) {
UUID uuid = markUUID.get();
Entity entityMark = serverLevel.getEntity(uuid);
if(entityMark instanceof StaticSummon summon && summon.isAlive()) {
CompoundTag markData = summon.getEntityData().get(StaticSummon.CUSTOM_DATA);
markData.putBoolean("dead", true);
summon.getEntityData().set(StaticSummon.CUSTOM_DATA, markData);
summon.getEntityData().set(StaticSummon.AGE, summon.getEntityData().get(StaticSummon.LIFETIME) - 20);
SoundUtil.playServerSound(summon.level(), ModSounds.DEMON_SWORD_FINAL_STRIKE.get(), summon.position(),16.0f, 1.0f);
}
}*/
}
}
projectile.discard();
@@ -1112,28 +1099,6 @@ public class DevilsDevastation extends SwordItem {
}
}
}
/*if(summon.level() instanceof ServerLevel serverLevel) {
CompoundTag customData = summon.getEntityData().get(StaticSummon.CUSTOM_DATA);
boolean toDie = true;
if(customData.contains("uuid")) {
Entity owenrEntity = serverLevel.getEntity(customData.getUUID("uuid"));
if(owenrEntity instanceof Player player) {
MobEffectInstance effectInstance = player.getEffect(ModEffects.KILL_MODE);
if(effectInstance != null) toDie = false;
}
}
if(toDie) {
if(!customData.contains("dead")) {
customData.putBoolean("dead", true);
summon.getEntityData().set(StaticSummon.CUSTOM_DATA, customData);
SoundUtil.playServerSound(summon.level(), ModSounds.DEMON_SWORD_FINAL_STRIKE.get(), summon.position(),16.0f, 1.0f);
summon.getEntityData().set(StaticSummon.AGE, 50);
}
}else {
summon.getEntityData().set(StaticSummon.AGE, 100);
}
}*/
}
@Override
@@ -1316,14 +1281,10 @@ public class DevilsDevastation extends SwordItem {
}
public static void enterIntoKillMode(Player player) {
if(!player.level().isClientSide()) {
player.setData(ModAttachments.DEVILS_DEVASTATION_HIT_COUNT, 0);
return;
}
if(!player.level().isClientSide()) return;
SoundUtil.playClientSound(player, ModSounds.DEMON_SWORD_KILL_MODE.get());
Vec3 pos = player.getBoundingBox().getCenter();
Vector3f color = new Vector3f(0.8f, 0.176f, 0.78f);
int count = 24;
@@ -303,6 +303,12 @@ public class Meowmere extends SwordItem {
summon.setDeltaMovement(motion);
}
@Override
public AABB getBoundingBoxForCulling(StaticSummon summon) {
if(summon.trailPositions.isEmpty()) return summon.getBoundingBox();
return new AABB(summon.position(), summon.trailPositions.getLast());
}
@Override
public void onDied(StaticSummon summon) {
if(!summon.level().isClientSide()) {
@@ -1,5 +1,6 @@
package com.lzxnone.terraria.network.handler;
import com.lzxnone.terraria.attachment.ModAttachments;
import com.lzxnone.terraria.effect.ModEffects;
import com.lzxnone.terraria.item.ModItems;
import com.lzxnone.terraria.item.weapon.melee.DevilsDevastation;
@@ -23,6 +24,7 @@ public class DevilsDevastationKillModeHandler {
if(instance == null && instance2 == null) {
MobEffectInstance effectInstance = new MobEffectInstance(ModEffects.KILL_MODE, DevilsDevastation.getKillModeTime(), 0);
player.addEffect(effectInstance);
player.setData(ModAttachments.DEVILS_DEVASTATION_HIT_COUNT, 0);
}
}
});
@@ -46,7 +46,7 @@ public class BloodButcheredParticle extends TextureSheetParticle {
@Override
public ParticleRenderType getRenderType() {
return ModParticleRenderTypes.TRANSLUCENT_EMISSIVE;
return ParticleRenderType.PARTICLE_SHEET_OPAQUE;
}
public static class Provider implements ParticleProvider<SimpleParticleType> {
@@ -7,7 +7,7 @@ import net.minecraft.client.particle.*;
import net.minecraft.client.renderer.LightTexture;
import org.joml.Vector3f;
public class DustParticle extends TextureSheetParticle {
public class DustParticle extends EmissiveBloomParticle {
private final SpriteSet sprites;
private final float rotSpeed;
@@ -102,7 +102,7 @@ public class DustParticle extends TextureSheetParticle {
@Override
public ParticleRenderType getRenderType() {
return ModParticleRenderTypes.TRANSLUCENT_EMISSIVE;
return ModParticleRenderTypes.EMISSIVE_BLOOM;
}
public static class Provider implements ParticleProvider<DustParticleOptions> {
@@ -50,7 +50,7 @@ public class ExcaliburHitParticle extends TextureSheetParticle {
@Override
public ParticleRenderType getRenderType() {
return ModParticleRenderTypes.TRANSLUCENT_EMISSIVE;
return ParticleRenderType.PARTICLE_SHEET_OPAQUE;
}
public static class Provider implements ParticleProvider<SimpleParticleType> {
@@ -46,7 +46,7 @@ public class ExplodeParticle extends TextureSheetParticle {
@Override
public ParticleRenderType getRenderType() {
return ModParticleRenderTypes.TRANSLUCENT_EMISSIVE;
return ParticleRenderType.PARTICLE_SHEET_OPAQUE;
}
public static class Provider implements ParticleProvider<SimpleParticleType> {
@@ -132,7 +132,7 @@ public class InfluxWaverDropParticle extends TextureSheetParticle {
@Override
public ParticleRenderType getRenderType() {
return ModParticleRenderTypes.TRANSLUCENT_EMISSIVE;
return ParticleRenderType.PARTICLE_SHEET_OPAQUE;
}
public static class Provider implements ParticleProvider<SimpleParticleType> {
@@ -46,7 +46,7 @@ public class LeafParticle extends TextureSheetParticle {
@Override
public ParticleRenderType getRenderType() {
return ModParticleRenderTypes.TRANSLUCENT_EMISSIVE;
return ParticleRenderType.PARTICLE_SHEET_OPAQUE;
}
public static class Provider implements ParticleProvider<SimpleParticleType> {
@@ -13,25 +13,6 @@ import net.minecraft.client.renderer.texture.TextureAtlas;
import net.minecraft.client.renderer.texture.TextureManager;
public final class ModParticleRenderTypes {
public static final ParticleRenderType TRANSLUCENT_EMISSIVE = new ParticleRenderType() {
@Override
public BufferBuilder begin(Tesselator tesselator, TextureManager textureManager) {
Minecraft.getInstance().gameRenderer.lightTexture().turnOnLightLayer();
return ParticleRenderType.PARTICLE_SHEET_TRANSLUCENT.begin(tesselator, textureManager);
}
@Override
public String toString() {
return "lzxnoneterraria:translucent_emissive";
}
@Override
public boolean isTranslucent() {
return true;
}
};
public static final ParticleRenderType EMISSIVE_BLOOM = new ParticleRenderType() {
@Override
public BufferBuilder begin(Tesselator tesselator, TextureManager textureManager) {
@@ -54,7 +54,7 @@ public class NightsEdgeHitParticle extends TextureSheetParticle {
@Override
public ParticleRenderType getRenderType() {
return ModParticleRenderTypes.TRANSLUCENT_EMISSIVE;
return ParticleRenderType.PARTICLE_SHEET_OPAQUE;
}
public static class Provider implements ParticleProvider<SimpleParticleType> {
@@ -42,7 +42,7 @@ public class SeedlerThornParticle extends TextureSheetParticle {
@Override
public ParticleRenderType getRenderType() {
return ModParticleRenderTypes.TRANSLUCENT_EMISSIVE;
return ParticleRenderType.PARTICLE_SHEET_OPAQUE;
}
public static class Provider implements ParticleProvider<SimpleParticleType> {
@@ -48,7 +48,7 @@ public class SolarExplosionParticle extends TextureSheetParticle {
@Override
public ParticleRenderType getRenderType() {
return ModParticleRenderTypes.TRANSLUCENT_EMISSIVE;
return ParticleRenderType.PARTICLE_SHEET_OPAQUE;
}
public static class Provider implements ParticleProvider<SimpleParticleType> {
@@ -58,7 +58,7 @@ public class StarParticle extends TextureSheetParticle {
@Override
public ParticleRenderType getRenderType() {
return ModParticleRenderTypes.TRANSLUCENT_EMISSIVE;
return ParticleRenderType.PARTICLE_SHEET_OPAQUE;
}
public static class Provider implements ParticleProvider<SimpleParticleType> {
@@ -79,7 +79,7 @@ public class TerraBeamHitParticle extends TextureSheetParticle {
@Override
public ParticleRenderType getRenderType() {
return ModParticleRenderTypes.TRANSLUCENT_EMISSIVE;
return ParticleRenderType.PARTICLE_SHEET_OPAQUE;
}
public static class Provider implements ParticleProvider<SimpleParticleType> {
@@ -54,7 +54,7 @@ public class TrueExcaliburHitParticle extends TextureSheetParticle {
@Override
public ParticleRenderType getRenderType() {
return ModParticleRenderTypes.TRANSLUCENT_EMISSIVE;
return ParticleRenderType.PARTICLE_SHEET_OPAQUE;
}
public static class Provider implements ParticleProvider<SimpleParticleType> {
@@ -54,7 +54,7 @@ public class TrueNightsEdgeHitParticle extends TextureSheetParticle {
@Override
public ParticleRenderType getRenderType() {
return ModParticleRenderTypes.TRANSLUCENT_EMISSIVE;
return ParticleRenderType.PARTICLE_SHEET_OPAQUE;
}
public static class Provider implements ParticleProvider<SimpleParticleType> {
@@ -143,7 +143,7 @@ public class ZenithTrailParticle extends TextureSheetParticle {
@Override
public ParticleRenderType getRenderType() {
return ModParticleRenderTypes.TRANSLUCENT_EMISSIVE;
return ParticleRenderType.PARTICLE_SHEET_OPAQUE;
}
public static class Provider implements ParticleProvider<ZenithTrailParticleOptions> {