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
|
package jp.plusplus.fbs.magic;
import cpw.mods.fml.common.registry.VillagerRegistry;
import jp.plusplus.fbs.api.MagicBase;
import jp.plusplus.fbs.block.BlockCore;
import jp.plusplus.fbs.entity.EntityMagicAuthor;
import net.minecraft.block.Block;
import net.minecraft.entity.passive.EntityVillager;
import net.minecraft.util.MathHelper;
/**
* Created by plusplus_F on 2015/09/27.
*/
public class MagicSummonVillager extends MagicBase {
public static final int BOOKSHELF=24;
@Override
public boolean checkSuccess() {
return false;
}
@Override
public String getMagicCircleName(){
return "fbs.summonVillager";
}
@Override
public void success() {
sanity(2,6);
//魔法陣の周囲の本棚を数える
int x= MathHelper.floor_double(player.posX);
int y= MathHelper.floor_double(player.posY);
int z= MathHelper.floor_double(player.posZ);
int count=0;
for(int k=0;k<2;k++){
for(int i=0;i<5;i++){
if(world.getBlock(x-2+i, y+k, z-2)==BlockCore.bookshelf) count++;
if(world.getBlock(x-2+i, y+k, z+2)==BlockCore.bookshelf) count++;
}
for(int i=0;i<3;i++){
if(world.getBlock(x-2, y+k, z-1+i)==BlockCore.bookshelf) count++;
if(world.getBlock(x+2, y+k, z-1+i)==BlockCore.bookshelf) count++;
}
}
//本棚が一定数以上あれば作家を湧かせる
if(count>=BOOKSHELF){
EntityMagicAuthor e=new EntityMagicAuthor(world);
e.setPosition(player.posX+2*rand.nextFloat(), player.posY, player.posZ+2*rand.nextFloat());
world.spawnEntityInWorld(e);
}
else{
//通常の処理
EntityVillager e=new EntityVillager(world, rand.nextInt(5+VillagerRegistry.getRegisteredVillagers().size()));
e.setPosition(player.posX+2*rand.nextFloat(), player.posY, player.posZ+2*rand.nextFloat());
world.spawnEntityInWorld(e);
}
}
@Override
public void failure() {
sanity(3, 8);
}
}
|