本文整理汇总了Java中net.minecraftforge.event.entity.player.UseHoeEvent.getEntityPlayer方法的典型用法代码示例。如果您正苦于以下问题:Java UseHoeEvent.getEntityPlayer方法的具体用法?Java UseHoeEvent.getEntityPlayer怎么用?Java UseHoeEvent.getEntityPlayer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraftforge.event.entity.player.UseHoeEvent
的用法示例。
在下文中一共展示了UseHoeEvent.getEntityPlayer方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onUseHoe
import net.minecraftforge.event.entity.player.UseHoeEvent; //导入方法依赖的package包/类
@SubscribeEvent
public static void onUseHoe(UseHoeEvent event) {
EntityPlayer player = event.getEntityPlayer();
World world = event.getWorld();
BlockPos pos = event.getPos();
IBlockState state = world.getBlockState(pos);
Block block = state.getBlock();
if (block == GenesisBlocks.HUMUS || block == GenesisBlocks.HUMUS_PATH) {
world.playSound(player, pos, SoundEvents.ITEM_HOE_TILL, SoundCategory.BLOCKS, 1.0F, 1.0F);
if (!world.isRemote) {
IBlockState farmland = GenesisBlocks.HUMUS_FARMLAND.getDefaultState();
world.setBlockState(pos, farmland, WorldFlags.UPDATE_BLOCK_AND_CLIENT_AND_RERENDER_ON_MAIN);
}
event.setResult(Event.Result.ALLOW);
}
}
示例2: onUseHoeEvent
import net.minecraftforge.event.entity.player.UseHoeEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onUseHoeEvent(UseHoeEvent event) {
if (ModBlocks.customFarmLand == null) {
return;
}
World world = event.getWorld();
BlockPos pos = event.getPos();
EntityPlayer player = event.getEntityPlayer();
ItemStack stack = event.getCurrent();
IBlockState iblockstate = world.getBlockState(pos);
Block block = iblockstate.getBlock();
if (world.isAirBlock(pos.up())) {
if (block == Blocks.GRASS) {
event.setCanceled(true);
useHoe(stack, player, world, pos, ModBlocks.customFarmLand.getDefaultState());
} else if (block == Blocks.DIRT) {
switch (iblockstate.getValue(BlockDirt.VARIANT)) {
case DIRT:
event.setCanceled(true);
useHoe(stack, player, world, pos, ModBlocks.customFarmLand.getDefaultState());
break;
case COARSE_DIRT:
event.setCanceled(true);
useHoe(stack, player, world, pos, Blocks.DIRT.getDefaultState().withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.DIRT));
break;
}
}
}
}