骨粉で対象ブロックを成長させるイベント. 旧IBonemealHandler.
クラス
@Cancelable
public class BonemealEvent extends PlayerEvent
{
public final World world;
public final int ID;
public final int X;
public final int Y;
public final int Z;
private boolean handeled = false;
public BonemealEvent(EntityPlayer player, World world, int id, int x, int y, int z)
{
super(player);
this.world = world;
this.ID = id;
this.X = x;
this.Y = y;
this.Z = z;
}
public void setHandeled()
{
handeled = true;
}
public boolean isHandeled()
{
return handeled;
}
}
使用例
public class BonemealEventHook()
{
@ForgeSubscribe
public void onBonemealUsed(BonemealEvent event)
{
EntityPlayer player = event.entityPlayer;
World world = event.world;
int blockID = event.ID;
int x = event.X;
int y = event.Y;
int z = event.Z;
if(!world.isRemote && blockID == @Mod.blockNewSapling.blockID)
{
((BlockNewSapling)@Mod.blockNewSapling).growTree(world, x, y, z, world.rand);
event.setHandeled();
}
}
}
骨粉による成長促進を可能にするイベント. 小麦のような植物の場合はそれに適したメソッドにすればよい. 草ブロックに骨粉を使用した場合に生成される植物(花や雑草)を増やす場合は, MinecraftForge.addGrassPlant()を使う.
最終更新:2012年08月25日 22:19