generated from MrSphay/codex-agent-repository-kit
Decompile upstream Explosion Overhaul 0.2.3.0
This commit is contained in:
131
com/vinlanx/explosionoverhaul/ModCommands.java
Normal file
131
com/vinlanx/explosionoverhaul/ModCommands.java
Normal file
@@ -0,0 +1,131 @@
|
||||
/*
|
||||
* 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.minecraftforge.event.RegisterCommandsEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.network.PacketDistributor;
|
||||
|
||||
@Mod.EventBusSubscriber(modid="explosionoverhaul")
|
||||
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");
|
||||
PacketDistributor.TargetPoint targetPoint = new PacketDistributor.TargetPoint(pos.m_7096_(), pos.m_7098_(), pos.m_7094_(), 256.0, level.m_46472_());
|
||||
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.INSTANCE.send(PacketDistributor.NEAR.with(() -> targetPoint), (Object)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.m_237113_((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.m_237113_((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.m_237113_((String)"\u00a76[Explosion Overhaul] \u00a7eShowing rescan prompt..."), false);
|
||||
return 1;
|
||||
}
|
||||
catch (Exception e) {
|
||||
((CommandSourceStack)ctx.getSource()).m_81352_((Component)Component.m_237113_((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.INSTANCE.send(PacketDistributor.PLAYER.with(() -> player), (Object)new LowPassTestPacket(duration));
|
||||
((CommandSourceStack)ctx.getSource()).m_288197_(() -> Component.m_237113_((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.INSTANCE.send(PacketDistributor.PLAYER.with(() -> player), (Object)new BlurTestPacket(duration));
|
||||
((CommandSourceStack)ctx.getSource()).m_288197_(() -> Component.m_237113_((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.INSTANCE.send(PacketDistributor.PLAYER.with(() -> player), (Object)new CameraShakeConcussionPacket(duration, intensity));
|
||||
((CommandSourceStack)ctx.getSource()).m_288197_(() -> Component.m_237113_((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.INSTANCE.send(PacketDistributor.PLAYER.with(() -> player), (Object)new OpenALTogglePacket(target, turnOn));
|
||||
((CommandSourceStack)ctx.getSource()).m_288197_(() -> Component.m_237113_((String)("Sent OpenAL toggle to player: " + target + " -> " + (turnOn ? "ON" : "OFF"))), false);
|
||||
return 1;
|
||||
}
|
||||
((CommandSourceStack)ctx.getSource()).m_81352_((Component)Component.m_237113_((String)("Unknown target: " + target + ". Use 'Deafness' or 'LowPass'.")));
|
||||
return 0;
|
||||
}))));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user