CommandParticle .java

net.minecraft.command.CommandParticle (class, 134 lines): members: addTabCompletionOptions, getRequiredPermissionLevel, getCommandUsage, getCommandName.

net.minecraft.commandclass134 linescommonextends CommandBase4.5 KB

API Surface (5)

String getCommandName()
int getRequiredPermissionLevel()
String getCommandUsage(ICommandSender sender)
void processCommand(ICommandSender sender, String[] args)
List<String> addTabCompletionOptions(ICommandSender sender, String[] args, BlockPos pos)

String literals (6)

"particle"
"commands.particle.usage"
"commands.particle.notFound"
"force"
"commands.particle.success"
"normal"

Code Graph: Dependencies (7)

Edges (calls / imports / inherits / references) resolved by graphify from the AST. Every chip opens the class source.

Full Source

CommandParticle.java134 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.command;
2
3
import java.util.List;
4
import net.minecraft.util.BlockPos;
5
import net.minecraft.util.EnumParticleTypes;
6
import net.minecraft.util.Vec3;
7
import net.minecraft.world.World;
8
import net.minecraft.world.WorldServer;
9
10
public class CommandParticle extends CommandBase
11
{
12
    /**
13
     * Gets the name of the command
14
     */
15
    public String getCommandName()
16
    {
17
        return "particle";
18
    }
19
20
    /**
21
     * Return the required permission level for this command.
22
     */
23
    public int getRequiredPermissionLevel()
24
    {
25
        return 2;
26
    }
27
28
    /**
29
     * Gets the usage string for the command.
30
     */
31
    public String getCommandUsage(ICommandSender sender)
32
    {
33
        return "commands.particle.usage";
34
    }
35
36
    /**
37
     * Callback when the command is invoked
38
     */
39
    public void processCommand(ICommandSender sender, String[] args) throws CommandException
40
    {
41
        if (args.length < 8)
42
        {
43
            throw new WrongUsageException("commands.particle.usage", new Object[0]);
44
        }
45
        else
46
        {
47
            boolean flag = false;
48
            EnumParticleTypes enumparticletypes = null;
49
50
            for (EnumParticleTypes enumparticletypes1 : EnumParticleTypes.values())
51
            {
52
                if (enumparticletypes1.hasArguments())
53
                {
54
                    if (args[0].startsWith(enumparticletypes1.getParticleName()))
55
                    {
56
                        flag = true;
57
                        enumparticletypes = enumparticletypes1;
58
                        break;
59
                    }
60
                }
61
                else if (args[0].equals(enumparticletypes1.getParticleName()))
62
                {
63
                    flag = true;
64
                    enumparticletypes = enumparticletypes1;
65
                    break;
66
                }
67
            }
68
69
            if (!flag)
70
            {
71
                throw new CommandException("commands.particle.notFound", new Object[] {args[0]});
72
            }
73
            else
74
            {
75
                String s = args[0];
76
                Vec3 vec3 = sender.getPositionVector();
77
                double d6 = (double)((float)parseDouble(vec3.xCoord, args[1], true));
78
                double d0 = (double)((float)parseDouble(vec3.yCoord, args[2], true));
79
                double d1 = (double)((float)parseDouble(vec3.zCoord, args[3], true));
80
                double d2 = (double)((float)parseDouble(args[4]));
81
                double d3 = (double)((float)parseDouble(args[5]));
82
                double d4 = (double)((float)parseDouble(args[6]));
83
                double d5 = (double)((float)parseDouble(args[7]));
84
                int i = 0;
85
86
                if (args.length > 8)
87
                {
88
                    i = parseInt(args[8], 0);
89
                }
90
91
                boolean flag1 = false;
92
93
                if (args.length > 9 && "force".equals(args[9]))
94
                {
95
                    flag1 = true;
96
                }
97
98
                World world = sender.getEntityWorld();
99
100
                if (world instanceof WorldServer)
101
                {
102
                    WorldServer worldserver = (WorldServer)world;
103
                    int[] aint = new int[enumparticletypes.getArgumentCount()];
104
105
                    if (enumparticletypes.hasArguments())
106
                    {
107
                        String[] astring = args[0].split("_", 3);
108
109
                        for (int j = 1; j < astring.length; ++j)
110
                        {
111
                            try
112
                            {
113
                                aint[j - 1] = Integer.parseInt(astring[j]);
114
                            }
115
                            catch (NumberFormatException var29)
116
                            {
117
                                throw new CommandException("commands.particle.notFound", new Object[] {args[0]});
118
                            }
119
                        }
120
                    }
121
122
                    worldserver.spawnParticle(enumparticletypes, flag1, d6, d0, d1, i, d2, d3, d4, d5, aint);
123
                    notifyOperators(sender, this, "commands.particle.success", new Object[] {s, Integer.valueOf(Math.max(i, 1))});
124
                }
125
            }
126
        }
127
    }
128
129
    public List<String> addTabCompletionOptions(ICommandSender sender, String[] args, BlockPos pos)
130
    {
131
        return args.length == 1 ? getListOfStringsMatchingLastWord(args, EnumParticleTypes.getParticleNames()) : (args.length > 1 && args.length <= 4 ? func_175771_a(args, 1, pos) : (args.length == 10 ? getListOfStringsMatchingLastWord(args, new String[] {"normal", "force"}): null));
132
    }
133
}
134

Deobfuscated MCP 1.8.9 source of CommandParticle from Marcelektro/MavenMCP-1.8.9 (net/minecraft/command/CommandParticle.java), stored verbatim.