Skip to content

Commit

Permalink
enhance command blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
Spigey committed May 3, 2024
1 parent eec5382 commit 1d8e3b1
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/main/java/spigey/asteroide/util.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,28 @@ public static void addCommand(Command CommandToAdd){
}
public static void addHud(HudElementInfo HudToAdd){
Hud.get().register(HudToAdd);
} // {display:{Name:'["",{"text":"COMMAND","color":"dark_gray"}]'},Enchantments:[{lvl:1,id:infinity}],HideFlags:1}
public static void CommandBlock(Item CommandBlockToGive, String Command, int AlwaysActive, String DisplayName, boolean Enchanted) throws CommandSyntaxException {
if(!CommandBlockToGive.toString().toUpperCase().contains("COMMAND_BLOCK")){return;} // Only allow Command Blocks
Command = Command.replaceAll("\"", "\\\\\\\"");
DisplayName = DisplayName.replaceAll("\"", "\\\\\\\"");
String nbt = "{display:{Name:'[\"\",{\"text\":\"" + DisplayName +"\",\"color\":\"dark_gray\"}]'},BlockEntityTag:{Command:\"" + Command + "\",auto:" + AlwaysActive + "b},HideFlags:127"; // idfk nbt
if(Enchanted){nbt += ",Enchantments:[{lvl:1,id:infinity}]";}
nbt += "}";
give(itemstack(CommandBlockToGive), nbt);
}
public static void CommandBlock(Item CommandBlockToGive, String Command, int AlwaysActive) throws CommandSyntaxException {
public static void CommandBlock(Item CommandBlockToGive, String Command, int AlwaysActive, boolean Enchanted) throws CommandSyntaxException {
if(!CommandBlockToGive.toString().toUpperCase().contains("COMMAND_BLOCK")){return;} // Only allow Command Blocks
Command = Command.replaceAll("\"", "\\\\\\\"");
String nbt = "{BlockEntityTag:{Command:\"" + Command + "\",auto:" + AlwaysActive + "b},HideFlags:127}"; // idfk nbt
if(Enchanted){
nbt = "{BlockEntityTag:{Command:\\\"\" + Command + \"\\\",auto:\" + AlwaysActive + \"b},Enchantments:[{lvl:1,id:infinity}],HideFlags:127}";
}
give(itemstack(CommandBlockToGive), nbt);
}
public static void CommandBlock(Item CommandBlockToGive, String Command, int AlwaysActive) throws CommandSyntaxException {
CommandBlock(CommandBlockToGive, Command, AlwaysActive, false);
}
public static double eval(final String str) {
return new Object() {
int pos = -1, ch;
Expand Down

0 comments on commit 1d8e3b1

Please sign in to comment.