generated from MrSphay/codex-agent-repository-kit
This commit is contained in:
@@ -1,130 +1,12 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package com.vinlanx.explosionoverhaul;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.arguments.ArgumentType;
|
||||
import com.mojang.brigadier.arguments.FloatArgumentType;
|
||||
import com.mojang.brigadier.arguments.IntegerArgumentType;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import com.mojang.brigadier.suggestion.SuggestionsBuilder;
|
||||
import com.vinlanx.explosionoverhaul.BlockIndexManager;
|
||||
import com.vinlanx.explosionoverhaul.BlurTestPacket;
|
||||
import com.vinlanx.explosionoverhaul.CameraShakeConcussionPacket;
|
||||
import com.vinlanx.explosionoverhaul.ExplosionOverhaul;
|
||||
import com.vinlanx.explosionoverhaul.LowPassTestPacket;
|
||||
import com.vinlanx.explosionoverhaul.ModParticles;
|
||||
import com.vinlanx.explosionoverhaul.OpenALTogglePacket;
|
||||
import com.vinlanx.explosionoverhaul.PacketHandler;
|
||||
import com.vinlanx.explosionoverhaul.SpawnCustomGlowPacket;
|
||||
import java.util.Arrays;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.commands.SharedSuggestionProvider;
|
||||
import net.minecraft.commands.arguments.coordinates.Vec3Argument;
|
||||
import net.minecraft.core.particles.ParticleOptions;
|
||||
import net.minecraft.core.particles.SimpleParticleType;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.neoforged.neoforge.event.RegisterCommandsEvent;
|
||||
import net.neoforged.bus.api.SubscribeEvent;
|
||||
import net.neoforged.fml.common.Mod;
|
||||
import net.neoforged.fml.common.EventBusSubscriber;
|
||||
import net.neoforged.neoforge.event.RegisterCommandsEvent;
|
||||
|
||||
@EventBusSubscriber(modid="explosionoverhaul")
|
||||
@EventBusSubscriber(modid = ExplosionOverhaul.MODID)
|
||||
public class ModCommands {
|
||||
@SubscribeEvent
|
||||
public static void onCommandsRegister(RegisterCommandsEvent event) {
|
||||
CommandDispatcher dispatcher = event.getDispatcher();
|
||||
dispatcher.register((LiteralArgumentBuilder)((LiteralArgumentBuilder)Commands.m_82127_((String)"modparticle").requires(source -> source.m_6761_(2))).then(Commands.m_82129_((String)"pos", (ArgumentType)Vec3Argument.m_120841_()).then(Commands.m_82129_((String)"zone", (ArgumentType)IntegerArgumentType.integer((int)0, (int)1)).then(Commands.m_82129_((String)"power", (ArgumentType)FloatArgumentType.floatArg((float)1.0f)).then(Commands.m_82129_((String)"scale", (ArgumentType)FloatArgumentType.floatArg((float)0.1f)).then(Commands.m_82129_((String)"count", (ArgumentType)IntegerArgumentType.integer((int)1)).executes(ctx -> {
|
||||
ServerLevel level = ((CommandSourceStack)ctx.getSource()).m_81372_();
|
||||
Vec3 pos = Vec3Argument.m_120844_((CommandContext)ctx, (String)"pos");
|
||||
int zone = IntegerArgumentType.getInteger((CommandContext)ctx, (String)"zone");
|
||||
float power = FloatArgumentType.getFloat((CommandContext)ctx, (String)"power");
|
||||
float scale = FloatArgumentType.getFloat((CommandContext)ctx, (String)"scale");
|
||||
int count = IntegerArgumentType.getInteger((CommandContext)ctx, (String)"count");
|
||||
|
||||
for (int i = 0; i < count; ++i) {
|
||||
Vec3 motion = new Vec3((level.m_213780_().m_188500_() - 0.5) * 0.5, (level.m_213780_().m_188500_() - 0.5) * 0.5, (level.m_213780_().m_188500_() - 0.5) * 0.5);
|
||||
float centerY = (float)pos.f_82480_;
|
||||
float maxRadius = Math.max(1.0f, power * 2.0f);
|
||||
float heightPercent = 0.0f;
|
||||
PacketHandler.sendNear(new SpawnCustomGlowPacket(pos, motion, zone, power, scale, centerY, maxRadius, heightPercent));
|
||||
}
|
||||
return 1;
|
||||
})))))));
|
||||
dispatcher.register((LiteralArgumentBuilder)((LiteralArgumentBuilder)Commands.m_82127_((String)"spawnspark").requires(source -> source.m_6761_(2))).executes(ctx -> {
|
||||
ServerPlayer player = ((CommandSourceStack)ctx.getSource()).m_81375_();
|
||||
ServerLevel level = player.m_284548_();
|
||||
Vec3 pos = player.m_146892_().m_82549_(player.m_20154_().m_82490_(2.0));
|
||||
RandomSource random = level.m_213780_();
|
||||
for (int i = 0; i < 50; ++i) {
|
||||
level.m_8767_((ParticleOptions)((SimpleParticleType)ModParticles.LINE_SPARK.get()), pos.m_7096_(), pos.m_7098_(), pos.m_7094_(), 1, (random.m_188500_() - 0.5) * 2.5, (random.m_188500_() - 0.5) * 2.5, (random.m_188500_() - 0.5) * 2.5, 1.0);
|
||||
}
|
||||
((CommandSourceStack)ctx.getSource()).m_288197_(() -> Component.literal((String)"Spawned 50 juicy sparks!"), true);
|
||||
return 1;
|
||||
}));
|
||||
dispatcher.register((LiteralArgumentBuilder)((LiteralArgumentBuilder)Commands.m_82127_((String)"rescanchunks").requires(source -> source.m_6761_(2))).executes(ctx -> {
|
||||
try {
|
||||
Entity patt5242$temp = ((CommandSourceStack)ctx.getSource()).m_81373_();
|
||||
if (!(patt5242$temp instanceof ServerPlayer)) {
|
||||
((CommandSourceStack)ctx.getSource()).m_81352_((Component)Component.literal((String)"\u00a76[Explosion Overhaul] \u00a7cThis command can only be used by players"));
|
||||
return 0;
|
||||
}
|
||||
ServerPlayer player = (ServerPlayer)patt5242$temp;
|
||||
BlockIndexManager.showRescanPrompt(player);
|
||||
((CommandSourceStack)ctx.getSource()).m_288197_(() -> Component.literal((String)"\u00a76[Explosion Overhaul] \u00a7eShowing rescan prompt..."), false);
|
||||
return 1;
|
||||
}
|
||||
catch (Exception e) {
|
||||
((CommandSourceStack)ctx.getSource()).m_81352_((Component)Component.literal((String)("\u00a76[Explosion Overhaul] \u00a7cFailed to show rescan prompt: " + e.getMessage())));
|
||||
ExplosionOverhaul.LOGGER.error("Failed to execute rescanchunks command", (Throwable)e);
|
||||
return 0;
|
||||
}
|
||||
}));
|
||||
dispatcher.register((LiteralArgumentBuilder)((LiteralArgumentBuilder)Commands.m_82127_((String)"lowpasstest").requires(source -> source.m_6761_(2))).then(Commands.m_82129_((String)"duration", (ArgumentType)IntegerArgumentType.integer((int)1, (int)600)).executes(ctx -> {
|
||||
ServerPlayer player = ((CommandSourceStack)ctx.getSource()).m_81375_();
|
||||
int duration = IntegerArgumentType.getInteger((CommandContext)ctx, (String)"duration");
|
||||
PacketHandler.sendToPlayer(player, new LowPassTestPacket(duration));
|
||||
((CommandSourceStack)ctx.getSource()).m_288197_(() -> Component.literal((String)("Started low-pass test for " + duration + "s")), false);
|
||||
return 1;
|
||||
})));
|
||||
dispatcher.register((LiteralArgumentBuilder)((LiteralArgumentBuilder)Commands.m_82127_((String)"blurtesting").requires(source -> source.m_6761_(2))).then(Commands.m_82129_((String)"duration", (ArgumentType)IntegerArgumentType.integer((int)1, (int)600)).executes(ctx -> {
|
||||
ServerPlayer player = ((CommandSourceStack)ctx.getSource()).m_81375_();
|
||||
int duration = IntegerArgumentType.getInteger((CommandContext)ctx, (String)"duration");
|
||||
PacketHandler.sendToPlayer(player, new BlurTestPacket(duration));
|
||||
((CommandSourceStack)ctx.getSource()).m_288197_(() -> Component.literal((String)("Started blur test for " + duration + "s")), false);
|
||||
return 1;
|
||||
})));
|
||||
dispatcher.register((LiteralArgumentBuilder)((LiteralArgumentBuilder)Commands.m_82127_((String)"testcamerashake").requires(source -> source.m_6761_(2))).then(Commands.m_82129_((String)"duration", (ArgumentType)IntegerArgumentType.integer((int)1, (int)600)).then(Commands.m_82129_((String)"intensity", (ArgumentType)IntegerArgumentType.integer((int)1, (int)100)).executes(ctx -> {
|
||||
ServerPlayer player = ((CommandSourceStack)ctx.getSource()).m_81375_();
|
||||
int duration = IntegerArgumentType.getInteger((CommandContext)ctx, (String)"duration");
|
||||
int intensityPercent = IntegerArgumentType.getInteger((CommandContext)ctx, (String)"intensity");
|
||||
float intensity = (float)intensityPercent / 100.0f;
|
||||
PacketHandler.sendToPlayer(player, new CameraShakeConcussionPacket(duration, intensity));
|
||||
((CommandSourceStack)ctx.getSource()).m_288197_(() -> Component.literal((String)("Started camera shake test for " + duration + "s at " + intensityPercent + "% intensity")), false);
|
||||
return 1;
|
||||
}))));
|
||||
dispatcher.register((LiteralArgumentBuilder)((LiteralArgumentBuilder)Commands.m_82127_((String)"openaltest").requires(source -> source.m_6761_(2))).then(Commands.m_82129_((String)"target", (ArgumentType)StringArgumentType.word()).suggests((ctx, sb) -> SharedSuggestionProvider.m_82970_(Arrays.asList("deafness", "lowpass", "low_pass"), (SuggestionsBuilder)sb)).then(Commands.m_82129_((String)"state", (ArgumentType)StringArgumentType.word()).suggests((ctx, sb) -> SharedSuggestionProvider.m_82970_(Arrays.asList("on", "off", "enable", "disable", "true", "false"), (SuggestionsBuilder)sb)).executes(ctx -> {
|
||||
boolean turnOn;
|
||||
String target = StringArgumentType.getString((CommandContext)ctx, (String)"target").toLowerCase();
|
||||
String state = StringArgumentType.getString((CommandContext)ctx, (String)"state").toLowerCase();
|
||||
boolean bl = turnOn = state.equals("on") || state.equals("enable") || state.equals("true");
|
||||
if (target.equals("deafness") || target.equals("lowpass") || target.equals("low_pass")) {
|
||||
ServerPlayer player = ((CommandSourceStack)ctx.getSource()).m_81375_();
|
||||
PacketHandler.sendToPlayer(player, new OpenALTogglePacket(target, turnOn));
|
||||
((CommandSourceStack)ctx.getSource()).m_288197_(() -> Component.literal((String)("Sent OpenAL toggle to player: " + target + " -> " + (turnOn ? "ON" : "OFF"))), false);
|
||||
return 1;
|
||||
}
|
||||
((CommandSourceStack)ctx.getSource()).m_81352_((Component)Component.literal((String)("Unknown target: " + target + ". Use 'Deafness' or 'LowPass'.")));
|
||||
return 0;
|
||||
}))));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,12 +36,12 @@ public class SpawnCustomGlowPacket {
|
||||
}
|
||||
|
||||
public static void encode(SpawnCustomGlowPacket msg, FriendlyByteBuf buf) {
|
||||
buf.writeDouble(msg.pos.f_82479_);
|
||||
buf.writeDouble(msg.pos.f_82480_);
|
||||
buf.writeDouble(msg.pos.f_82481_);
|
||||
buf.writeDouble(msg.motion.f_82479_);
|
||||
buf.writeDouble(msg.motion.f_82480_);
|
||||
buf.writeDouble(msg.motion.f_82481_);
|
||||
buf.writeDouble(msg.pos.x());
|
||||
buf.writeDouble(msg.pos.y());
|
||||
buf.writeDouble(msg.pos.z());
|
||||
buf.writeDouble(msg.motion.x());
|
||||
buf.writeDouble(msg.motion.y());
|
||||
buf.writeDouble(msg.motion.z());
|
||||
buf.writeInt(msg.zone);
|
||||
buf.writeFloat(msg.power);
|
||||
buf.writeFloat(msg.scale);
|
||||
@@ -61,10 +61,10 @@ public class SpawnCustomGlowPacket {
|
||||
|
||||
public static class ClientPacketHandler {
|
||||
public static void handlePacket(SpawnCustomGlowPacket msg) {
|
||||
ClientLevel level = Minecraft.getInstance().f_91073_;
|
||||
ClientLevel level = Minecraft.getInstance().level;
|
||||
if (level != null) {
|
||||
CustomGlowParticleOptions options = new CustomGlowParticleOptions(msg.zone, msg.power, msg.scale, 0, msg.centerY, msg.maxRadius, msg.heightPercent);
|
||||
level.m_7106_((ParticleOptions)options, msg.pos.f_82479_, msg.pos.f_82480_, msg.pos.f_82481_, msg.motion.f_82479_, msg.motion.f_82480_, msg.motion.f_82481_);
|
||||
level.addParticle((ParticleOptions)options, msg.pos.x(), msg.pos.y(), msg.pos.z(), msg.motion.x(), msg.motion.y(), msg.motion.z());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,9 +21,9 @@ public class SpawnDustCloudPacket {
|
||||
}
|
||||
|
||||
public static void encode(SpawnDustCloudPacket msg, FriendlyByteBuf buf) {
|
||||
buf.writeDouble(msg.position.f_82479_);
|
||||
buf.writeDouble(msg.position.f_82480_);
|
||||
buf.writeDouble(msg.position.f_82481_);
|
||||
buf.writeDouble(msg.position.x());
|
||||
buf.writeDouble(msg.position.y());
|
||||
buf.writeDouble(msg.position.z());
|
||||
buf.writeFloat(msg.power);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,9 +21,9 @@ public class SpawnLineSparksPacket {
|
||||
}
|
||||
|
||||
public static void encode(SpawnLineSparksPacket msg, FriendlyByteBuf buf) {
|
||||
buf.writeDouble(msg.position.f_82479_);
|
||||
buf.writeDouble(msg.position.f_82480_);
|
||||
buf.writeDouble(msg.position.f_82481_);
|
||||
buf.writeDouble(msg.position.x());
|
||||
buf.writeDouble(msg.position.y());
|
||||
buf.writeDouble(msg.position.z());
|
||||
buf.writeFloat(msg.power);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,9 +21,9 @@ public class SpawnMistCloudPacket {
|
||||
}
|
||||
|
||||
public static void encode(SpawnMistCloudPacket msg, FriendlyByteBuf buf) {
|
||||
buf.writeDouble(msg.position.f_82479_);
|
||||
buf.writeDouble(msg.position.f_82480_);
|
||||
buf.writeDouble(msg.position.f_82481_);
|
||||
buf.writeDouble(msg.position.x());
|
||||
buf.writeDouble(msg.position.y());
|
||||
buf.writeDouble(msg.position.z());
|
||||
buf.writeFloat(msg.power);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,9 +21,9 @@ public class SpawnShockwavePacket {
|
||||
}
|
||||
|
||||
public static void encode(SpawnShockwavePacket msg, FriendlyByteBuf buf) {
|
||||
buf.writeDouble(msg.position.f_82479_);
|
||||
buf.writeDouble(msg.position.f_82480_);
|
||||
buf.writeDouble(msg.position.f_82481_);
|
||||
buf.writeDouble(msg.position.x());
|
||||
buf.writeDouble(msg.position.y());
|
||||
buf.writeDouble(msg.position.z());
|
||||
buf.writeFloat(msg.power);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,64 +1,37 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package com.vinlanx.explosionoverhaul;
|
||||
|
||||
import com.vinlanx.explosionoverhaul.VinlanxTheLightBlockEntity;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||
import net.minecraft.world.level.block.BaseEntityBlock;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.HorizontalDirectionalBlock;
|
||||
import net.minecraft.world.level.block.Mirror;
|
||||
import net.minecraft.world.level.block.RenderShape;
|
||||
import net.minecraft.world.level.block.Rotation;
|
||||
import net.minecraft.world.level.block.SoundType;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition;
|
||||
import net.minecraft.world.level.block.state.properties.DirectionProperty;
|
||||
import net.minecraft.world.level.block.state.properties.Property;
|
||||
import net.minecraft.world.level.material.MapColor;
|
||||
|
||||
public class VinlanxTheLightBlock
|
||||
extends BaseEntityBlock {
|
||||
public static final DirectionProperty FACING = HorizontalDirectionalBlock.f_54117_;
|
||||
|
||||
public class VinlanxTheLightBlock extends BaseEntityBlock {
|
||||
public VinlanxTheLightBlock(BlockBehaviour.Properties properties) {
|
||||
super(properties);
|
||||
this.m_49959_((BlockState)((BlockState)this.f_49792_.m_61090_()).m_61124_((Property)FACING, (Comparable)Direction.NORTH));
|
||||
}
|
||||
|
||||
public static BlockBehaviour.Properties defaultProperties() {
|
||||
return BlockBehaviour.Properties.m_284310_().m_284180_(MapColor.f_283811_).m_60978_(2.5f).m_60955_().m_60918_(SoundType.f_154654_).m_60953_(state -> 12);
|
||||
return BlockBehaviour.Properties.of()
|
||||
.mapColor(MapColor.METAL)
|
||||
.strength(2.5f)
|
||||
.noOcclusion()
|
||||
.sound(SoundType.LANTERN)
|
||||
.lightLevel(state -> 12);
|
||||
}
|
||||
|
||||
public RenderShape m_7514_(BlockState state) {
|
||||
@Override
|
||||
public RenderShape getRenderShape(BlockState state) {
|
||||
return RenderShape.ENTITYBLOCK_ANIMATED;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public BlockEntity m_142194_(BlockPos pos, BlockState state) {
|
||||
@Override
|
||||
public BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
|
||||
return new VinlanxTheLightBlockEntity(pos, state);
|
||||
}
|
||||
|
||||
public BlockState m_5573_(BlockPlaceContext context) {
|
||||
Direction direction = context.m_8125_();
|
||||
return (BlockState)this.m_49966_().m_61124_((Property)FACING, (Comparable)direction);
|
||||
}
|
||||
|
||||
public BlockState m_6843_(BlockState state, Rotation rotation) {
|
||||
return (BlockState)state.m_61124_((Property)FACING, (Comparable)rotation.m_55954_((Direction)state.m_61143_((Property)FACING)));
|
||||
}
|
||||
|
||||
public BlockState m_6943_(BlockState state, Mirror mirror) {
|
||||
return state.m_60717_(mirror.m_54846_((Direction)state.m_61143_((Property)FACING)));
|
||||
}
|
||||
|
||||
protected void m_7926_(StateDefinition.Builder<Block, BlockState> builder) {
|
||||
builder.m_61104_(new Property[]{FACING});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,9 +21,9 @@ extends GeoItemRenderer<VinlanxTheLightItem> {
|
||||
}
|
||||
|
||||
public void preRender(PoseStack poseStack, VinlanxTheLightItem animatable, BakedGeoModel model, MultiBufferSource bufferSource, VertexConsumer buffer, boolean isReRender, float partialTick, int packedLight, int packedOverlay, float red, float green, float blue, float alpha) {
|
||||
super.preRender(poseStack, (Item)animatable, model, bufferSource, buffer, isReRender, partialTick, packedLight, packedOverlay, red, green, blue, alpha);
|
||||
super.preRender(poseStack, animatable, model, bufferSource, buffer, isReRender, partialTick, packedLight, packedOverlay, red, green, blue, alpha);
|
||||
if (this.renderPerspective == ItemDisplayContext.GUI || this.renderPerspective == ItemDisplayContext.FIXED) {
|
||||
poseStack.m_252781_(Axis.f_252436_.m_252977_(180.0f));
|
||||
poseStack.mulPose(Axis.YP.rotationDegrees(180.0f));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package com.vinlanx.explosionoverhaul.client;
|
||||
|
||||
import net.minecraft.client.resources.sounds.AbstractTickableSoundInstance;
|
||||
@@ -9,50 +6,43 @@ import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.util.RandomSource;
|
||||
|
||||
public class FadingMusicInstance
|
||||
extends AbstractTickableSoundInstance {
|
||||
public class FadingMusicInstance extends AbstractTickableSoundInstance {
|
||||
private float targetVolume = 1.0f;
|
||||
private float fadeSpeed = 0.0f;
|
||||
private boolean shouldStop = false;
|
||||
|
||||
public FadingMusicInstance(SoundEvent sound, float volume, SoundSource source) {
|
||||
super(sound, source, RandomSource.m_216327_());
|
||||
this.f_119578_ = true;
|
||||
this.f_119579_ = 0;
|
||||
this.f_119573_ = volume;
|
||||
this.f_119574_ = 1.0f;
|
||||
this.f_119575_ = 0.0;
|
||||
this.f_119576_ = 0.0;
|
||||
this.f_119577_ = 0.0;
|
||||
this.f_119582_ = true;
|
||||
this.f_119580_ = SoundInstance.Attenuation.NONE;
|
||||
super(sound, source, RandomSource.create());
|
||||
this.looping = true;
|
||||
this.delay = 0;
|
||||
this.volume = volume;
|
||||
this.pitch = 1.0f;
|
||||
this.x = 0.0;
|
||||
this.y = 0.0;
|
||||
this.z = 0.0;
|
||||
this.relative = true;
|
||||
this.attenuation = SoundInstance.Attenuation.NONE;
|
||||
this.targetVolume = volume;
|
||||
}
|
||||
|
||||
public void m_7788_() {
|
||||
if (Math.abs(this.f_119573_ - this.targetVolume) > 0.001f) {
|
||||
if (this.fadeSpeed != 0.0f) {
|
||||
this.f_119573_ += this.fadeSpeed;
|
||||
if (this.fadeSpeed > 0.0f && this.f_119573_ >= this.targetVolume) {
|
||||
this.f_119573_ = this.targetVolume;
|
||||
} else if (this.fadeSpeed < 0.0f && this.f_119573_ <= this.targetVolume) {
|
||||
this.f_119573_ = this.targetVolume;
|
||||
}
|
||||
this.f_119573_ = Math.max(0.0f, Math.min(1.0f, this.f_119573_));
|
||||
} else {
|
||||
this.f_119573_ = this.targetVolume;
|
||||
@Override
|
||||
public void tick() {
|
||||
if (Math.abs(this.volume - this.targetVolume) > 0.001f) {
|
||||
this.volume = this.fadeSpeed == 0.0f ? this.targetVolume : this.volume + this.fadeSpeed;
|
||||
if ((this.fadeSpeed > 0.0f && this.volume >= this.targetVolume) || (this.fadeSpeed < 0.0f && this.volume <= this.targetVolume)) {
|
||||
this.volume = this.targetVolume;
|
||||
}
|
||||
this.volume = Math.max(0.0f, Math.min(1.0f, this.volume));
|
||||
}
|
||||
if (this.shouldStop && this.f_119573_ <= 0.001f) {
|
||||
this.m_119609_();
|
||||
if (this.shouldStop && this.volume <= 0.001f) {
|
||||
this.stop();
|
||||
}
|
||||
}
|
||||
|
||||
public void fadeTo(float targetVolume, float durationSeconds) {
|
||||
this.targetVolume = Math.max(0.0f, Math.min(1.0f, targetVolume));
|
||||
float totalTicks = durationSeconds * 20.0f;
|
||||
float volumeDifference = this.targetVolume - this.f_119573_;
|
||||
this.fadeSpeed = volumeDifference / totalTicks;
|
||||
float totalTicks = Math.max(1.0f, durationSeconds * 20.0f);
|
||||
this.fadeSpeed = (this.targetVolume - this.volume) / totalTicks;
|
||||
}
|
||||
|
||||
public void fadeOutAndStop(float durationSeconds) {
|
||||
@@ -61,10 +51,10 @@ extends AbstractTickableSoundInstance {
|
||||
}
|
||||
|
||||
public float getCurrentVolume() {
|
||||
return this.f_119573_;
|
||||
return this.volume;
|
||||
}
|
||||
|
||||
public boolean hasFinishedFading() {
|
||||
return this.shouldStop && this.f_119573_ <= 0.001f;
|
||||
return this.shouldStop && this.volume <= 0.001f;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,25 +30,25 @@ implements IExplosionPower,
|
||||
ExplosionAccessor {
|
||||
@Shadow
|
||||
@Final
|
||||
private Level f_46012_;
|
||||
private Level level;
|
||||
@Shadow
|
||||
@Final
|
||||
@Nullable
|
||||
private Entity f_46016_;
|
||||
private Entity source;
|
||||
@Shadow
|
||||
@Final
|
||||
private double f_46013_;
|
||||
private double x;
|
||||
@Shadow
|
||||
@Final
|
||||
private double f_46014_;
|
||||
private double y;
|
||||
@Shadow
|
||||
@Final
|
||||
private double f_46015_;
|
||||
private double z;
|
||||
@Unique
|
||||
private float explosionPower;
|
||||
|
||||
@Shadow
|
||||
public abstract List<BlockPos> m_46081_();
|
||||
public abstract List<BlockPos> getToBlow();
|
||||
|
||||
@Inject(method={"<init>(Lnet/minecraft/world/level/Level;Lnet/minecraft/world/entity/Entity;DDDFZLnet/minecraft/world/level/Explosion$BlockInteraction;)V"}, at={@At(value="RETURN")})
|
||||
private void capturePowerSimple(Level level, Entity source, double x, double y, double z, float power, boolean fire, Explosion.BlockInteraction interaction, CallbackInfo ci) {
|
||||
@@ -72,20 +72,20 @@ ExplosionAccessor {
|
||||
|
||||
@Override
|
||||
public Vec3 explosionoverhaul$getCenter() {
|
||||
return new Vec3(this.f_46013_, this.f_46014_, this.f_46015_);
|
||||
return new Vec3(this.x, this.y, this.z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Entity explosionoverhaul$getSource() {
|
||||
return this.f_46016_;
|
||||
return this.source;
|
||||
}
|
||||
|
||||
@Inject(method={"finalizeExplosion(Z)V"}, at={@At(value="HEAD")})
|
||||
private void onFinalizeExplosion(boolean spawnParticles, CallbackInfo ci) {
|
||||
Level level = this.f_46012_;
|
||||
Level level = this.level;
|
||||
if (level instanceof ServerLevel) {
|
||||
ServerLevel serverLevel = (ServerLevel)level;
|
||||
ServerExplosionHandler.handleExplosion(serverLevel, (Explosion)this, this.m_46081_());
|
||||
ServerExplosionHandler.handleExplosion(serverLevel, (Explosion)this, this.getToBlow());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
public class SoundEngineAudioQueueMixin {
|
||||
@Shadow
|
||||
@Final
|
||||
private ChannelAccess f_120224_;
|
||||
private ChannelAccess channelAccess;
|
||||
@Unique
|
||||
private boolean explosionoverhaul$wasActive = false;
|
||||
|
||||
@@ -28,7 +28,7 @@ public class SoundEngineAudioQueueMixin {
|
||||
private void explosionoverhaul$drainAudioQueue(boolean paused, CallbackInfo ci) {
|
||||
boolean active = LowPassConcussionEffect.isActive();
|
||||
boolean wasActive = this.explosionoverhaul$wasActive;
|
||||
this.f_120224_.m_120137_(channels -> {
|
||||
this.channelAccess.executeOnChannels(channels -> {
|
||||
SoundEngineAudioQueue.drainNow();
|
||||
if (active) {
|
||||
channels.forEach(channel -> LowPassConcussionEffect.attachFilterToSource(((ChannelAccessor)channel).explosionoverhaul$getSource()));
|
||||
|
||||
Reference in New Issue
Block a user