All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.minecraft.server.CommandEntityData Maven / Gradle / Ivy

package net.minecraft.server;

public class CommandEntityData extends CommandAbstract {
	
	public CommandEntityData() {
	}
	
	public String getCommand() {
		return "entitydata";
	}
	
	public int a() {
		return 2;
	}
	
	public String getUsage(ICommandListener icommandlistener) {
		return "commands.entitydata.usage";
	}
	
	public void execute(ICommandListener icommandlistener, String[] astring) throws CommandException {
		if (astring.length < 2) {
			throw new ExceptionUsage("commands.entitydata.usage");
		} else {
			Entity entity = b(icommandlistener, astring[0]);
			
			if (entity instanceof EntityHuman) {
				throw new CommandException("commands.entitydata.noPlayers", entity.getScoreboardDisplayName());
			} else {
				NBTTagCompound nbttagcompound = new NBTTagCompound();
				
				entity.writeToNBT(nbttagcompound);
				NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbttagcompound.clone();
				
				NBTTagCompound nbttagcompound2;
				
				try {
					nbttagcompound2 = MojangsonParser.parse(a(icommandlistener, astring, 1).c());
				} catch (MojangsonParseException mojangsonparseexception) {
					throw new CommandException("commands.entitydata.tagError", mojangsonparseexception.getMessage());
				}
				
				nbttagcompound2.remove("UUIDMost");
				nbttagcompound2.remove("UUIDLeast");
				nbttagcompound.a(nbttagcompound2);
				if (nbttagcompound.equals(nbttagcompound1)) {
					throw new CommandException("commands.entitydata.failed", nbttagcompound.toString());
				} else {
					entity.readFromNBT(nbttagcompound);
					a(icommandlistener, this, "commands.entitydata.success", nbttagcompound.toString());
				}
			}
		}
	}
	
	public boolean isListStart(String[] astring, int i) {
		return i == 0;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy