Command blocks now execute commands at the player

This commit is contained in:
Marcel Konrad
2020-07-29 01:09:20 +02:00
parent ce31d6e7b2
commit 227d1edc5d
2 changed files with 109 additions and 1 deletions

View File

@@ -0,0 +1,99 @@
package exopandora.worldhandler.builder.impl;
import javax.annotation.Nullable;
import exopandora.worldhandler.builder.CommandBuilder;
import exopandora.worldhandler.builder.CommandSyntax;
import exopandora.worldhandler.builder.types.ArgumentType;
import exopandora.worldhandler.util.EnumHelper;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@OnlyIn(Dist.CLIENT)
public class BuilderExecute extends CommandBuilder
{
public void setMode1(EnumMode mode)
{
this.setNode(0, mode.toString());
}
@Nullable
public EnumMode getMode1()
{
return EnumHelper.valueOf(this.getNodeAsString(0), EnumMode.class);
}
public void setTarget(String target)
{
this.setNode(1, target);
}
public String getTarget()
{
return this.getNodeAsString(1);
}
public void setMode2(EnumMode mode)
{
this.setNode(2, mode.toString());
}
@Nullable
public EnumMode getMode2()
{
return EnumHelper.valueOf(this.getNodeAsString(2), EnumMode.class);
}
public void setCommand(String command)
{
if(command != null && command.startsWith("/"))
{
this.setNode(3, command.substring(1));
}
else
{
this.setNode(3, command);
}
}
public String getCommand()
{
return this.getNodeAsString(3);
}
@Override
public String getCommandName()
{
return "execute";
}
@Override
public CommandSyntax getSyntax()
{
CommandSyntax syntax = new CommandSyntax();
syntax.addRequired("modifier", ArgumentType.STRING);
syntax.addRequired("targets", ArgumentType.STRING);
syntax.addRequired("action", ArgumentType.STRING);
syntax.addRequired("command", ArgumentType.STRING);
return syntax;
}
@OnlyIn(Dist.CLIENT)
public static enum EnumMode
{
ALIGN,
ANCHORED,
AS,
AT,
IN,
RUN;
@Override
public String toString()
{
return this.name().toLowerCase();
}
}
}