v1.7.4
No files matched your search
@@ -31,6 +31,10 @@ public class ModSounds {
|
||||
SOUND_EVENTS.register("magic_shoot",
|
||||
() -> SoundEvent.createVariableRangeEvent(
|
||||
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "magic_shoot")));
|
||||
public static final Supplier<SoundEvent> MAGIC_SHOOT2 =
|
||||
SOUND_EVENTS.register("magic_shoot2",
|
||||
() -> SoundEvent.createVariableRangeEvent(
|
||||
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "magic_shoot2")));
|
||||
public static final Supplier<SoundEvent> BUBBLE =
|
||||
SOUND_EVENTS.register("bubble",
|
||||
() -> SoundEvent.createVariableRangeEvent(
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.lzxnone.terraria.client.item.ranged.ClientBulletAmmo;
|
||||
import com.lzxnone.terraria.client.item.magic.ClientBetsysWrath;
|
||||
import com.lzxnone.terraria.client.item.magic.ClientBubbleGun;
|
||||
import com.lzxnone.terraria.client.item.magic.ClientLastPrism;
|
||||
import com.lzxnone.terraria.client.item.magic.ClientNebulaBlaze;
|
||||
import com.lzxnone.terraria.client.item.melee.ClientDevilsDevastation;
|
||||
import com.lzxnone.terraria.client.item.melee.ClientFirstFractal;
|
||||
import com.lzxnone.terraria.client.item.melee.ClientLightsBane;
|
||||
@@ -57,6 +58,8 @@ public class ClientStaticSummonRenderBehaviors {
|
||||
BEHAVIORS.put(StaticSummonBehaviors.LAST_PRISM_TRI, ClientLastPrism.SUMMON_BEHAVIOR);
|
||||
BEHAVIORS.put(StaticSummonBehaviors.LAST_PRISM_BEAM, ClientLastPrism.SUMMON_BEHAVIOR2);
|
||||
BEHAVIORS.put(StaticSummonBehaviors.BETSY_WRATH, ClientBetsysWrath.SUMMON_BEHAVIOR);
|
||||
BEHAVIORS.put(StaticSummonBehaviors.NEBULA_BLAZE, ClientNebulaBlaze.SUMMON_BEHAVIOR);
|
||||
BEHAVIORS.put(StaticSummonBehaviors.NEBULA_BLAZE_EXPLOSIVE, ClientNebulaBlaze.SUMMON_BEHAVIOR);
|
||||
BEHAVIORS.put(StaticSummonBehaviors.TERRAPRISMA, ClientTerraprisma.SUMMON_BEHAVIOR);
|
||||
BEHAVIORS.put(StaticSummonBehaviors.POSSESSION, ClientWhip.SUMMON_BEHAVIOR);
|
||||
BEHAVIORS.put(StaticSummonBehaviors.POSSESSION_VISION, DEFAULT_BEHAVIOR);
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
package com.lzxnone.terraria.client.item.magic;
|
||||
|
||||
import com.lzxnone.terraria.client.entity.summon.IStaticSummonRenderBehavior;
|
||||
import com.lzxnone.terraria.entity.ModRenderTypes;
|
||||
import com.lzxnone.terraria.entity.summon.StaticSummon;
|
||||
import com.lzxnone.terraria.entity.summon.StaticSummonBehaviors;
|
||||
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.util.Mth;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
|
||||
public class ClientNebulaBlaze {
|
||||
private static final ResourceLocation[] RES = {
|
||||
ResourceLocation.parse("lzxnoneterraria:textures/vfx/nebula_blaze_projectile0.png"),
|
||||
ResourceLocation.parse("lzxnoneterraria:textures/vfx/nebula_blaze_projectile1.png"),
|
||||
ResourceLocation.parse("lzxnoneterraria:textures/vfx/nebula_blaze_projectile2.png"),
|
||||
ResourceLocation.parse("lzxnoneterraria:textures/vfx/nebula_blaze_projectile3.png")
|
||||
};
|
||||
private static final ResourceLocation[] EXPLOSIVE_RES = {
|
||||
ResourceLocation.parse("lzxnoneterraria:textures/vfx/nebula_blaze_ex_projectile0.png"),
|
||||
ResourceLocation.parse("lzxnoneterraria:textures/vfx/nebula_blaze_ex_projectile1.png"),
|
||||
ResourceLocation.parse("lzxnoneterraria:textures/vfx/nebula_blaze_ex_projectile2.png"),
|
||||
ResourceLocation.parse("lzxnoneterraria:textures/vfx/nebula_blaze_ex_projectile3.png")
|
||||
};
|
||||
|
||||
public static final IStaticSummonRenderBehavior SUMMON_BEHAVIOR = new IStaticSummonRenderBehavior() {
|
||||
@Override
|
||||
public void render(Entity entity, float entityYaw, float partialTick, PoseStack poseStack, MultiBufferSource bufferSource, int packedLight) {
|
||||
if(!(entity instanceof StaticSummon summon)) return;
|
||||
boolean explosive = summon.getEntityData().get(StaticSummon.BEHAVIOR).equals(StaticSummonBehaviors.NEBULA_BLAZE_EXPLOSIVE);
|
||||
ResourceLocation[] frames = explosive ? EXPLOSIVE_RES : RES;
|
||||
float age = summon.getEntityData().get(StaticSummon.AGE) + partialTick;
|
||||
int frame = Mth.floor(age * 0.625F) % frames.length;
|
||||
float halfSize = explosive ? 0.55F : 0.42F;
|
||||
|
||||
poseStack.pushPose();
|
||||
poseStack.mulPose(Minecraft.getInstance().getEntityRenderDispatcher().cameraOrientation());
|
||||
poseStack.mulPose(Axis.ZP.rotationDegrees(age * 18.0F));
|
||||
|
||||
poseStack.scale(
|
||||
summon.getEntityData().get(StaticSummon.SCALE_X),
|
||||
summon.getEntityData().get(StaticSummon.SCALE_Y),
|
||||
summon.getEntityData().get(StaticSummon.SCALE_Z)
|
||||
);
|
||||
|
||||
VertexConsumer consumer = bufferSource.getBuffer(ModRenderTypes.entityAdditiveEmissive(frames[frame]));
|
||||
consumer.addVertex(poseStack.last().pose(), -halfSize, -halfSize, 0.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);
|
||||
consumer.addVertex(poseStack.last().pose(), halfSize, -halfSize, 0.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);
|
||||
consumer.addVertex(poseStack.last().pose(), halfSize, halfSize, 0.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);
|
||||
consumer.addVertex(poseStack.last().pose(), -halfSize, halfSize, 0.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();
|
||||
}
|
||||
};
|
||||
|
||||
public static void renderHandProjectile(MultiBufferSource bufferSource, PoseStack poseStack, Entity entity) {
|
||||
float age = entity.tickCount + Minecraft.getInstance().getTimer().getGameTimeDeltaPartialTick(false);
|
||||
int frame = Mth.floor(age * 0.625F) % RES.length;
|
||||
float halfSize = 0.35F;
|
||||
|
||||
poseStack.pushPose();
|
||||
poseStack.translate(0.0F, 0.0F, 0.08F);
|
||||
poseStack.mulPose(Minecraft.getInstance().getEntityRenderDispatcher().cameraOrientation());
|
||||
poseStack.mulPose(Axis.ZP.rotationDegrees(age * 18.0F));
|
||||
|
||||
VertexConsumer consumer = bufferSource.getBuffer(ModRenderTypes.entityAdditiveEmissive(RES[frame]));
|
||||
consumer.addVertex(poseStack.last().pose(), -halfSize, -halfSize, 0.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);
|
||||
consumer.addVertex(poseStack.last().pose(), halfSize, -halfSize, 0.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);
|
||||
consumer.addVertex(poseStack.last().pose(), halfSize, halfSize, 0.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);
|
||||
consumer.addVertex(poseStack.last().pose(), -halfSize, halfSize, 0.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();
|
||||
}
|
||||
}
|
||||
@@ -41,7 +41,6 @@ import net.minecraft.world.phys.Vec3;
|
||||
import org.joml.Vector3f;
|
||||
|
||||
public class LunarFlare extends MagicWeapon {
|
||||
public static final double HITBOX_INFLATE = 0.75D;
|
||||
public static final double SPAWN_HEIGHT = 20.0D;
|
||||
public static final double DELTA_HEIGHT = 10.0D;
|
||||
public static final double SPAWN_OFFSET = 10.0D;
|
||||
@@ -115,7 +114,7 @@ public class LunarFlare extends MagicWeapon {
|
||||
return;
|
||||
}
|
||||
|
||||
EntityHitResult entityHitResult = CollisionUtil.checkEntityHit(summon, nextPos, HITBOX_INFLATE);
|
||||
EntityHitResult entityHitResult = CollisionUtil.checkEntityHit(summon, nextPos, 0.75);
|
||||
if(entityHitResult != null) {
|
||||
onDied(summon);
|
||||
return;
|
||||
|
||||
@@ -7,16 +7,14 @@ import com.lzxnone.terraria.entity.summon.IStaticSummonBehavior;
|
||||
import com.lzxnone.terraria.entity.summon.StaticSummon;
|
||||
import com.lzxnone.terraria.entity.summon.StaticSummonBehaviors;
|
||||
import com.lzxnone.terraria.item.weapon.MagicWeapon;
|
||||
import com.lzxnone.terraria.particle.CircleParticleOptions;
|
||||
import com.lzxnone.terraria.particle.DustParticleOptions;
|
||||
import com.lzxnone.terraria.ui.config.ConfigListItem;
|
||||
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.DamageUtil;
|
||||
import com.lzxnone.terraria.utils.FilterUtil;
|
||||
import com.lzxnone.terraria.utils.MathUtil;
|
||||
import com.lzxnone.terraria.utils.SearchUtil;
|
||||
import com.lzxnone.terraria.utils.*;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
@@ -30,6 +28,7 @@ import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Rarity;
|
||||
import net.minecraft.world.item.Tiers;
|
||||
import net.minecraft.world.level.ClipContext;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
@@ -40,8 +39,7 @@ import org.joml.Vector3f;
|
||||
import java.util.List;
|
||||
|
||||
public class NebulaBlaze extends MagicWeapon {
|
||||
public static final Vector3f OFFSET = new Vector3f(-0.25F, -0.1F, 1.2F);
|
||||
public static final double HITBOX_INFLATE = 0.35D;
|
||||
public static final Vector3f OFFSET = new Vector3f(-0.5F, -0.1F, 1.2F);
|
||||
public static final String TARGET_UUID_KEY = "target";
|
||||
|
||||
public static final ConfigFloat DAMAGE = new ConfigFloat("weapon.nebula_blaze.damage", "nebula_blaze_damage", 10.0F, 0.0F, 8388600.0F);
|
||||
@@ -78,16 +76,35 @@ public class NebulaBlaze extends MagicWeapon {
|
||||
CONFIG_DATA
|
||||
);
|
||||
|
||||
public static final CircleParticleOptions TRAIL_PARTICLE = new CircleParticleOptions(0.075F, 16, new Vector3f(1.0F, 0.18F, 0.72F));
|
||||
public static final CircleParticleOptions EXPLOSIVE_TRAIL_PARTICLE = new CircleParticleOptions(0.085F, 16, new Vector3f(0.24F, 0.7F, 1.0F));
|
||||
public static final DustParticleOptions DUST_PARTICLE = new DustParticleOptions(
|
||||
0.1F, 0.35F, 18, true,
|
||||
new Vector3f[] {new Vector3f(1.0F, 0.16F, 0.62F), new Vector3f(0.86F, 0.08F, 1.0F)}
|
||||
);
|
||||
public static final DustParticleOptions EXPLOSIVE_DUST_PARTICLE = new DustParticleOptions(
|
||||
0.15F, 0.35F, 18, true,
|
||||
new Vector3f[] {new Vector3f(0.12F, 0.86F, 1.0F), new Vector3f(0.22F, 0.25F, 1.0F)}
|
||||
);
|
||||
public static final DustParticleOptions DEATH_PARTICLE = new DustParticleOptions(
|
||||
0.15F, 0.45F, 32, true,
|
||||
new Vector3f[] {new Vector3f(1.0F, 0.12F, 0.58F), new Vector3f(0.95F, 0.04F, 1.0F)}
|
||||
);
|
||||
public static final DustParticleOptions EXPLOSIVE_DEATH_PARTICLE = new DustParticleOptions(
|
||||
0.3F, 0.5F, 36, true,
|
||||
new Vector3f[] {new Vector3f(0.0F, 0.95F, 1.0F), new Vector3f(0.2F, 0.35F, 1.0F)}
|
||||
);
|
||||
|
||||
public static final IStaticSummonBehavior SUMMON_BEHAVIOR = new IStaticSummonBehavior() {
|
||||
@Override
|
||||
public void tick(StaticSummon summon) {
|
||||
checkBeforeTick(summon);
|
||||
tickProjectile(summon, SPEED.get(), TARGET_RANGE.get(), DAMAGE.get());
|
||||
tickProjectile(summon, SPEED.get(), TARGET_RANGE.get(), DAMAGE.get(), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDied(StaticSummon summon) {
|
||||
explode(summon, DAMAGE.get());
|
||||
explode(summon, DAMAGE.get(), false);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -95,12 +112,12 @@ public class NebulaBlaze extends MagicWeapon {
|
||||
@Override
|
||||
public void tick(StaticSummon summon) {
|
||||
checkBeforeTick(summon);
|
||||
tickProjectile(summon, EXPLOSIVE_SPEED.get(), EXPLOSIVE_TARGET_RANGE.get(), EXPLOSIVE_DAMAGE.get());
|
||||
tickProjectile(summon, EXPLOSIVE_SPEED.get(), EXPLOSIVE_TARGET_RANGE.get(), EXPLOSIVE_DAMAGE.get(), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDied(StaticSummon summon) {
|
||||
explode(summon, EXPLOSIVE_DAMAGE.get());
|
||||
explode(summon, EXPLOSIVE_DAMAGE.get(), true);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -128,7 +145,7 @@ public class NebulaBlaze extends MagicWeapon {
|
||||
protected void shoot(Level level, Player player, InteractionHand hand, ItemStack stack) {
|
||||
if(level.isClientSide()) return;
|
||||
|
||||
player.playNotifySound(ModSounds.MAGIC_SHOOT.get(), SoundSource.PLAYERS, 4.0F, 1.0F);
|
||||
player.playNotifySound(ModSounds.MAGIC_SHOOT2.get(), SoundSource.PLAYERS, 4.0F, 1.0F);
|
||||
|
||||
Vector3f[] dirs = MathUtil.computeCoordinateSystem(player);
|
||||
Vector3f offset = new Vector3f(
|
||||
@@ -151,7 +168,17 @@ public class NebulaBlaze extends MagicWeapon {
|
||||
summon.setDeltaMovement(direction.scale(explosive ? EXPLOSIVE_SPEED.get() : SPEED.get()));
|
||||
summon.getEntityData().set(StaticSummon.STACK_SOURCE, stack.copy());
|
||||
summon.getEntityData().set(StaticSummon.BEHAVIOR, explosive ? StaticSummonBehaviors.NEBULA_BLAZE_EXPLOSIVE : StaticSummonBehaviors.NEBULA_BLAZE);
|
||||
summon.getEntityData().set(StaticSummon.RENDER_MODE, "custom");
|
||||
summon.getEntityData().set(StaticSummon.LIFETIME, 100);
|
||||
if(explosive) {
|
||||
summon.getEntityData().set(StaticSummon.SCALE_X, 2.0f);
|
||||
summon.getEntityData().set(StaticSummon.SCALE_Y, 2.0f);
|
||||
summon.getEntityData().set(StaticSummon.SCALE_Z, 2.0f);
|
||||
}else {
|
||||
summon.getEntityData().set(StaticSummon.SCALE_X, 1.5f);
|
||||
summon.getEntityData().set(StaticSummon.SCALE_Y, 1.5f);
|
||||
summon.getEntityData().set(StaticSummon.SCALE_Z, 1.5f);
|
||||
}
|
||||
summon.getEntityData().set(StaticSummon.GLOW, true);
|
||||
summon.setNoGravity(true);
|
||||
summon.noPhysics = true;
|
||||
@@ -164,7 +191,7 @@ public class NebulaBlaze extends MagicWeapon {
|
||||
level.addFreshEntity(summon);
|
||||
}
|
||||
|
||||
private static void tickProjectile(StaticSummon summon, double speed, double targetRange, float damage) {
|
||||
private static void tickProjectile(StaticSummon summon, double speed, double targetRange, float damage, boolean explosive) {
|
||||
Vec3 direction = summon.getDeltaMovement();
|
||||
if(direction.lengthSqr() < 1.0E-7D) direction = summon.getLookAngle();
|
||||
if(direction.lengthSqr() < 1.0E-7D) direction = new Vec3(0.0D, 0.0D, 1.0D);
|
||||
@@ -177,11 +204,36 @@ public class NebulaBlaze extends MagicWeapon {
|
||||
if(target == null || !target.isAlive()) {
|
||||
target = null;
|
||||
customData.remove(TARGET_UUID_KEY);
|
||||
}else if(serverLevel.clip(new ClipContext(
|
||||
summon.position(),
|
||||
target.getBoundingBox().getCenter(),
|
||||
ClipContext.Block.COLLIDER,
|
||||
ClipContext.Fluid.NONE,
|
||||
summon
|
||||
)).getType() != HitResult.Type.MISS) {
|
||||
target = null;
|
||||
customData.remove(TARGET_UUID_KEY);
|
||||
}
|
||||
}
|
||||
if(target == null) {
|
||||
List<Entity> targets = SearchUtil.searchNearestEnemies(summon, summon.getOwner(), summon.getBoundingBox().inflate(targetRange), 1);
|
||||
target = targets.isEmpty() ? null : targets.getFirst();
|
||||
List<Entity> targets = SearchUtil.searchEnemies(summon, summon.getOwner(), summon.getBoundingBox().inflate(targetRange));
|
||||
double bestDistance = Double.MAX_VALUE;
|
||||
for(Entity candidate : targets) {
|
||||
Vec3 targetCenter = candidate.getBoundingBox().getCenter();
|
||||
if(serverLevel.clip(new ClipContext(
|
||||
summon.position(),
|
||||
targetCenter,
|
||||
ClipContext.Block.COLLIDER,
|
||||
ClipContext.Fluid.NONE,
|
||||
summon
|
||||
)).getType() != HitResult.Type.MISS) continue;
|
||||
|
||||
double distance = targetCenter.distanceToSqr(summon.position());
|
||||
if(distance < bestDistance) {
|
||||
bestDistance = distance;
|
||||
target = candidate;
|
||||
}
|
||||
}
|
||||
if(target != null) customData.putUUID(TARGET_UUID_KEY, target.getUUID());
|
||||
}
|
||||
summon.getEntityData().set(StaticSummon.CUSTOM_DATA, customData);
|
||||
@@ -204,15 +256,16 @@ public class NebulaBlaze extends MagicWeapon {
|
||||
summon.yRotO = xyRot[1];
|
||||
|
||||
if(summon.level().isClientSide()) return;
|
||||
addTrailParticles(summon, direction, explosive);
|
||||
|
||||
AABB hitBox = new AABB(start, end).inflate(HITBOX_INFLATE);
|
||||
AABB hitBox = new AABB(start, end).inflate(0.35);
|
||||
List<Entity> hitTargets = summon.level().getEntitiesOfClass(
|
||||
Entity.class,
|
||||
hitBox,
|
||||
FilterUtil.createTargetFilter(summon, summon.getOwner())
|
||||
);
|
||||
if(!hitTargets.isEmpty()) {
|
||||
explode(summon, damage);
|
||||
explode(summon, damage, explosive);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -220,14 +273,23 @@ public class NebulaBlaze extends MagicWeapon {
|
||||
if(blockHitResult.getType() != HitResult.Type.MISS) {
|
||||
summon.setPos(blockHitResult.getLocation());
|
||||
summon.setDeltaMovement(Vec3.ZERO);
|
||||
explode(summon, damage);
|
||||
explode(summon, damage, explosive);
|
||||
}
|
||||
}
|
||||
|
||||
private static void explode(StaticSummon summon, float damage) {
|
||||
private static void explode(StaticSummon summon, float damage, boolean explosive) {
|
||||
if(!(summon.level() instanceof ServerLevel serverLevel)) return;
|
||||
|
||||
Vec3 pos = summon.position();
|
||||
ParticleUtil.addParticles(
|
||||
serverLevel,
|
||||
explosive ? EXPLOSIVE_DEATH_PARTICLE : DEATH_PARTICLE,
|
||||
pos,
|
||||
new Vec3(explosive ? 0.75D : 0.55D, explosive ? 0.75D : 0.55D, explosive ? 0.75D : 0.55D),
|
||||
0.03D,
|
||||
explosive ? 28 : 20
|
||||
);
|
||||
SoundUtil.playServerSound(summon.level(), ModSounds.BOOM.get(), summon.position());
|
||||
double explosionRange = EXPLOSION_RANGE.get();
|
||||
if(explosionRange > 0.0D) {
|
||||
ItemStack sourceStack = summon.getEntityData().get(StaticSummon.STACK_SOURCE);
|
||||
@@ -244,4 +306,38 @@ public class NebulaBlaze extends MagicWeapon {
|
||||
|
||||
summon.discard();
|
||||
}
|
||||
|
||||
private static void addTrailParticles(StaticSummon summon, Vec3 direction, boolean explosive) {
|
||||
if(!(summon.level() instanceof ServerLevel serverLevel)) return;
|
||||
|
||||
Vector3f[] dirs = MathUtil.computeCoordinateSystem(direction.toVector3f(), summon.getYRot());
|
||||
Vec3 up = MathUtil.toVec3(dirs[1]).normalize();
|
||||
Vec3 right = MathUtil.toVec3(dirs[2]).normalize();
|
||||
double phase = summon.getEntityData().get(StaticSummon.AGE) * 0.75D;
|
||||
double radius = explosive ? 0.5D : 0.35D;
|
||||
|
||||
for(int i = 0; i < 2; i++) {
|
||||
double angle = phase + Math.PI * i;
|
||||
Vec3 particlePos = summon.position()
|
||||
.add(up.scale(Math.cos(angle) * radius))
|
||||
.add(right.scale(Math.sin(angle) * radius));
|
||||
ParticleUtil.addParticles(
|
||||
serverLevel,
|
||||
explosive ? EXPLOSIVE_TRAIL_PARTICLE : TRAIL_PARTICLE,
|
||||
particlePos,
|
||||
Vec3.ZERO,
|
||||
0.0D,
|
||||
1
|
||||
);
|
||||
}
|
||||
|
||||
ParticleUtil.addParticles(
|
||||
serverLevel,
|
||||
explosive ? EXPLOSIVE_DUST_PARTICLE : DUST_PARTICLE,
|
||||
summon.position(),
|
||||
new Vec3(Math.random(), Math.random(), Math.random()),
|
||||
0.2D,
|
||||
1
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -80,8 +80,8 @@ public class Possession extends Whip {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getCooldown() {
|
||||
return 3;
|
||||
protected int getUseTime() {
|
||||
return 12;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -20,20 +20,20 @@ import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Tier;
|
||||
import net.minecraft.world.item.UseAnim;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.joml.Vector3f;
|
||||
import org.jspecify.annotations.NonNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class Whip extends SummonWeapon {
|
||||
public static final Vector3f OFFSET = new Vector3f(1.0F, -1.0F, 0.0F);
|
||||
private static final int SEGMENTS = 24;
|
||||
private static final double HITBOX_INFLATE = 1.0D;
|
||||
private static final double SUMMON_OFFSET_X = -1.0D;
|
||||
private static final double SUMMON_OFFSET_Y = 1.0D;
|
||||
private static final double SUMMON_OFFSET_Z = 0.0D;
|
||||
|
||||
protected Whip(Tier tier, Item.Properties properties) {
|
||||
super(tier, properties);
|
||||
@@ -61,7 +61,7 @@ public abstract class Whip extends SummonWeapon {
|
||||
return getRange() * 0.25D;
|
||||
}
|
||||
|
||||
protected int getCooldown() {
|
||||
protected int getUseTime() {
|
||||
return 20;
|
||||
}
|
||||
|
||||
@@ -90,11 +90,13 @@ public abstract class Whip extends SummonWeapon {
|
||||
Entity owner = summon.getOwner();
|
||||
if(owner == null) return;
|
||||
|
||||
CompoundTag customData = summon.getEntityData().get(StaticSummon.CUSTOM_DATA);
|
||||
Vec3 offset = readVec3(customData, "offset", new Vec3(OFFSET.x, OFFSET.y, OFFSET.z));
|
||||
Vector3f[] dirs = MathUtil.computeCoordinateSystem(owner);
|
||||
summon.setPos(new Vec3(
|
||||
owner.getX() + dirs[0].x * SUMMON_OFFSET_Z + dirs[1].x * SUMMON_OFFSET_Y + dirs[2].x * SUMMON_OFFSET_X,
|
||||
owner.getY() + dirs[0].y * SUMMON_OFFSET_Z + dirs[1].y * SUMMON_OFFSET_Y + dirs[2].y * SUMMON_OFFSET_X,
|
||||
owner.getZ() + dirs[0].z * SUMMON_OFFSET_Z + dirs[1].z * SUMMON_OFFSET_Y + dirs[2].z * SUMMON_OFFSET_X
|
||||
owner.getX() + dirs[0].x * offset.z + dirs[1].x * offset.y + dirs[2].x * offset.x,
|
||||
owner.getY() + dirs[0].y * offset.z + dirs[1].y * offset.y + dirs[2].y * offset.x,
|
||||
owner.getZ() + dirs[0].z * offset.z + dirs[1].z * offset.y + dirs[2].z * offset.x
|
||||
));
|
||||
Whip whip = getWhip(summon);
|
||||
if(whip != null) whip.onTick(summon);
|
||||
@@ -123,16 +125,65 @@ public abstract class Whip extends SummonWeapon {
|
||||
@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() / 3));
|
||||
return InteractionResultHolder.sidedSuccess(stack, level.isClientSide());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getUseDuration(ItemStack stack, LivingEntity entity) {
|
||||
return 72000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull UseAnim getUseAnimation(ItemStack stack) {
|
||||
return UseAnim.BLOCK;
|
||||
}
|
||||
|
||||
public boolean shouldShootThisTick(ItemStack weaponStack, LivingEntity entity, int remainingUseTicks) {
|
||||
int useTime = Math.max(1, getUseTime());
|
||||
int elapsedMinecraftTicks = getUseDuration(weaponStack, entity) - remainingUseTicks;
|
||||
if(elapsedMinecraftTicks <= 0) return false;
|
||||
|
||||
int currentShot = elapsedMinecraftTicks * 3 / useTime;
|
||||
int previousShot = (elapsedMinecraftTicks - 1) * 3 / useTime;
|
||||
return currentShot > previousShot;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUseTick(Level level, LivingEntity entity, ItemStack stack, int count) {
|
||||
if(level.isClientSide()) return;
|
||||
if(!(entity instanceof Player player)) return;
|
||||
if(!shouldShootThisTick(stack, entity, count)) return;
|
||||
|
||||
if(!tryShoot(level, player, player.getUsedItemHand(), stack)) {
|
||||
player.stopUsingItem();
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean tryShoot(Level level, Player player, InteractionHand hand, ItemStack stack) {
|
||||
shoot(level, player, hand, stack);
|
||||
return true;
|
||||
}
|
||||
|
||||
protected void shoot(Level level, Player player, InteractionHand hand, ItemStack stack) {
|
||||
SoundUtil.playClientSound(player, ModSounds.WHIP_USE.get());
|
||||
if(!level.isClientSide()) {
|
||||
if(level.isClientSide()) return;
|
||||
|
||||
Vector3f[] dirs = MathUtil.computeCoordinateSystem(player);
|
||||
StaticSummon summon = new StaticSummon(ModEntities.STATIC_SUMMON.get(), level);
|
||||
summon.setOwner(player);
|
||||
summon.getEntityData().set(StaticSummon.STACK_SOURCE, stack.copy());
|
||||
Vector3f offset = new Vector3f(
|
||||
hand == InteractionHand.OFF_HAND ? -OFFSET.x : OFFSET.x,
|
||||
OFFSET.y,
|
||||
OFFSET.z
|
||||
);
|
||||
summon.setPos(new Vec3(
|
||||
player.getX() + dirs[0].x * SUMMON_OFFSET_Z + dirs[1].x * SUMMON_OFFSET_Y + dirs[2].x * SUMMON_OFFSET_X,
|
||||
player.getY() + dirs[0].y * SUMMON_OFFSET_Z + dirs[1].y * SUMMON_OFFSET_Y + dirs[2].y * SUMMON_OFFSET_X,
|
||||
player.getZ() + dirs[0].z * SUMMON_OFFSET_Z + dirs[1].z * SUMMON_OFFSET_Y + dirs[2].z * SUMMON_OFFSET_X
|
||||
player.getX() + dirs[0].x * offset.z + dirs[1].x * offset.y + dirs[2].x * offset.x,
|
||||
player.getY() + dirs[0].y * offset.z + dirs[1].y * offset.y + dirs[2].y * offset.x,
|
||||
player.getZ() + dirs[0].z * offset.z + dirs[1].z * offset.y + dirs[2].z * offset.x
|
||||
));
|
||||
summon.getEntityData().set(StaticSummon.BEHAVIOR, StaticSummonBehaviors.POSSESSION);
|
||||
summon.getEntityData().set(StaticSummon.RENDER_MODE, "custom");
|
||||
@@ -150,6 +201,9 @@ public abstract class Whip extends SummonWeapon {
|
||||
customData.putFloat("rightX", dirs[2].x);
|
||||
customData.putFloat("rightY", dirs[2].y);
|
||||
customData.putFloat("rightZ", dirs[2].z);
|
||||
customData.putFloat("offsetX", offset.x);
|
||||
customData.putFloat("offsetY", offset.y);
|
||||
customData.putFloat("offsetZ", offset.z);
|
||||
customData.putDouble("range", getRange());
|
||||
customData.putDouble("height", getHeight());
|
||||
customData.putDouble("bend", getBend());
|
||||
@@ -166,10 +220,6 @@ public abstract class Whip extends SummonWeapon {
|
||||
level.addFreshEntity(summon);
|
||||
}
|
||||
|
||||
player.getCooldowns().addCooldown(stack.getItem(), getCooldown());
|
||||
return InteractionResultHolder.sidedSuccess(stack, level.isClientSide());
|
||||
}
|
||||
|
||||
private static void hurtTargets(StaticSummon summon) {
|
||||
if(summon.level().isClientSide()) return;
|
||||
|
||||
|
||||
@@ -2,11 +2,13 @@ package com.lzxnone.terraria.mixin;
|
||||
|
||||
import com.lzxnone.terraria.effect.ModEffects;
|
||||
import com.lzxnone.terraria.client.config.RenderConfigs;
|
||||
import com.lzxnone.terraria.client.item.magic.ClientNebulaBlaze;
|
||||
import com.lzxnone.terraria.client.item.melee.ClientDevilsDevastation;
|
||||
import com.lzxnone.terraria.entity.ModRenderTypes;
|
||||
import com.lzxnone.terraria.item.ModItems;
|
||||
import com.lzxnone.terraria.item.weapon.melee.DevilsDevastation;
|
||||
import com.lzxnone.terraria.item.weapon.melee.Mace;
|
||||
import com.lzxnone.terraria.item.weapon.summon.whip.Whip;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import net.minecraft.client.player.AbstractClientPlayer;
|
||||
@@ -105,8 +107,14 @@ public class ItemInHandRenderMixin {
|
||||
boolean leftHand, PoseStack poseStack, MultiBufferSource buffer,
|
||||
int seed, CallbackInfo ci) {
|
||||
if(!RenderConfigs.ENABLE_RENDER_ITEM.get()) return;
|
||||
|
||||
if((itemStack.is(ModItems.ZENITH.get())
|
||||
if(itemStack.getItem() instanceof Whip && entity instanceof Player player) {
|
||||
if(player.isUsingItem()) {
|
||||
ItemStack usingStack = player.getUseItem();
|
||||
if(usingStack.is(itemStack.getItem())) {
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
}else if((itemStack.is(ModItems.ZENITH.get())
|
||||
|| itemStack.is(ModItems.TRUE_COPPER_SHORTSWORD.get())
|
||||
|| itemStack.is(ModItems.FIRST_FRACTAL.get())
|
||||
|| itemStack.is(ModItems.TERRAGRIM.get())) && entity instanceof Player player) {
|
||||
@@ -133,6 +141,14 @@ public class ItemInHandRenderMixin {
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
}else if(itemStack.is(ModItems.NEBULA_BLAZE.get()) && entity instanceof Player player) {
|
||||
if(player.isUsingItem()) {
|
||||
ItemStack usingStack = player.getUseItem();
|
||||
if(usingStack.is(itemStack.getItem())) {
|
||||
ClientNebulaBlaze.renderHandProjectile(buffer, poseStack, player);
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
||||
import com.lzxnone.terraria.item.ModItems;
|
||||
import com.lzxnone.terraria.item.weapon.MagicWeapon;
|
||||
import com.lzxnone.terraria.item.weapon.RangedWeapon;
|
||||
import com.lzxnone.terraria.item.weapon.summon.whip.Whip;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
@@ -22,7 +23,8 @@ public abstract class UseSpeedMixin {
|
||||
|| usingItem.is(ModItems.TERRAGRIM.get())
|
||||
|| usingItem.is(ModItems.MACE.get())
|
||||
|| usingItem.getItem() instanceof MagicWeapon
|
||||
|| usingItem.getItem() instanceof RangedWeapon;
|
||||
|| usingItem.getItem() instanceof RangedWeapon
|
||||
|| usingItem.getItem() instanceof Whip;
|
||||
}
|
||||
|
||||
@WrapOperation(
|
||||
|
||||
@@ -40,6 +40,9 @@
|
||||
"magic_shoot": {
|
||||
"sounds": ["lzxnoneterraria:magic_shoot"]
|
||||
},
|
||||
"magic_shoot2": {
|
||||
"sounds": ["lzxnoneterraria:magic_shoot2"]
|
||||
},
|
||||
"bubble": {
|
||||
"sounds": ["lzxnoneterraria:bubble"]
|
||||
},
|
||||
|
||||
|
Before Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 589 B |
|
After Width: | Height: | Size: 618 B |
|
After Width: | Height: | Size: 598 B |
|
After Width: | Height: | Size: 607 B |
|
Before Width: | Height: | Size: 743 B |
|
After Width: | Height: | Size: 351 B |
|
After Width: | Height: | Size: 362 B |
|
After Width: | Height: | Size: 363 B |
|
After Width: | Height: | Size: 333 B |