-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added /spawnparticle and dimension argument to /playsound
- Loading branch information
1 parent
8224a38
commit 7a32feb
Showing
23 changed files
with
351 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
accessWidener v2 named | ||
accessible method net/minecraft/client/gui/Gui drawRect (IIIII)V | ||
accessible method net/minecraft/client/gui/Gui drawRectWidthHeight (IIIII)V | ||
accessible method net/minecraft/client/gui/Gui drawRectWidthHeight (IIIII)V | ||
accessible field net/minecraft/client/sound/SoundPool nameToSoundPoolEntriesMapping Ljava/util/Map; | ||
accessible field net/minecraft/client/sound/SoundManager soundPoolSounds Lnet/minecraft/client/sound/SoundPool; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+2.27 KB
(130%)
.../commander-bta.main/net/pedroricardo/commander/content/CommanderClientCommandSource.class
Binary file not shown.
Binary file modified
BIN
+168 Bytes
(100%)
...ction/commander-bta.main/net/pedroricardo/commander/content/CommanderCommandManager.class
Binary file not shown.
Binary file modified
BIN
+558 Bytes
(120%)
...uction/commander-bta.main/net/pedroricardo/commander/content/CommanderCommandSource.class
Binary file not shown.
Binary file modified
BIN
+2.68 KB
(150%)
...commander-bta.main/net/pedroricardo/commander/content/CommanderConsoleCommandSource.class
Binary file not shown.
Binary file modified
BIN
+2.69 KB
(140%)
.../commander-bta.main/net/pedroricardo/commander/content/CommanderServerCommandSource.class
Binary file not shown.
Binary file modified
BIN
-110 Bytes
(98%)
...n/commander-bta.main/net/pedroricardo/commander/content/arguments/Vec3dArgumentType.class
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
116 changes: 116 additions & 0 deletions
116
src/main/java/net/pedroricardo/commander/content/arguments/PositionArgumentType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
package net.pedroricardo.commander.content.arguments; | ||
|
||
import com.mojang.brigadier.StringReader; | ||
import com.mojang.brigadier.arguments.ArgumentType; | ||
import com.mojang.brigadier.context.CommandContext; | ||
import com.mojang.brigadier.exceptions.CommandSyntaxException; | ||
import com.mojang.brigadier.suggestion.Suggestions; | ||
import com.mojang.brigadier.suggestion.SuggestionsBuilder; | ||
import net.minecraft.core.util.phys.Vec3d; | ||
import net.pedroricardo.commander.content.CommanderCommandSource; | ||
import net.pedroricardo.commander.content.exceptions.CommanderExceptions; | ||
import net.pedroricardo.commander.content.helpers.DoubleCoordinate; | ||
import net.pedroricardo.commander.content.helpers.DoublePos; | ||
|
||
import java.text.DecimalFormat; | ||
import java.text.DecimalFormatSymbols; | ||
import java.util.Arrays; | ||
import java.util.Collection; | ||
import java.util.List; | ||
import java.util.Locale; | ||
import java.util.concurrent.CompletableFuture; | ||
|
||
public class PositionArgumentType implements ArgumentType<DoublePos> { | ||
private static final List<String> EXAMPLES = Arrays.asList("~ ~ ~", "0 0 0", "~ ~60 ~", "~-20 ~10 ~-25.5"); | ||
|
||
public static PositionArgumentType pos() { | ||
return new PositionArgumentType(); | ||
} | ||
|
||
@Override | ||
public DoublePos parse(StringReader reader) throws CommandSyntaxException { | ||
int i = reader.getCursor(); | ||
DoubleCoordinate x = DoubleCoordinate.parse(reader); | ||
if (!reader.canRead() || reader.peek() != ' ') { | ||
if (reader.peek() == 'f' || reader.peek() == 'd') { | ||
reader.skip(); | ||
if (!reader.canRead() || reader.peek() != ' ') { | ||
reader.setCursor(i); | ||
throw CommanderExceptions.incomplete().createWithContext(reader); | ||
} | ||
} else { | ||
reader.setCursor(i); | ||
throw CommanderExceptions.incomplete().createWithContext(reader); | ||
} | ||
} | ||
reader.skip(); | ||
DoubleCoordinate y = DoubleCoordinate.parse(reader); | ||
if (!reader.canRead() || reader.peek() != ' ') { | ||
if (reader.peek() == 'f' || reader.peek() == 'd') { | ||
reader.skip(); | ||
if (!reader.canRead() || reader.peek() != ' ') { | ||
reader.setCursor(i); | ||
throw CommanderExceptions.incomplete().createWithContext(reader); | ||
} | ||
} else { | ||
reader.setCursor(i); | ||
throw CommanderExceptions.incomplete().createWithContext(reader); | ||
} | ||
} | ||
reader.skip(); | ||
DoubleCoordinate z = DoubleCoordinate.parse(reader); | ||
return new DoublePos(x, y, z); | ||
} | ||
|
||
@Override | ||
public <S> CompletableFuture<Suggestions> listSuggestions(CommandContext<S> context, SuggestionsBuilder builder) { | ||
String string = builder.getRemaining(); | ||
Vec3d coordinates = ((CommanderCommandSource)context.getSource()).getCoordinates(true); | ||
|
||
if (coordinates == null) return builder.buildFuture(); | ||
|
||
if (string.isEmpty()) { | ||
coordinates.xCoord = roundToSixDecimals(coordinates.xCoord); | ||
coordinates.yCoord = roundToSixDecimals(coordinates.yCoord); | ||
coordinates.zCoord = roundToSixDecimals(coordinates.zCoord); | ||
String allCoordinates = coordinates.xCoord + " " + coordinates.yCoord + " " + coordinates.zCoord; | ||
try { | ||
this.parse(new StringReader(allCoordinates)); | ||
builder.suggest(String.valueOf(coordinates.xCoord)); | ||
builder.suggest(coordinates.xCoord + " " + coordinates.yCoord); | ||
builder.suggest(allCoordinates); | ||
} catch (CommandSyntaxException ignored) {} | ||
} else { | ||
String[] strings = string.split(" "); | ||
String allCoordinates; | ||
switch (strings.length) { | ||
case 1: | ||
allCoordinates = strings[0] + " " + coordinates.yCoord + " " + coordinates.zCoord; | ||
try { | ||
this.parse(new StringReader(allCoordinates)); | ||
builder.suggest(strings[0] + " " + coordinates.yCoord); | ||
builder.suggest(allCoordinates); | ||
} catch (CommandSyntaxException ignored) {} | ||
break; | ||
case 2: | ||
allCoordinates = strings[0] + " " + strings[1] + " " + coordinates.zCoord; | ||
try { | ||
this.parse(new StringReader(allCoordinates)); | ||
builder.suggest(allCoordinates); | ||
} catch (CommandSyntaxException ignored) {} | ||
break; | ||
} | ||
} | ||
return builder.buildFuture(); | ||
} | ||
|
||
private static double roundToSixDecimals(double value) { | ||
DecimalFormat df = new DecimalFormat("#.######", DecimalFormatSymbols.getInstance(Locale.ROOT)); | ||
return Double.parseDouble(df.format(value)); | ||
} | ||
|
||
@Override | ||
public Collection<String> getExamples() { | ||
return EXAMPLES; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.