blob: e45875d124d7a28f57e17354bce252f13371504e (
plain)
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
|
package jp.plusplus.fbs.command;
import jp.plusplus.fbs.Registry;
import jp.plusplus.fbs.api.FBSEntityPropertiesAPI;
import net.minecraft.command.CommandBase;
import net.minecraft.command.CommandException;
import net.minecraft.command.ICommandSender;
import net.minecraft.command.WrongUsageException;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
/**
* Created by plusplus_F on 2016/03/01.
*/
public class CommandGetBook extends CommandBase {
@Override
public String getCommandName() {
return "givebook";
}
@Override
public String getCommandUsage(ICommandSender p_71518_1_) {
return "commands.fbs.getbook.usage";
}
@Override
public void processCommand(ICommandSender p_71515_1_, String[] p_71515_2_) {
if (p_71515_2_.length >= 2) {
World w = p_71515_1_.getEntityWorld();
EntityPlayer ep = w.getPlayerEntityByName(p_71515_2_[0]);
if (ep == null) new CommandException("commands.generic.player.notFound", new Object[1]);
String name=p_71515_2_[1];
ItemStack itemStack= Registry.GetBookItemStack(name);
if(itemStack==null){
new CommandException("commands.fbs.getbook.notFound", new Object[1]);
}
EntityItem entityitem = ep.dropPlayerItemWithRandomChoice(itemStack, false);
entityitem.delayBeforeCanPickup = 0;
entityitem.func_145797_a(ep.getCommandSenderName());
func_152373_a(p_71515_1_, this, "commands.give.success", new Object[] {itemStack.func_151000_E(), 1, ep.getCommandSenderName()});
} else {
throw new WrongUsageException("commands.fbs.getbook.usage", new Object[0]);
}
}
}
|