forked from regelneef/necessities
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCommandSetSpawn.java
More file actions
71 lines (54 loc) · 2.2 KB
/
CommandSetSpawn.java
File metadata and controls
71 lines (54 loc) · 2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package kdx7214.necessities;
import java.io.File;
import java.io.FileOutputStream;
import java.util.List;
import java.util.Set;
import java.util.logging.Logger;
import cpw.mods.fml.common.Loader;
import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommand;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.CompressedStreamTools;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.server.MinecraftServer;
import net.minecraft.src.ModLoader;
import net.minecraft.util.ChunkCoordinates;
public class CommandSetSpawn extends CommandBaseNecessities {
public CommandSetSpawn() {
}
public String getCommandName()
{
return "setspawn";
}
public String getCommandUsage(ICommandSender par1ICommandSender)
{
return "/" + getCommandName() ;
}
public void processCommand(ICommandSender sender, String[] par2ArrayOfStr)
{
MinecraftServer server = ModLoader.getMinecraftServerInstance() ;
EntityPlayer player = getCommandSenderAsPlayer(sender) ;
NBTTagCompound spawn = NecessitiesMain.instance.necessities_data.getCompoundTag("[Spawn]") ;
spawn.setDouble("PosX", player.posX) ;
spawn.setDouble("PosY", player.posY) ;
spawn.setDouble("PosZ", player.posZ) ;
spawn.setFloat("Yaw", player.rotationYaw) ;
spawn.setFloat("Pitch", player.rotationPitch) ;
spawn.setInteger("Dim", player.dimension) ;
NecessitiesMain.instance.necessities_data.setCompoundTag("[Spawn]", spawn) ;
player.worldObj.provider.setSpawnPoint((int)player.posX, (int)player.posY, (int)player.posZ) ;
try {
FileOutputStream fos = new FileOutputStream(getNecessities()) ;
CompressedStreamTools.writeCompressed(NecessitiesMain.instance.necessities_data, fos) ;
fos.close() ;
} catch (Exception e1) {
e1.printStackTrace();
}
player.addChatMessage("New spawn location has been set.") ;
} // public void processCommand(...)
@Override
public boolean canCommandSenderUseCommand(ICommandSender sender) {
return hasPermission(sender, "necessities.setspawn", true, false) ;
} // public boolean canCommandSenderUseCommand(...)
}