mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-05 20:36:42 +00:00
Add support for skull blocks.
This commit is contained in:
@ -59,6 +59,7 @@ import com.sk89q.worldedit.blocks.ItemType;
|
||||
import com.sk89q.worldedit.blocks.MobSpawnerBlock;
|
||||
import com.sk89q.worldedit.blocks.NoteBlock;
|
||||
import com.sk89q.worldedit.blocks.SignBlock;
|
||||
import com.sk89q.worldedit.blocks.SkullBlock;
|
||||
import com.sk89q.worldedit.commands.BiomeCommands;
|
||||
import com.sk89q.worldedit.commands.ChunkCommands;
|
||||
import com.sk89q.worldedit.commands.ClipboardCommands;
|
||||
@ -540,6 +541,43 @@ public class WorldEdit {
|
||||
return new NoteBlock(data, (byte) 0);
|
||||
}
|
||||
|
||||
case HEAD:
|
||||
// allow setting type/player/rotation
|
||||
if (blockAndExtraData.length > 1) {
|
||||
// and thus, the format shall be "|type|rotation" or "|type" or "|rotation"
|
||||
byte rot = 0;
|
||||
String type = "";
|
||||
try {
|
||||
rot = Byte.parseByte(blockAndExtraData[1]);
|
||||
} catch (NumberFormatException e) {
|
||||
type = blockAndExtraData[1];
|
||||
if (blockAndExtraData.length > 2) {
|
||||
try {
|
||||
rot = Byte.parseByte(blockAndExtraData[2]);
|
||||
} catch (NumberFormatException e2) {
|
||||
throw new InvalidItemException(arg, "Second part of skull metadata should be a number.");
|
||||
}
|
||||
}
|
||||
}
|
||||
byte skullType = 0;
|
||||
// type is either the mob type or the player name
|
||||
// sorry for the four minecraft accounts named "skeleton", "wither", "zombie", or "creeper"
|
||||
if (!type.isEmpty()) {
|
||||
if (type.equalsIgnoreCase("skeleton")) skullType = 0;
|
||||
else if (type.equalsIgnoreCase("wither")) skullType = 1;
|
||||
else if (type.equalsIgnoreCase("zombie")) skullType = 2;
|
||||
else if (type.equalsIgnoreCase("creeper")) skullType = 4;
|
||||
else skullType = 3;
|
||||
}
|
||||
if (skullType == 3) {
|
||||
return new SkullBlock(data, rot, type);
|
||||
} else {
|
||||
return new SkullBlock(data, skullType, rot);
|
||||
}
|
||||
} else {
|
||||
return new SkullBlock(data);
|
||||
}
|
||||
|
||||
default:
|
||||
return new BaseBlock(blockId, data);
|
||||
}
|
||||
|
Reference in New Issue
Block a user